BehospitalInfoMapper.xml 719 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
  5. <!-- 通用查询映射结果 -->
  6. <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
  7. <id column="behospital_code" property="behospitalCode"/>
  8. <result column="hospital_id" property="hospitalId"/>
  9. <result column="name" property="name"/>
  10. <result column="sex" property="sex"/>
  11. <result column="birthday" property="birthday"/>
  12. <result column="file_code" property="fileCode"/>
  13. <result column="qc_type_id" property="qcTypeId"/>
  14. <result column="ward_code" property="wardCode"/>
  15. <result column="ward_name" property="wardName"/>
  16. <result column="beh_dept_id" property="behDeptId"/>
  17. <result column="beh_dept_name" property="behDeptName"/>
  18. <result column="bed_code" property="bedCode"/>
  19. <result column="bed_name" property="bedName"/>
  20. <result column="insurance_name" property="insuranceName"/>
  21. <result column="job_type" property="jobType"/>
  22. <result column="behospital_date" property="behospitalDate"/>
  23. <result column="leave_hospital_date" property="leaveHospitalDate"/>
  24. <result column="diagnose_icd" property="diagnoseIcd"/>
  25. <result column="diagnose" property="diagnose"/>
  26. <result column="beh_doctor_id" property="behDoctorId"/>
  27. <result column="beh_doctor_name" property="behDoctorName"/>
  28. <result column="doctor_id" property="doctorId"/>
  29. <result column="doctor_name" property="doctorName"/>
  30. <result column="director_doctor_id" property="directorDoctorId"/>
  31. <result column="director_doctor_name" property="directorDoctorName"/>
  32. <result column="is_placefile" property="isPlacefile"/>
  33. <result column="placefile_date" property="placefileDate"/>
  34. <result column="is_deleted" property="isDeleted"/>
  35. <result column="gmt_create" property="gmtCreate"/>
  36. <result column="gmt_modified" property="gmtModified"/>
  37. <result column="creator" property="creator"/>
  38. <result column="modifier" property="modifier"/>
  39. <result column="linkman" property="linkman"/>
  40. </resultMap>
  41. <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
  42. SELECT * FROM (
  43. select t.*,
  44. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  45. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  46. g.check_type AS ch_type,
  47. h.check_type AS mr_type,
  48. g.check_name AS ch_name,
  49. h.check_name AS mr_name,
  50. g.check_time AS ch_time,
  51. h.check_time AS mr_time
  52. from (
  53. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  54. grade_time,IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,e.score_res as score_bn from med_behospital_info a
  55. LEFT JOIN med_qcresult_info b
  56. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  57. left join med_home_page c
  58. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  59. LEFT JOIN med_qcresult_cases e
  60. on a.behospital_code = e.behospital_code
  61. AND e.is_deleted = 'N'
  62. and e.cases_id = 243
  63. ) t
  64. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  65. ON t.behospital_code = g.behospital_code
  66. AND t.hospital_id = g.hospital_id
  67. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  68. ON t.behospital_code = h.behospital_code
  69. AND t.hospital_id = h.hospital_id
  70. where t.is_deleted = 'N'
  71. <if test="diagnose != null and diagnose != ''">
  72. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  73. </if>
  74. <if test="deptName != null and deptName != ''">
  75. and t.beh_dept_name= #{deptName}
  76. </if>
  77. <if test="doctorName != null and doctorName != ''">
  78. and CONCAT(
  79. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  80. like CONCAT('%',#{doctorName},'%')
  81. </if>
  82. <if test="name != null and name != ''">
  83. and t.name like CONCAT('%',#{name},'%')
  84. </if>
  85. <if test="doctorCode != null and doctorCode != ''">
  86. and (t.doctor_id = #{doctorCode}
  87. or t.beh_doctor_id = #{doctorCode}
  88. or t.director_doctor_id = #{doctorCode})
  89. </if>
  90. <if test="fileCode != null and fileCode != ''">
  91. and t.file_code like CONCAT('%',#{fileCode},'%')
  92. </if>
  93. <if test="hospitalId != null">
  94. and t.hospital_id = #{hospitalId}
  95. </if>
  96. <if test="behospitalCode != null and behospitalCode != ''">
  97. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  98. </if>
  99. <if test="behosDateStart != null">
  100. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  101. </if>
  102. <if test="behosDateEnd != null">
  103. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  104. </if>
  105. <if test="leaveHosDateStart != null">
  106. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  107. </if>
  108. <if test="leaveHosDateEnd != null">
  109. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  110. </if>
  111. <if test="level != null and level != ''">
  112. and t.level = #{level}
  113. </if>
  114. <if test="isPlacefile != null and isPlacefile != ''">
  115. and t.is_placefile = #{isPlacefile}
  116. </if>
  117. and t.qc_type_id != 0) p
  118. where p.is_deleted="N"
  119. <if test="checkStatus != null ">
  120. and p.check_status = #{checkStatus}
  121. </if>
  122. <if test="mrStatus != null ">
  123. AND p.mr_status = #{mrStatus}
  124. </if>
  125. <if test="chName != null and chName !=''">
  126. AND p.ch_name like CONCAT('%',#{chName},'%')
  127. </if>
  128. <if test="mrName != null and mrName !=''">
  129. AND p.mr_name like CONCAT('%',#{mrName},'%')
  130. </if>
  131. <if test="chTimeStart != null">
  132. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  133. </if>
  134. <if test="chTimeEnd != null">
  135. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  136. </if>
  137. <if test="mrTimeStart != null">
  138. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  139. </if>
  140. <if test="mrTimeEnd != null">
  141. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  142. </if>
  143. </select>
  144. <select id="getQualityCaseSorce" resultType="com.diagbot.dto.CaseScoreDTO">
  145. SELECT c.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  146. FROM med_qcresult_detail c,med_behospital_info e
  147. where c.is_deleted = 'N'AND e.is_deleted = 'N'
  148. AND c.behospital_code = e.behospital_code
  149. AND c.hospital_id = e.hospital_id
  150. and c.hospital_id = #{hospitalId}
  151. <if test="deptName != null and deptName != ''">
  152. and e.beh_dept_name= #{deptName}
  153. </if>
  154. <if test="behospitalCode != null and behospitalCode != ''">
  155. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  156. </if>
  157. <if test="isPlacefile != null and isPlacefile != ''">
  158. and e.is_placefile = #{isPlacefile}
  159. </if>
  160. <if test="behosDateStart != null">
  161. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  162. </if>
  163. <if test="behosDateEnd != null">
  164. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  165. </if>
  166. <if test="leaveHosDateStart != null">
  167. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  168. </if>
  169. <if test="leaveHosDateEnd != null">
  170. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  171. </if>
  172. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  173. order by c.behospital_code
  174. </select>
  175. <select id="getQualityCaseSorceByDept" resultType="com.diagbot.dto.CaseScoreDTO">
  176. SELECT c.cases_id as casesId,c.cases_entry_id as casesEntryId,c.behospital_code as behospitalCode,c.score,c.cases_score as casesScore,c.msg,c.is_reject as isReject
  177. FROM med_qcresult_detail c,sys_user_dept d,med_behospital_info e
  178. where c.is_deleted = 'N' AND d.is_deleted = 'N' AND e.is_deleted = 'N'
  179. AND c.behospital_code = e.behospital_code
  180. ON d.hospital_id = e.hospital_id
  181. AND e.beh_dept_id = d.dept_id
  182. AND c.hospital_id = e.hospital_id
  183. and c.hospital_id = #{hospitalId}
  184. <if test="deptName != null and deptName != ''">
  185. and e.beh_dept_name= #{deptName}
  186. </if>
  187. <if test="userId != null and userId != ''">
  188. and d.user_id = #{userId}
  189. </if>
  190. <if test="behospitalCode != null and behospitalCode != ''">
  191. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  192. </if>
  193. <if test="isPlacefile != null and isPlacefile != ''">
  194. and e.is_placefile = #{isPlacefile}
  195. </if>
  196. <if test="behosDateStart != null">
  197. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  198. </if>
  199. <if test="behosDateEnd != null">
  200. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  201. </if>
  202. <if test="leaveHosDateStart != null">
  203. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  204. </if>
  205. <if test="leaveHosDateEnd != null">
  206. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  207. </if>
  208. GROUP BY c.behospital_code,c.cases_id,c.cases_entry_id
  209. order by c.behospital_code
  210. </select>
  211. <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  212. SELECT * FROM (
  213. select
  214. distinct
  215. t.name AS NAME,
  216. t.behospital_code AS behospitalCode,
  217. t.doctor_name AS doctorName,
  218. t.beh_dept_name AS deptName,
  219. t.beh_dept_id AS deptId,
  220. t.leave_hospital_date AS leaveHospitalDate,
  221. t.level,
  222. t.age,
  223. t.score_res as totalScore,
  224. t.is_deleted,
  225. g.check_name AS chName,
  226. h.check_name AS mrName
  227. from (
  228. select a.*,
  229. ifnull(b.level,'未评分') as level,
  230. b.grade_type,
  231. IF(c.age is null, null,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') ))as age,
  232. b.score_res
  233. from med_behospital_info a
  234. LEFT JOIN med_qcresult_info b
  235. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  236. left join med_home_page c
  237. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  238. ) t
  239. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  240. ON t.behospital_code = g.behospital_code
  241. AND t.hospital_id = g.hospital_id
  242. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  243. ON t.behospital_code = h.behospital_code
  244. AND t.hospital_id = h.hospital_id
  245. where t.is_deleted = 'N'
  246. <if test="diagnose != null and diagnose != ''">
  247. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  248. </if>
  249. <if test="deptName != null and deptName != ''">
  250. and t.beh_dept_name= #{deptName}
  251. </if>
  252. <if test="doctorName != null and doctorName != ''">
  253. and CONCAT(
  254. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  255. like CONCAT('%',#{doctorName},'%')
  256. </if>
  257. <if test="name != null and name != ''">
  258. and t.name like CONCAT('%',#{name},'%')
  259. </if>
  260. <if test="doctorCode != null and doctorCode != ''">
  261. and (t.doctor_id = #{doctorCode}
  262. or t.beh_doctor_id = #{doctorCode}
  263. or t.director_doctor_id = #{doctorCode})
  264. </if>
  265. <if test="fileCode != null and fileCode != ''">
  266. and t.file_code like CONCAT('%',#{fileCode},'%')
  267. </if>
  268. <if test="hospitalId != null">
  269. and t.hospital_id = #{hospitalId}
  270. </if>
  271. <if test="behospitalCode != null and behospitalCode != ''">
  272. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  273. </if>
  274. <if test="behosDateStart != null">
  275. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  276. </if>
  277. <if test="behosDateEnd != null">
  278. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  279. </if>
  280. <if test="leaveHosDateStart != null">
  281. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  282. </if>
  283. <if test="leaveHosDateEnd != null">
  284. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  285. </if>
  286. <if test="level != null and level != ''">
  287. and t.level = #{level}
  288. </if>
  289. <if test="isPlacefile != null and isPlacefile != ''">
  290. and t.is_placefile = #{isPlacefile}
  291. </if>
  292. and t.qc_type_id != 0) p
  293. where p.is_deleted="N"
  294. <if test="chName != null and chName !=''">
  295. AND p.chName like CONCAT('%',#{chName},'%')
  296. </if>
  297. <if test="mrName != null and mrName !=''">
  298. AND p.mrName like CONCAT('%',#{mrName},'%')
  299. </if>
  300. </select>
  301. <select id="qualityControlByDept" resultType="com.diagbot.dto.QualityControlDeptDTO">
  302. SELECT * FROM (
  303. select
  304. distinct
  305. t.name AS NAME,
  306. t.behospital_code AS behospitalCode,
  307. t.doctor_name AS doctorName,
  308. t.beh_dept_name AS deptName,
  309. t.beh_dept_id AS deptId,
  310. t.leave_hospital_date AS leaveHospitalDate,
  311. t.level,
  312. t.age,
  313. t.score_res as totalScore,
  314. t.is_deleted,
  315. g.check_name AS chName,
  316. h.check_name AS mrName
  317. from (
  318. select a.*, ifnull(b.level,'未评分') as level, IF(c.age is null, null,CONCAT( ifnull(c.age,''),ifnull(c.age_unit,'') ))as age, b.grade_type,d.user_id, b.score_res, b.gmt_create as
  319. grade_time from med_behospital_info a
  320. LEFT JOIN med_qcresult_info b
  321. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  322. left join med_home_page c
  323. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  324. LEFT JOIN sys_user_dept d
  325. ON a.hospital_id = d.hospital_id
  326. AND a.beh_dept_id = d.dept_id
  327. ) t
  328. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  329. ON t.behospital_code = g.behospital_code
  330. AND t.hospital_id = g.hospital_id
  331. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  332. ON t.behospital_code = h.behospital_code
  333. AND t.hospital_id = h.hospital_id
  334. where t.is_deleted = 'N'
  335. AND t.user_id = #{userId}
  336. <if test="diagnose != null and diagnose != ''">
  337. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  338. </if>
  339. <if test="deptName != null and deptName != ''">
  340. and t.beh_dept_name= #{deptName}
  341. </if>
  342. <if test="doctorName != null and doctorName != ''">
  343. and CONCAT(
  344. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  345. like CONCAT('%',#{doctorName},'%')
  346. </if>
  347. <if test="name != null and name != ''">
  348. and t.name like CONCAT('%',#{name},'%')
  349. </if>
  350. <if test="doctorCode != null and doctorCode != ''">
  351. and (t.doctor_id = #{doctorCode}
  352. or t.beh_doctor_id = #{doctorCode}
  353. or t.director_doctor_id = #{doctorCode})
  354. </if>
  355. <if test="fileCode != null and fileCode != ''">
  356. and t.file_code like CONCAT('%',#{fileCode},'%')
  357. </if>
  358. <if test="hospitalId != null">
  359. and t.hospital_id = #{hospitalId}
  360. </if>
  361. <if test="behospitalCode != null and behospitalCode != ''">
  362. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  363. </if>
  364. <if test="behosDateStart != null">
  365. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  366. </if>
  367. <if test="behosDateEnd != null">
  368. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  369. </if>
  370. <if test="leaveHosDateStart != null">
  371. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  372. </if>
  373. <if test="leaveHosDateEnd != null">
  374. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  375. </if>
  376. <if test="level != null and level != ''">
  377. and t.level = #{level}
  378. </if>
  379. <if test="isPlacefile != null and isPlacefile != ''">
  380. and t.is_placefile = #{isPlacefile}
  381. </if>
  382. and t.qc_type_id != 0) p
  383. where p.is_deleted="N"
  384. <if test="chName != null and chName !=''">
  385. AND p.chName like CONCAT('%',#{chName},'%')
  386. </if>
  387. <if test="mrName != null and mrName !=''">
  388. AND p.mrName like CONCAT('%',#{mrName},'%')
  389. </if>
  390. </select>
  391. <!-- <select id="getQualityControl" resultType="com.diagbot.dto.QualityControlDTO">
  392. SELECT m.* FROM(
  393. SELECT
  394. a.name AS NAME,
  395. a.behospital_code AS behospitalCode,
  396. a.doctor_name AS doctorName,
  397. a.beh_dept_name AS deptName,
  398. a.beh_dept_id AS deptId,
  399. a.leave_hospital_date AS leaveHospitalDate,
  400. c.behospital_code,
  401. c.hospital_id,
  402. c.admissionNote,
  403. c.firstCourseNote,
  404. c.medHomePage,
  405. c.docAdviceNote,
  406. c.courseRecord,
  407. c.operationInfo,
  408. c.dischargeNote,
  409. c.admissionNoteScore,
  410. c.firstCourseNoteScore,
  411. c. medHomePageScore,
  412. c.docAdviceNoteScore,
  413. c.courseRecordScore,
  414. c.operationInfoScore,
  415. c.dischargeNoteScore,
  416. c.otherCase,
  417. (100.0-c.score_res) AS otherCaseScore,
  418. IFNULL(b.level,'未评分') AS `level`,
  419. g.check_name AS ch_name,
  420. h.check_name AS mr_name
  421. FROM
  422. med_behospital_info a LEFT JOIN med_qcresult_info b
  423. ON a.behospital_code = b.behospital_code AND b.is_deleted = 'N'
  424. LEFT JOIN (
  425. SELECT
  426. t.behospital_code,
  427. t.hospital_id,
  428. t.admissionNote,
  429. t.firstCourseNote,
  430. t.medHomePage,
  431. t.docAdviceNote,
  432. t.courseRecord,
  433. t.operationInfo,
  434. t.dischargeNote,
  435. t.otherCase,
  436. t.score_res,
  437. if(t.admissionNoteScoreOn >= t.admissionNoteTolScore, (t.admissionNoteTolScore + t.admissionNoteScoreTh),(t.admissionNoteScoreOn + t.admissionNoteScoreTh)) AS admissionNoteScore,
  438. if(t.firstCourseNoteScoreOn >= t.firstCourseNoteTolScore, (t.firstCourseNoteTolScore + t.firstCourseNoteScoreTh),(t.firstCourseNoteScoreOn + t.firstCourseNoteScoreTh)) AS firstCourseNoteScore,
  439. if(t.medHomePageScoreOn >= t.medHomePageTolScore, (t.medHomePageTolScore + t.medHomePageScoreTh),(t.medHomePageScoreOn + t.medHomePageScoreTh)) AS medHomePageScore,
  440. if(t.docAdviceNoteScoreOn >= t.docAdviceNoteTolScore, (t.docAdviceNoteTolScore + t.docAdviceNoteScoreTh),(t.docAdviceNoteScoreOn + t.docAdviceNoteScoreTh)) AS docAdviceNoteScore,
  441. if(t.courseRecordScoreOn >= t.courseRecordTolScore, (t.courseRecordTolScore + t.courseRecordScoreTh),(t.courseRecordScoreOn + t.courseRecordScoreTh)) AS courseRecordScore,
  442. if(t.operationInfoScoreOn >= t.operationInfoTolScore, (t.operationInfoTolScore + t.operationInfoScoreTh),(t.operationInfoScoreOn + t.operationInfoScoreTh)) AS operationInfoScore,
  443. if(t.dischargeNoteScoreOn >= t.dischargeNoteTolScore, (t.dischargeNoteTolScore + t.dischargeNoteScoreTh),(t.dischargeNoteScoreOn + t.dischargeNoteScoreTh)) AS dischargeNoteScore
  444. from(
  445. select
  446. t1.*,
  447. t2.admissionNoteTolScore,
  448. t2.firstCourseNoteTolScore,
  449. t2.medHomePageTolScore,
  450. t2.docAdviceNoteTolScore,
  451. t2.courseRecordTolScore,
  452. t2.operationInfoTolScore,
  453. t2.dischargeNoteTolScore,
  454. t2.score_res FROM (
  455. SELECT
  456. t1.behospital_code,
  457. t1.hospital_id,
  458. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 1 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS admissionNote,
  459. SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS admissionNoteScoreOn,
  460. SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END) AS admissionNoteScoreTw,
  461. (SUM(CASE WHEN t1.mode_id =1 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =1 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS admissionNoteScoreTh,
  462. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 2 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS firstCourseNote,
  463. SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreOn,
  464. SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) AS firstCourseNoteScoreTw,
  465. (SUM(CASE WHEN t1.mode_id =2 THEN t1.score ELSE 0 END) -SUM(CASE WHEN t1.mode_id =2 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS firstCourseNoteScoreTh,
  466. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 6 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS medHomePage,
  467. SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS medHomePageScoreOn,
  468. SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END) AS medHomePageScoreTw,
  469. (SUM(CASE WHEN t1.mode_id =6 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =6 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS medHomePageScoreTh,
  470. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 8 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS docAdviceNote,
  471. SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreOn,
  472. SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END) AS docAdviceNoteScoreTw,
  473. (SUM(CASE WHEN t1.mode_id =8 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =8 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS docAdviceNoteScoreTh,
  474. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 56 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS courseRecord,
  475. SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS courseRecordScoreOn,
  476. SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END) AS courseRecordScoreTw,
  477. (SUM(CASE WHEN t1.mode_id =56 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =56 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS courseRecordScoreTh,
  478. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 17 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS operationInfo,
  479. SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS operationInfoScoreOn,
  480. SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END) AS operationInfoScoreTw,
  481. (SUM(CASE WHEN t1.mode_id =17 THEN t1.score ELSE 0 END)-SUM(CASE WHEN t1.mode_id =17 AND t1.is_reject = 0 THEN t1.score ELSE 0 END)) AS operationInfoScoreTh,
  482. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS dischargeNote,
  483. SUM(CASE WHEN t1.mode_id =5 AND t1.is_reject = 0 THEN t1.score ELSE 0 END) AS dischargeNoteScoreOn,
  484. SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END) AS dischargeNoteScoreTw,
  485. (SUM(CASE WHEN t1.mode_id =5 THEN t1.score ELSE 0 END)-GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id = 5 THEN t1.msg ELSE NULL END SEPARATOR ';' )) AS dischargeNoteScoreTh,
  486. GROUP_CONCAT(DISTINCT CASE WHEN t1.mode_id != 1 AND t1.mode_id != 2 AND t1.mode_id != 6 AND t1.mode_id != 8 AND t1.mode_id != 156 AND t1.mode_id != 17 AND t1.mode_id != 5 THEN t1.msg ELSE NULL END SEPARATOR ';' ) AS otherCase
  487. FROM (
  488. SELECT
  489. c.behospital_code,
  490. c.hospital_id,
  491. a.mode_id,
  492. c.cases_score,
  493. c.score,
  494. c.msg,
  495. c.is_reject,
  496. c.cases_id
  497. FROM
  498. `qc_cases_entry` a,
  499. qc_mode b,
  500. med_qcresult_detail c,
  501. qc_cases_hospital d,
  502. med_behospital_info e
  503. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  504. AND a.id = c.cases_entry_id
  505. AND a.mode_id = b.id
  506. AND c.cases_id = d.cases_id
  507. AND c.hospital_id = d.hospital_id
  508. AND c.behospital_code = e.behospital_code
  509. AND c.hospital_id = e.hospital_id
  510. <if test="hospitalId != null">
  511. and c.hospital_id = #{hospitalId}
  512. </if>
  513. <if test="deptName != null and deptName != ''">
  514. and e.beh_dept_name= #{deptName}
  515. </if>
  516. <if test="behospitalCode != null and behospitalCode != ''">
  517. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  518. </if>
  519. <if test="isPlacefile != null and isPlacefile != ''">
  520. and e.is_placefile = #{isPlacefile}
  521. </if>
  522. <if test="behosDateStart != null">
  523. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  524. </if>
  525. <if test="behosDateEnd != null">
  526. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  527. </if>
  528. <if test="leaveHosDateStart != null">
  529. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  530. </if>
  531. <if test="leaveHosDateEnd != null">
  532. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  533. </if>
  534. <if test="level != null and level != ''">
  535. and e.level = #{level}
  536. </if>
  537. <if test="level != null and level != ''">
  538. and e.level = #{level}
  539. </if>
  540. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  541. )t1 GROUP BY behospital_code)t1
  542. LEFT JOIN (
  543. SELECT m1.*, m2.score_res FROM(
  544. SELECT
  545. m1.hospital_id,
  546. m1.behospital_code,
  547. SUM(CASE WHEN m1.mode_id =1 THEN m1.cases_score ELSE 0 END) AS admissionNoteTolScore,
  548. SUM(CASE WHEN m1.mode_id =2 THEN m1.cases_score ELSE 0 END) AS firstCourseNoteTolScore,
  549. SUM(CASE WHEN m1.mode_id =6 THEN m1.cases_score ELSE 0 END) AS medHomePageTolScore,
  550. SUM(CASE WHEN m1.mode_id =8 THEN m1.cases_score ELSE 0 END) AS docAdviceNoteTolScore,
  551. SUM(CASE WHEN m1.mode_id =56 THEN m1.cases_score ELSE 0 END) AS courseRecordTolScore,
  552. SUM(CASE WHEN m1.mode_id =17 THEN m1.cases_score ELSE 0 END) AS operationInfoTolScore,
  553. SUM(CASE WHEN m1.mode_id =5 THEN m1.cases_score ELSE 0 END) AS dischargeNoteTolScore
  554. FROM (
  555. SELECT
  556. c.behospital_code,
  557. a.mode_id,
  558. c.cases_score,
  559. c.cases_id,
  560. c.hospital_id
  561. FROM
  562. `qc_cases_entry` a,
  563. qc_mode b,
  564. med_qcresult_detail c,
  565. qc_cases_hospital d,
  566. med_behospital_info e
  567. WHERE a.is_deleted = 'N' AND b.is_deleted = 'N' AND c.is_deleted = 'N' AND d.is_deleted = 'N'AND e.is_deleted = 'N'
  568. AND a.id = c.cases_entry_id
  569. AND a.mode_id = b.id
  570. AND c.cases_id = d.cases_id
  571. AND c.hospital_id = d.hospital_id
  572. AND c.behospital_code = e.behospital_code
  573. AND c.hospital_id = e.hospital_id
  574. <if test="hospitalId != null">
  575. and c.hospital_id = #{hospitalId}
  576. </if>
  577. <if test="deptName != null and deptName != ''">
  578. and e.beh_dept_name= #{deptName}
  579. </if>
  580. <if test="behospitalCode != null and behospitalCode != ''">
  581. and e.behospital_code like CONCAT('%',#{behospitalCode},'%')
  582. </if>
  583. <if test="isPlacefile != null and isPlacefile != ''">
  584. and e.is_placefile = #{isPlacefile}
  585. </if>
  586. <if test="behosDateStart != null">
  587. <![CDATA[ and e.behospital_date >= #{behosDateStart}]]>
  588. </if>
  589. <if test="behosDateEnd != null">
  590. <![CDATA[ and e.behospital_date < #{behosDateEnd}]]>
  591. </if>
  592. <if test="leaveHosDateStart != null">
  593. <![CDATA[ and e.leave_hospital_date >= #{leaveHosDateStart}]]>
  594. </if>
  595. <if test="leaveHosDateEnd != null">
  596. <![CDATA[ and e.leave_hospital_date < #{leaveHosDateEnd}]]>
  597. </if>
  598. <if test="level != null and level != ''">
  599. and e.level = #{level}
  600. </if>
  601. <if test="level != null and level != ''">
  602. and e.level = #{level}
  603. </if>
  604. GROUP BY mode_id
  605. ORDER BY b.order_no, c.grade_type DESC, a.order_no
  606. )m1 GROUP BY behospital_code)m1 LEFT JOIN med_qcresult_info m2
  607. ON m2.is_deleted = 'N'
  608. AND m1.hospital_id = m2.hospital_id
  609. AND m1.behospital_code = m2.behospital_code
  610. )t2
  611. ON t1.hospital_id = t2.hospital_id
  612. AND t1.behospital_code = t2.behospital_code)t)c
  613. ON a.behospital_code = c.behospital_code
  614. AND a.hospital_id = c.hospital_id
  615. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  616. ON a.behospital_code = g.behospital_code
  617. AND a.hospital_id = g.hospital_id
  618. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  619. ON a.behospital_code = h.behospital_code
  620. AND a.hospital_id = h.hospital_id
  621. where
  622. a.is_deleted = 'N'
  623. <if test="deptName != null and deptName != ''">
  624. and a.beh_dept_name= #{deptName}
  625. </if>
  626. <if test="doctorName != null and doctorName != ''">
  627. and CONCAT(
  628. IFNULL(a.doctor_name,''),IFNULL(a.beh_doctor_name,''),IFNULL(a.director_doctor_name,''))
  629. like CONCAT('%',#{doctorName},'%')
  630. </if>
  631. <if test="name != null and name != ''">
  632. and a.name like CONCAT('%',#{name},'%')
  633. </if>
  634. <if test="doctorCode != null and doctorCode != ''">
  635. and (a.doctor_id = #{doctorCode}
  636. or a.beh_doctor_id = #{doctorCode}
  637. or a.director_doctor_id = #{doctorCode})
  638. </if>
  639. <if test="fileCode != null and fileCode != ''">
  640. and a.file_code like CONCAT('%',#{fileCode},'%')
  641. </if>
  642. <if test="hospitalId != null">
  643. and a.hospital_id = #{hospitalId}
  644. </if>
  645. <if test="behospitalCode != null and behospitalCode != ''">
  646. and a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  647. </if>
  648. <if test="behosDateStart != null">
  649. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  650. </if>
  651. <if test="behosDateEnd != null">
  652. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  653. </if>
  654. <if test="leaveHosDateStart != null">
  655. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  656. </if>
  657. <if test="leaveHosDateEnd != null">
  658. <![CDATA[ and a.leave_hospital_date < #{leaveHosDateEnd}]]>
  659. </if>
  660. <if test="level != null and level != ''">
  661. and a.level = #{level}
  662. </if>
  663. <if test="isPlacefile != null and isPlacefile != ''">
  664. and a.is_placefile = #{isPlacefile}
  665. </if>
  666. and a.qc_type_id != 0
  667. <if test="chName != null and chName !=''">
  668. AND g.ch_name like CONCAT('%',#{chName},'%')
  669. </if>
  670. <if test="mrName != null and mrName !=''">
  671. AND h.mr_name like CONCAT('%',#{mrName},'%')
  672. </if>)m
  673. </select>-->
  674. <select id="getMsg" resultType="com.diagbot.dto.MsgDTO">
  675. SELECT a.*, u.linkman
  676. FROM
  677. (
  678. SELECT DISTINCT b.`name` model_name,c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info, a.cases_id cases_id, d.score cases_score,
  679. b.id model_id, a.name standard_msg, c.opt_type, c.grade_type,
  680. c.gmt_create, c.gmt_modified, c.modifier,c.is_deleted,c.explain_info as explainInfo,
  681. a.type, a.drgs
  682. FROM
  683. `qc_cases_entry` a, qc_mode b, med_qcresult_detail c, qc_cases_hospital d
  684. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  685. and a.id = c.cases_entry_id and a.mode_id = b.id
  686. AND c.cases_id = d.cases_id and c.hospital_id = d.hospital_id
  687. and c.hospital_id = #{hospitalId}
  688. and c.behospital_code = #{behospitalCode}
  689. order by b.order_no, c.grade_type desc, a.order_no) a
  690. LEFT JOIN sys_user u on u.id = a.modifier and u.is_deleted = 'N'
  691. </select>
  692. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  693. SELECT b.id model_id,b.`name` model_name,
  694. d.score,d.msg,d.cases_entry_id,d.is_reject,
  695. a.cases_id cases_id, a.name standard_msg,a.code
  696. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  697. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  698. and a.mode_id = b.id
  699. and a.id = d.cases_entry_id
  700. and d.is_used = 1
  701. and d.hospital_id = #{hospitalId}
  702. and a.code in
  703. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  704. #{item}
  705. </foreach>
  706. <if test="modeId != null">
  707. and a.mode_id = #{modeId}
  708. </if>
  709. order by b.order_no, a.order_no;
  710. </select>
  711. <!--病案管理指标基础sql明细-->
  712. <select id="getBaseIndex" parameterType="com.diagbot.vo.MedIndexFilterVO" resultType="java.util.Map">
  713. select
  714. f1.firWorkNum,
  715. f2.secWorkNum,
  716. f3.thrWorkNum,
  717. f3.forWorkNum,
  718. f3.sixWorkNum
  719. from (
  720. SELECT count(DISTINCT a.behospital_code) as firWorkNum
  721. FROM
  722. med_behospital_info a
  723. WHERE
  724. a.is_deleted = 'N'
  725. AND a.is_placefile = 1
  726. <if test="hospitalId != null and hospitalId != ''">
  727. AND a.hospital_id = #{hospitalId}
  728. </if>
  729. <![CDATA[AND a.qc_type_id <>0 ]]>
  730. <if test="startDate != null and startDate != ''">
  731. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  732. </if>
  733. <if test="endDate != null and endDate != ''">
  734. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  735. </if>)f1,
  736. ( SELECT count(DISTINCT a.behospital_code) AS secWorkNum
  737. FROM
  738. med_outpatient_info a
  739. WHERE
  740. a.is_deleted = 'N'
  741. <if test="startDate != null and startDate != ''">
  742. <![CDATA[ AND a.visit_date >= #{lastStartDate}]]>
  743. </if>
  744. <if test="endDate != null and endDate != ''">
  745. <![CDATA[ AND a.visit_date <= #{lastEndDate}]]>
  746. </if>
  747. <if test="hospitalId != null and hospitalId != ''">
  748. AND a.hospital_id = #{hospitalId}
  749. </if>)f2,(
  750. select
  751. count(DISTINCT case when <![CDATA[m.behospital_date >= #{startDate}]]> and <![CDATA[m.behospital_date <= #{endDate}]]>
  752. and m.is_placefile = 0 then m.behospital_code else null end) as thrWorkNum,
  753. count(DISTINCT case when <![CDATA[m.leave_hospital_date >= #{startDate}]]> and <![CDATA[m.leave_hospital_date <= #{endDate}]]> and m.is_placefile = 1 then m.behospital_code else null end) as forWorkNum,
  754. count(DISTINCT case when <![CDATA[m.leave_hospital_date >= #{startDate}]]> and <![CDATA[m.leave_hospital_date <= #{endDate}]]> and m.is_placefile = 1 and m.level = '甲' then m.behospital_code else null end) as sixWorkNum
  755. from(
  756. SELECT DISTINCT a.*,b.level
  757. FROM
  758. med_behospital_info a,
  759. med_qcresult_info b
  760. WHERE
  761. a.is_deleted = 'N'
  762. AND b.is_deleted = 'N'
  763. AND a.hospital_id = b.hospital_id
  764. AND a.behospital_code = b.behospital_code
  765. <![CDATA[AND a.qc_type_id <>0 ]]>
  766. <if test="hospitalId != null and hospitalId != ''">
  767. AND a.hospital_id = #{hospitalId}
  768. </if>)m
  769. )f3
  770. </select>
  771. <!-- 病案管理规则质控缺陷病历总数查询-->
  772. <select id="getMedManageParams" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.MedManageParamsDTO">
  773. SELECT
  774. f1.behospitalCode,
  775. <if test="flagStr != null and flagStr == 1 ">
  776. f2.rep_name as repName,
  777. </if>
  778. <if test="flagStr != null and flagStr == 2">
  779. f3.da_item_name as daItemName,
  780. f3.da_status AS daStatus,
  781. f3.doctor_advice_type as doctorAdviceType,
  782. </if>
  783. <if test="flagStr != null and flagStr == 4 ">
  784. f5.content as content,
  785. f5.rec_title as recTitle,
  786. </if>
  787. f1.hospitalId
  788. from(
  789. SELECT DISTINCT
  790. a.hospital_id as hospitalId,
  791. a.behospital_code as behospitalCode
  792. FROM
  793. med_behospital_info a,
  794. med_qcresult_info b
  795. WHERE
  796. a.is_deleted = 'N'
  797. AND b.is_deleted = 'N'
  798. AND a.hospital_id = b.hospital_id
  799. AND a.behospital_code = b.behospital_code
  800. AND <![CDATA[a.leave_hospital_date >= #{startDate}]]>
  801. AND <![CDATA[a.leave_hospital_date <= #{endDate}]]>
  802. AND a.is_placefile = 1
  803. <![CDATA[AND a.qc_type_id <>0 ]]>
  804. <if test="hospitalId != null and hospitalId != ''">
  805. AND a.hospital_id = #{hospitalId}
  806. </if>)f1
  807. <if test="flagStr != null and flagStr == 1 ">
  808. join med_lis_info f2
  809. on f2.is_deleted = 'N'
  810. AND f1.hospitalId = f2.hospital_id
  811. AND f1.behospitalCode = f2.behospital_code
  812. </if>
  813. <if test="flagStr != null and flagStr == 2">
  814. join med_doctor_advice f3
  815. on f3.is_deleted = 'N'
  816. AND f1.hospitalId = f3.hospital_id
  817. AND f1.behospitalCode = f3.behospital_code
  818. </if>
  819. <if test="flagStr != null and flagStr == 3">
  820. join med_qcresult_detail f4
  821. on f4.is_deleted = 'N'
  822. AND f1.hospitalId = f4.hospital_id
  823. AND f1.behospitalCode = f4.behospital_code
  824. AND f4.is_reject = 1
  825. </if>
  826. <if test="flagStr != null and flagStr == 4">
  827. join str_informed_consent f5
  828. on f5.is_deleted = 'N'
  829. AND f1.hospitalId = f5.hospital_id
  830. AND f1.behospitalCode = f5.behospital_code
  831. </if>
  832. </select>
  833. <!-- 各科室缺陷占比-全院-首页 -->
  834. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  835. resultType="com.diagbot.dto.NumDTO">
  836. SELECT
  837. a.beh_dept_id as id,
  838. a.beh_dept_name as name,
  839. count(*) AS num
  840. FROM
  841. med_behospital_info a,
  842. med_qcresult_info c,
  843. med_qcresult_detail d
  844. WHERE
  845. a.behospital_code = c.behospital_code
  846. AND a.hospital_id = c.hospital_id
  847. AND a.behospital_code = d.behospital_code
  848. AND a.hospital_id = d.hospital_id
  849. AND a.is_deleted = 'N'
  850. AND c.is_deleted = 'N'
  851. AND d.is_deleted = 'N'
  852. <if test="isPlacefile != null and isPlacefile != ''">
  853. and a.is_placefile = #{isPlacefile}
  854. </if>
  855. <![CDATA[AND a.qc_type_id <>0 ]]>
  856. <if test="hospitalId != null and hospitalId != ''">
  857. AND a.hospital_id = #{hospitalId}
  858. </if>
  859. <if test="isPlacefile != null and isPlacefile == 0">
  860. <if test="startDate != null and startDate != ''">
  861. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  862. </if>
  863. <if test="endDate != null and endDate != ''">
  864. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  865. </if>
  866. </if>
  867. <if test="isPlacefile != null and isPlacefile == 1">
  868. <if test="startDate != null and startDate != ''">
  869. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  870. </if>
  871. <if test="endDate != null and endDate != ''">
  872. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  873. </if>
  874. </if>
  875. GROUP BY
  876. a.beh_dept_id,
  877. a.beh_dept_name
  878. ORDER BY
  879. count(*) DESC
  880. </select>
  881. <!-- 质控结果缺陷总数查询-->
  882. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  883. SELECT
  884. count(*) AS totle
  885. FROM
  886. med_behospital_info a,
  887. med_qcresult_info c,
  888. med_qcresult_detail d
  889. WHERE
  890. a.behospital_code = c.behospital_code
  891. AND a.hospital_id = c.hospital_id
  892. AND a.behospital_code = d.behospital_code
  893. AND a.hospital_id = d.hospital_id
  894. AND a.is_deleted = 'N'
  895. AND c.is_deleted = 'N'
  896. AND d.is_deleted = 'N'
  897. <if test="isPlacefile != null and isPlacefile != ''">
  898. and a.is_placefile = #{isPlacefile}
  899. </if>
  900. <![CDATA[AND a.qc_type_id <>0 ]]>
  901. <if test="hospitalId != null and hospitalId != ''">
  902. AND a.hospital_id = #{hospitalId}
  903. </if>
  904. <if test="isPlacefile != null and isPlacefile == 0">
  905. <if test="startDate != null and startDate != ''">
  906. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  907. </if>
  908. <if test="endDate != null and endDate != ''">
  909. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  910. </if>
  911. </if>
  912. <if test="isPlacefile != null and isPlacefile == 1">
  913. <if test="startDate != null and startDate != ''">
  914. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  915. </if>
  916. <if test="endDate != null and endDate != ''">
  917. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  918. </if>
  919. </if>
  920. </select>
  921. <!--获取病历-->
  922. <select id="getNoGrade" resultMap="BaseResultMap">
  923. select * from med_behospital_info a
  924. where a.is_deleted = 'N'
  925. and a.qc_type_id != 0
  926. <if test="isPlacefile != null and isPlacefile != ''">
  927. and a.is_placefile = #{isPlacefile}
  928. </if>
  929. <if test="filterFlag != null and filterFlag == 0">
  930. and
  931. not EXISTS (
  932. SELECT
  933. 1
  934. FROM
  935. med_qcresult_info b
  936. WHERE
  937. b.is_deleted = 'N'
  938. AND a.hospital_id = b.hospital_id
  939. AND a.behospital_code = b.behospital_code
  940. )
  941. </if>
  942. <if test="leaveDate != null">
  943. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  944. </if>
  945. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  946. and a.hospital_id in
  947. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  948. #{item}
  949. </foreach>
  950. </if>
  951. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  952. and a.behospital_code in
  953. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  954. #{item}
  955. </foreach>
  956. </if>
  957. <if test="individuation != null and individuation.contains(1)">
  958. union
  959. select * from med_behospital_info b
  960. where b.is_deleted = 'N'
  961. and b.qc_type_id != 0
  962. <if test="isPlacefile != null and isPlacefile != ''">
  963. and b.is_placefile = #{isPlacefile}
  964. </if>
  965. <if test="startLeaveDate != null">
  966. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  967. </if>
  968. <if test="endLeaveDate != null">
  969. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  970. </if>
  971. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  972. and b.hospital_id in
  973. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  974. #{item}
  975. </foreach>
  976. </if>
  977. </if>
  978. </select>
  979. <!--质控评分(科室)分页-->
  980. <select id="getPageByDept" resultType="com.diagbot.dto.BehospitalInfoDTO">
  981. SELECT * from (
  982. SELECT
  983. t.*,
  984. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  985. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  986. g.check_type as ch_type,
  987. h.check_type AS mr_type,
  988. g.check_name as ch_name,
  989. h.check_name as mr_name,
  990. g.check_time as ch_time,
  991. h.check_time AS mr_time
  992. FROM
  993. ( SELECT
  994. a.*,
  995. IFNULL(b.level, '未评分') AS `level`,
  996. b.grade_type,
  997. b.score_res,
  998. e.score_res as score_bn,
  999. b.gmt_create AS grade_time,
  1000. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1001. FROM
  1002. med_behospital_info a
  1003. JOIN sys_user_dept d
  1004. ON a.hospital_id = d.hospital_id
  1005. AND a.beh_dept_id = d.dept_id
  1006. LEFT JOIN med_qcresult_info b
  1007. ON a.behospital_code = b.behospital_code
  1008. AND b.is_deleted = 'N'
  1009. LEFT JOIN med_qcresult_cases e
  1010. on a.behospital_code = e.behospital_code
  1011. AND e.is_deleted = 'N'
  1012. and e.cases_id = 243
  1013. LEFT JOIN med_home_page c
  1014. ON a.behospital_code = c.behospital_code
  1015. AND c.is_deleted = 'N'
  1016. WHERE d.is_deleted = 'N'
  1017. AND d.user_id = #{userId}
  1018. ) t
  1019. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1020. ON t.behospital_code = g.behospital_code
  1021. AND t.hospital_id = g.hospital_id
  1022. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1023. ON t.behospital_code = h.behospital_code
  1024. AND t.hospital_id = h.hospital_id
  1025. where t.is_deleted = 'N'
  1026. <if test="diagnose != null and diagnose != ''">
  1027. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1028. </if>
  1029. <if test="deptName != null and deptName != ''">
  1030. and t.beh_dept_name = #{deptName}
  1031. </if>
  1032. <if test="doctorName != null and doctorName != ''">
  1033. and CONCAT(
  1034. IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
  1035. like CONCAT('%',#{doctorName},'%')
  1036. </if>
  1037. <if test="doctorCode != null and doctorCode != ''">
  1038. and (t.doctor_id = #{doctorCode}
  1039. or t.beh_doctor_id = #{doctorCode}
  1040. or t.director_doctor_id = #{doctorCode})
  1041. </if>
  1042. <if test="name != null and name != ''">
  1043. and t.name like CONCAT('%',#{name},'%')
  1044. </if>
  1045. <if test="fileCode != null and fileCode != ''">
  1046. and t.file_code like CONCAT('%',#{fileCode},'%')
  1047. </if>
  1048. <if test="hospitalId != null">
  1049. and t.hospital_id = #{hospitalId}
  1050. </if>
  1051. <if test="behospitalCode != null and behospitalCode != ''">
  1052. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1053. </if>
  1054. <if test="behosDateStart != null">
  1055. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1056. </if>
  1057. <if test="behosDateEnd != null">
  1058. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1059. </if>
  1060. <if test="leaveHosDateStart != null">
  1061. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1062. </if>
  1063. <if test="leaveHosDateEnd != null">
  1064. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1065. </if>
  1066. <if test="level != null and level != ''">
  1067. and t.level = #{level}
  1068. </if>
  1069. <if test="isPlacefile != null and isPlacefile != ''">
  1070. and t.is_placefile = #{isPlacefile}
  1071. </if>
  1072. and t.qc_type_id != 0) p
  1073. where p.is_deleted="N"
  1074. <if test="checkStatus != null ">
  1075. and p.check_status = #{checkStatus}
  1076. </if>
  1077. <if test="mrStatus != null ">
  1078. AND p.mr_status = #{mrStatus}
  1079. </if>
  1080. <if test="chName != null and chName !=''">
  1081. AND p.ch_name like CONCAT('%',#{chName},'%')
  1082. </if>
  1083. <if test="mrName != null and mrName !=''">
  1084. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1085. </if>
  1086. <if test="chTimeStart != null">
  1087. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1088. </if>
  1089. <if test="chTimeEnd != null">
  1090. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1091. </if>
  1092. <if test="mrTimeStart != null">
  1093. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1094. </if>
  1095. <if test="mrTimeEnd != null">
  1096. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1097. </if>
  1098. </select>
  1099. <!--质控评分(个人)分页-->
  1100. <select id="getPageByPerson" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1101. Select * from (
  1102. select t.*,
  1103. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1104. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1105. g.check_type as ch_type,
  1106. h.check_type AS mr_type,
  1107. g.check_name as ch_name,
  1108. h.check_name as mr_name,
  1109. g.check_time as ch_time,
  1110. h.check_time AS mr_time
  1111. from (SELECT
  1112. a.*,
  1113. IFNULL(b.level, '未评分') AS `level`,
  1114. b.grade_type,
  1115. b.score_res,
  1116. e.score_res as score_bn,
  1117. b.gmt_create AS grade_time,
  1118. CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age
  1119. FROM
  1120. med_behospital_info a
  1121. JOIN
  1122. (SELECT
  1123. u.id,
  1124. u.linkman AS linkman,
  1125. uh.hospital_id
  1126. FROM
  1127. sys_user u
  1128. JOIN sys_user_hospital uh
  1129. ON u.id = uh.user_id
  1130. WHERE u.is_deleted = "N"
  1131. AND u.id = #{userId}
  1132. AND uh.hospital_id = #{hospitalId}) u1
  1133. ON a.hospital_id = u1.hospital_id
  1134. LEFT JOIN med_qcresult_info b
  1135. ON a.behospital_code = b.behospital_code
  1136. AND b.is_deleted = 'N'
  1137. LEFT JOIN med_qcresult_cases e
  1138. on a.behospital_code = e.behospital_code
  1139. AND e.is_deleted = 'N'
  1140. and e.cases_id = 243
  1141. LEFT JOIN med_home_page c
  1142. ON a.behospital_code = c.behospital_code
  1143. AND c.is_deleted = 'N'
  1144. WHERE
  1145. a.is_deleted = 'N'
  1146. and a.doctor_name = u1.linkman
  1147. or a.beh_doctor_name = u1.linkman
  1148. or a.director_doctor_name = u1.linkman
  1149. ) t
  1150. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1151. ON t.behospital_code = g.behospital_code
  1152. AND t.hospital_id = g.hospital_id
  1153. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1154. ON t.behospital_code = h.behospital_code
  1155. AND t.hospital_id = h.hospital_id
  1156. WHERE t.is_deleted = 'N'
  1157. <if test="diagnose != null and diagnose != ''">
  1158. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1159. </if>
  1160. <if test="deptName != null and deptName != ''">
  1161. and t.beh_dept_name = #{deptName}
  1162. </if>
  1163. <if test="name != null and name != ''">
  1164. and t.name like CONCAT('%',#{name},'%')
  1165. </if>
  1166. <if test="fileCode != null and fileCode != ''">
  1167. and t.file_code like CONCAT('%',#{fileCode},'%')
  1168. </if>
  1169. <if test="behospitalCode != null and behospitalCode != ''">
  1170. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1171. </if>
  1172. <if test="behosDateStart != null">
  1173. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1174. </if>
  1175. <if test="behosDateEnd != null">
  1176. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1177. </if>
  1178. <if test="leaveHosDateStart != null">
  1179. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1180. </if>
  1181. <if test="leaveHosDateEnd != null">
  1182. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1183. </if>
  1184. <if test="level != null and level != ''">
  1185. and t.level = #{level}
  1186. </if>
  1187. <if test="isPlacefile != null and isPlacefile != ''">
  1188. and t.is_placefile = #{isPlacefile}
  1189. </if>
  1190. and t.qc_type_id != 0) p
  1191. where p.is_deleted="N"
  1192. <if test="checkStatus != null ">
  1193. and p.check_status = #{checkStatus}
  1194. </if>
  1195. <if test="mrStatus != null ">
  1196. AND p.mr_status = #{mrStatus}
  1197. </if>
  1198. <if test="chName != null and chName !=''">
  1199. AND p.ch_name like CONCAT('%',#{chName},'%')
  1200. </if>
  1201. <if test="mrName != null and mrName !=''">
  1202. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1203. </if>
  1204. <if test="chTimeStart != null">
  1205. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1206. </if>
  1207. <if test="chTimeEnd != null">
  1208. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1209. </if>
  1210. <if test="mrTimeStart != null">
  1211. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1212. </if>
  1213. <if test="mrTimeEnd != null">
  1214. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1215. </if>
  1216. </select>
  1217. <!--质控评分(医疗组)分页-->
  1218. <select id="getPageByGroup" resultType="com.diagbot.dto.BehospitalInfoDTO">
  1219. select * from (
  1220. select t.*,
  1221. CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  1222. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  1223. g.check_type as ch_type,
  1224. h.check_type AS mr_type,
  1225. g.check_name as ch_name,
  1226. h.check_name as mr_name,
  1227. g.check_time as ch_time,
  1228. h.check_time AS mr_time
  1229. from (
  1230. select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
  1231. grade_time,CONCAT( ifnull(c.age,'') ,ifnull(c.age_unit,'') )as age, e.score_res as score_bn from med_behospital_info a
  1232. LEFT JOIN med_qcresult_info b
  1233. on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
  1234. LEFT JOIN med_qcresult_cases e
  1235. on a.behospital_code = e.behospital_code
  1236. AND e.is_deleted = 'N'
  1237. and e.cases_id = 243
  1238. left join med_home_page c
  1239. on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
  1240. ) t
  1241. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  1242. ON t.behospital_code = g.behospital_code
  1243. AND t.hospital_id = g.hospital_id
  1244. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  1245. ON t.behospital_code = h.behospital_code
  1246. AND t.hospital_id = h.hospital_id
  1247. WHERE t.is_deleted = 'N'
  1248. and
  1249. t.doctor_id in (
  1250. SELECT doctor_id FROM `bas_doctor_info`
  1251. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  1252. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  1253. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  1254. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  1255. and c1.username = c3.doctor_id
  1256. and c2.hospital_id = #{hospitalId}
  1257. and c1.id = #{userId}
  1258. )
  1259. )
  1260. <if test="diagnose != null and diagnose != ''">
  1261. AND t.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  1262. </if>
  1263. <if test="doctorName != null and doctorName != ''">
  1264. and (t.doctor_name like CONCAT('%',#{doctorName},'%')
  1265. or t.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  1266. or t.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  1267. </if>
  1268. <if test="name != null and name != ''">
  1269. and t.name like CONCAT('%',#{name},'%')
  1270. </if>
  1271. <if test="doctorCode != null and doctorCode != ''">
  1272. and (t.doctor_id = #{doctorCode}
  1273. or t.beh_doctor_id = #{doctorCode}
  1274. or t.director_doctor_id = #{doctorCode})
  1275. </if>
  1276. <if test="fileCode != null and fileCode != ''">
  1277. and t.file_code like CONCAT('%',#{fileCode},'%')
  1278. </if>
  1279. <if test="hospitalId != null">
  1280. and t.hospital_id = #{hospitalId}
  1281. </if>
  1282. <if test="behospitalCode != null and behospitalCode != ''">
  1283. and t.behospital_code like CONCAT('%',#{behospitalCode},'%')
  1284. </if>
  1285. <if test="behosDateStart != null">
  1286. <![CDATA[ and t.behospital_date >= #{behosDateStart}]]>
  1287. </if>
  1288. <if test="behosDateEnd != null">
  1289. <![CDATA[ and t.behospital_date < #{behosDateEnd}]]>
  1290. </if>
  1291. <if test="leaveHosDateStart != null">
  1292. <![CDATA[ and t.leave_hospital_date >= #{leaveHosDateStart}]]>
  1293. </if>
  1294. <if test="leaveHosDateEnd != null">
  1295. <![CDATA[ and t.leave_hospital_date < #{leaveHosDateEnd}]]>
  1296. </if>
  1297. <if test="level != null and level != ''">
  1298. and t.level = #{level}
  1299. </if>
  1300. <if test="isPlacefile != null and isPlacefile != ''">
  1301. and t.is_placefile = #{isPlacefile}
  1302. </if>
  1303. and t.qc_type_id != 0) p
  1304. where p.is_deleted="N"
  1305. <if test="checkStatus != null ">
  1306. and p.check_status = #{checkStatus}
  1307. </if>
  1308. <if test="mrStatus != null ">
  1309. AND p.mr_status = #{mrStatus}
  1310. </if>
  1311. <if test="chName != null and chName !=''">
  1312. AND p.ch_name like CONCAT('%',#{chName},'%')
  1313. </if>
  1314. <if test="mrName != null and mrName !=''">
  1315. AND p.mr_name like CONCAT('%',#{mrName},'%')
  1316. </if>
  1317. <if test="chTimeStart != null">
  1318. <![CDATA[ and p.ch_time >= #{chTimeStart}]]>
  1319. </if>
  1320. <if test="chTimeEnd != null">
  1321. <![CDATA[ and p.ch_time < #{chTimeEnd}]]>
  1322. </if>
  1323. <if test="mrTimeStart != null">
  1324. <![CDATA[ and p.mr_time >= #{mrTimeStart}]]>
  1325. </if>
  1326. <if test="mrTimeEnd != null">
  1327. <![CDATA[ and p.mr_time < #{mrTimeEnd}]]>
  1328. </if>
  1329. </select>
  1330. <!-- 出院总人数统计-全院-首页 -->
  1331. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1332. SELECT
  1333. COUNT(*)
  1334. FROM
  1335. med_behospital_info a
  1336. WHERE
  1337. a.is_deleted = 'N'
  1338. <if test="isPlacefile != null and isPlacefile != ''">
  1339. and a.is_placefile = #{isPlacefile}
  1340. </if>
  1341. <if test="hospitalId != null and hospitalId != ''">
  1342. AND a.hospital_id = #{hospitalId}
  1343. </if>
  1344. <if test="isPlacefile != null and isPlacefile == 0">
  1345. <if test="startDate != null and startDate != ''">
  1346. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1347. </if>
  1348. <if test="endDate != null and endDate != ''">
  1349. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1350. </if>
  1351. </if>
  1352. <if test="isPlacefile != null and isPlacefile == 1">
  1353. <if test="startDate != null and startDate != ''">
  1354. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1355. </if>
  1356. <if test="endDate != null and endDate != ''">
  1357. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1358. </if>
  1359. </if>
  1360. </select>
  1361. <!-- 新生儿出院人数统计-全院-首页 -->
  1362. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1363. SELECT
  1364. COUNT(*)
  1365. FROM
  1366. med_behospital_info a,
  1367. med_home_page b
  1368. WHERE
  1369. a.is_deleted = 'N'
  1370. AND b.is_deleted = 'N'
  1371. AND a.hospital_id = b.hospital_id
  1372. AND a.behospital_code = b.behospital_code
  1373. <if test="isPlacefile != null and isPlacefile != ''">
  1374. and a.is_placefile = #{isPlacefile}
  1375. </if>
  1376. AND (
  1377. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' AND b.newborn_day != '—')
  1378. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1379. )
  1380. <![CDATA[AND a.qc_type_id <>0 ]]>
  1381. <if test="hospitalId != null and hospitalId != ''">
  1382. AND a.hospital_id = #{hospitalId}
  1383. </if>
  1384. <if test="isPlacefile != null and isPlacefile == 0">
  1385. <if test="startDate != null and startDate != ''">
  1386. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1387. </if>
  1388. <if test="endDate != null and endDate != ''">
  1389. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1390. </if>
  1391. </if>
  1392. <if test="isPlacefile != null and isPlacefile == 1">
  1393. <if test="startDate != null and startDate != ''">
  1394. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1395. </if>
  1396. <if test="endDate != null and endDate != ''">
  1397. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1398. </if>
  1399. </if>
  1400. </select>
  1401. <!-- 死亡人数统计-全院-首页 -->
  1402. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1403. select COUNT(*) from(
  1404. SELECT distinct a.*
  1405. FROM
  1406. med_behospital_info a,
  1407. med_medical_record b,
  1408. med_medical_record_content c
  1409. WHERE
  1410. a.is_deleted = 'N'
  1411. AND b.is_deleted = 'N'
  1412. AND c.is_deleted = 'N'
  1413. AND a.hospital_id = b.hospital_id
  1414. AND a.hospital_id = c.hospital_id
  1415. AND a.behospital_code = b.behospital_code
  1416. AND b.rec_id = c.rec_id
  1417. and b.mode_id = '24'
  1418. <if test="isPlacefile != null and isPlacefile != ''">
  1419. and a.is_placefile = #{isPlacefile}
  1420. </if>
  1421. <![CDATA[AND a.qc_type_id <>0 ]]>
  1422. <if test="hospitalId != null and hospitalId != ''">
  1423. AND a.hospital_id = #{hospitalId}
  1424. </if>
  1425. <if test="isPlacefile != null and isPlacefile == 0">
  1426. <if test="startDate != null and startDate != ''">
  1427. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1428. </if>
  1429. <if test="endDate != null and endDate != ''">
  1430. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1431. </if>
  1432. </if>
  1433. <if test="isPlacefile != null and isPlacefile == 1">
  1434. <if test="startDate != null and startDate != ''">
  1435. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1436. </if>
  1437. <if test="endDate != null and endDate != ''">
  1438. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1439. </if>
  1440. </if>)m
  1441. </select>
  1442. <!-- 手术人数统计-全院-首页 -->
  1443. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  1444. SELECT
  1445. COUNT( DISTINCT a.behospital_code )
  1446. FROM
  1447. med_behospital_info a,
  1448. med_medical_record c,
  1449. qc_mode d
  1450. WHERE
  1451. a.is_deleted = 'N'
  1452. AND c.is_deleted = 'N'
  1453. AND d.is_deleted = 'N'
  1454. AND a.hospital_id = c.hospital_id
  1455. AND a.behospital_code = c.behospital_code
  1456. AND c.mode_id = d.id
  1457. <if test="isPlacefile != null and isPlacefile != ''">
  1458. and a.is_placefile = #{isPlacefile}
  1459. </if>
  1460. AND d.`name` = '手术记录'
  1461. <![CDATA[AND a.qc_type_id <>0 ]]>
  1462. <if test="hospitalId != null and hospitalId != ''">
  1463. AND a.hospital_id = #{hospitalId}
  1464. </if>
  1465. <if test="isPlacefile != null and isPlacefile == 0">
  1466. <if test="startDate != null and startDate != ''">
  1467. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1468. </if>
  1469. <if test="endDate != null and endDate != ''">
  1470. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1471. </if>
  1472. </if>
  1473. <if test="isPlacefile != null and isPlacefile == 1">
  1474. <if test="startDate != null and startDate != ''">
  1475. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1476. </if>
  1477. <if test="endDate != null and endDate != ''">
  1478. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1479. </if>
  1480. </if>
  1481. </select>
  1482. <!-- 入院人数统计-首页 -->
  1483. <select id="beHosCount" parameterType="com.diagbot.vo.FilterVO"
  1484. resultType="com.diagbot.dto.NumDTO">
  1485. SELECT
  1486. a.beh_dept_id AS id,
  1487. a.beh_dept_name AS NAME,
  1488. COUNT(*) AS num
  1489. FROM
  1490. med_behospital_info a
  1491. WHERE
  1492. a.is_deleted = 'N'
  1493. <if test="isPlacefile != null and isPlacefile != ''">
  1494. and a.is_placefile = #{isPlacefile}
  1495. </if>
  1496. <if test="hospitalId != null and hospitalId != ''">
  1497. AND a.hospital_id = #{hospitalId}
  1498. </if>
  1499. <if test="isPlacefile != null and isPlacefile == 0">
  1500. <if test="startDate != null and startDate != ''">
  1501. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1502. </if>
  1503. <if test="endDate != null and endDate != ''">
  1504. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1505. </if>
  1506. </if>
  1507. <if test="isPlacefile != null and isPlacefile == 1">
  1508. <if test="startDate != null and startDate != ''">
  1509. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1510. </if>
  1511. <if test="endDate != null and endDate != ''">
  1512. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1513. </if>
  1514. </if>
  1515. GROUP BY
  1516. a.beh_dept_id,
  1517. a.beh_dept_name
  1518. </select>
  1519. <!-- 出院总人数统计-科室-首页 -->
  1520. <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1521. resultType="com.diagbot.dto.NumDTO">
  1522. SELECT
  1523. a.beh_dept_id AS id,
  1524. a.beh_dept_name AS NAME,
  1525. COUNT(*) AS num
  1526. FROM
  1527. med_behospital_info a,
  1528. sys_user_dept c
  1529. WHERE
  1530. a.is_deleted = 'N'
  1531. AND c.is_deleted = 'N'
  1532. AND a.hospital_id = c.hospital_id
  1533. AND a.beh_dept_id = c.dept_id
  1534. <if test="isPlacefile != null and isPlacefile != ''">
  1535. and a.is_placefile = #{isPlacefile}
  1536. </if>
  1537. <if test="userId!=null">
  1538. AND c.user_id = #{userId}
  1539. </if>
  1540. <if test="hospitalId != null and hospitalId != ''">
  1541. AND a.hospital_id = #{hospitalId}
  1542. </if>
  1543. <if test="isPlacefile != null and isPlacefile == 0">
  1544. <if test="startDate != null and startDate != ''">
  1545. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1546. </if>
  1547. <if test="endDate != null and endDate != ''">
  1548. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1549. </if>
  1550. </if>
  1551. <if test="isPlacefile != null and isPlacefile == 1">
  1552. <if test="startDate != null and startDate != ''">
  1553. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1554. </if>
  1555. <if test="endDate != null and endDate != ''">
  1556. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1557. </if>
  1558. </if>
  1559. GROUP BY
  1560. a.beh_dept_id,
  1561. a.beh_dept_name
  1562. </select>
  1563. <!-- 入院总人数统计-科室-首页 -->
  1564. <select id="admissionHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1565. resultType="com.diagbot.dto.AdmissionCountDTO">
  1566. SELECT
  1567. a.beh_dept_id as deptId,
  1568. a.beh_dept_name as deptName,
  1569. a.doctor_id as doctorId,
  1570. a.doctor_name as doctorName,
  1571. COUNT(*) AS num
  1572. FROM
  1573. med_behospital_info a,
  1574. sys_user_dept c
  1575. WHERE
  1576. a.is_deleted = 'N'
  1577. AND c.is_deleted = 'N'
  1578. AND a.hospital_id = c.hospital_id
  1579. AND a.beh_dept_id = c.dept_id
  1580. <if test="isPlacefile != null and isPlacefile != ''">
  1581. and a.is_placefile = #{isPlacefile}
  1582. </if>
  1583. <if test="userId!=null">
  1584. AND c.user_id = #{userId}
  1585. </if>
  1586. <if test="hospitalId != null and hospitalId != ''">
  1587. AND a.hospital_id = #{hospitalId}
  1588. </if>
  1589. <if test="isPlacefile != null and isPlacefile == 0">
  1590. <if test="startDate != null and startDate != ''">
  1591. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1592. </if>
  1593. <if test="endDate != null and endDate != ''">
  1594. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1595. </if>
  1596. </if>
  1597. <if test="isPlacefile != null and isPlacefile == 1">
  1598. <if test="startDate != null and startDate != ''">
  1599. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1600. </if>
  1601. <if test="endDate != null and endDate != ''">
  1602. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1603. </if>
  1604. </if>
  1605. GROUP BY
  1606. a.beh_dept_id,
  1607. a.beh_dept_name,
  1608. a.doctor_id,
  1609. a.doctor_name
  1610. </select>
  1611. <!-- 新生儿出院人数统计-科室-首页 -->
  1612. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1613. resultType="com.diagbot.dto.NumDTO">
  1614. SELECT
  1615. a.beh_dept_id AS id,
  1616. a.beh_dept_name AS NAME,
  1617. COUNT(*) AS num
  1618. FROM
  1619. med_behospital_info a,
  1620. med_home_page b,
  1621. sys_user_dept c
  1622. WHERE
  1623. a.is_deleted = 'N'
  1624. AND b.is_deleted = 'N'
  1625. AND c.is_deleted = 'N'
  1626. AND a.hospital_id = b.hospital_id
  1627. AND a.hospital_id = c.hospital_id
  1628. AND a.behospital_code = b.behospital_code
  1629. AND a.beh_dept_id = c.dept_id
  1630. AND (
  1631. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-'AND b.newborn_day != '—' )
  1632. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  1633. )
  1634. <if test="isPlacefile != null and isPlacefile != ''">
  1635. and a.is_placefile = #{isPlacefile}
  1636. </if>
  1637. <![CDATA[AND a.qc_type_id <>0 ]]>
  1638. <if test="userId!=null">
  1639. AND c.user_id = #{userId}
  1640. </if>
  1641. <if test="hospitalId != null and hospitalId != ''">
  1642. AND a.hospital_id = #{hospitalId}
  1643. </if>
  1644. <if test="isPlacefile != null and isPlacefile == 0">
  1645. <if test="startDate != null and startDate != ''">
  1646. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1647. </if>
  1648. <if test="endDate != null and endDate != ''">
  1649. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1650. </if>
  1651. </if>
  1652. <if test="isPlacefile != null and isPlacefile == 1">
  1653. <if test="startDate != null and startDate != ''">
  1654. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1655. </if>
  1656. <if test="endDate != null and endDate != ''">
  1657. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1658. </if>
  1659. </if>
  1660. GROUP BY
  1661. a.beh_dept_id,
  1662. a.beh_dept_name
  1663. </select>
  1664. <!-- 死亡人数统计-科室-首页 -->
  1665. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1666. resultType="com.diagbot.dto.NumDTO">
  1667. SELECT
  1668. a.beh_dept_id AS id,
  1669. a.beh_dept_name AS NAME,
  1670. COUNT(*) AS num
  1671. FROM
  1672. med_behospital_info a,
  1673. sys_user_dept c,
  1674. med_medical_record d,
  1675. med_medical_record_content e
  1676. WHERE
  1677. a.is_deleted = 'N'
  1678. AND c.is_deleted = 'N'
  1679. AND d.is_deleted = 'N'
  1680. AND e.is_deleted = 'N'
  1681. AND a.hospital_id = c.hospital_id
  1682. AND a.hospital_id = d.hospital_id
  1683. AND a.hospital_id = e.hospital_id
  1684. AND a.behospital_code = d.behospital_code
  1685. AND a.beh_dept_id = c.dept_id
  1686. AND d.rec_id = e.rec_id
  1687. AND d.mode_id = '24'
  1688. <if test="isPlacefile != null and isPlacefile != ''">
  1689. and a.is_placefile = #{isPlacefile}
  1690. </if>
  1691. <![CDATA[AND a.qc_type_id <>0 ]]>
  1692. <if test="userId!=null">
  1693. AND c.user_id = #{userId}
  1694. </if>
  1695. <if test="hospitalId != null and hospitalId != ''">
  1696. AND a.hospital_id = #{hospitalId}
  1697. </if>
  1698. <if test="isPlacefile != null and isPlacefile == 0">
  1699. <if test="startDate != null and startDate != ''">
  1700. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1701. </if>
  1702. <if test="endDate != null and endDate != ''">
  1703. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1704. </if>
  1705. </if>
  1706. <if test="isPlacefile != null and isPlacefile == 1">
  1707. <if test="startDate != null and startDate != ''">
  1708. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1709. </if>
  1710. <if test="endDate != null and endDate != ''">
  1711. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1712. </if>
  1713. </if>
  1714. GROUP BY
  1715. a.beh_dept_id,
  1716. a.beh_dept_name
  1717. </select>
  1718. <!-- 手术人数统计-科室-首页 -->
  1719. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  1720. resultType="com.diagbot.dto.NumDTO">
  1721. SELECT
  1722. a.beh_dept_id AS id,
  1723. a.beh_dept_name AS NAME,
  1724. COUNT( DISTINCT a.behospital_code ) AS num
  1725. FROM
  1726. med_behospital_info a,
  1727. sys_user_dept c,
  1728. med_medical_record d,
  1729. qc_mode e
  1730. WHERE
  1731. a.is_deleted = 'N'
  1732. AND c.is_deleted = 'N'
  1733. AND d.is_deleted = 'N'
  1734. AND e.is_deleted = 'N'
  1735. AND a.hospital_id = c.hospital_id
  1736. AND a.hospital_id = d.hospital_id
  1737. AND a.behospital_code = d.behospital_code
  1738. AND a.beh_dept_id = c.dept_id
  1739. AND d.mode_id = e.id
  1740. AND e.`name` = '手术记录'
  1741. <if test="isPlacefile != null and isPlacefile != ''">
  1742. and a.is_placefile = #{isPlacefile}
  1743. </if>
  1744. <![CDATA[AND a.qc_type_id <>0 ]]>
  1745. <if test="userId!=null">
  1746. AND c.user_id = #{userId}
  1747. </if>
  1748. <if test="hospitalId != null and hospitalId != ''">
  1749. AND a.hospital_id = #{hospitalId}
  1750. </if>
  1751. <if test="isPlacefile != null and isPlacefile == 0">
  1752. <if test="startDate != null and startDate != ''">
  1753. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1754. </if>
  1755. <if test="endDate != null and endDate != ''">
  1756. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1757. </if>
  1758. </if>
  1759. <if test="isPlacefile != null and isPlacefile == 1">
  1760. <if test="startDate != null and startDate != ''">
  1761. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1762. </if>
  1763. <if test="endDate != null and endDate != ''">
  1764. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1765. </if>
  1766. </if>
  1767. GROUP BY
  1768. a.beh_dept_id,
  1769. a.beh_dept_name
  1770. </select>
  1771. <!-- 各科室缺陷占比排行(分页) -->
  1772. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  1773. SELECT t.*
  1774. FROM
  1775. (SELECT
  1776. t1.beh_dept_name AS NAME,
  1777. t1.num AS num,
  1778. t2.totle AS totleNum,
  1779. round( t1.num / t2.totle, 4 ) AS percent,
  1780. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1781. FROM
  1782. (
  1783. SELECT
  1784. a.beh_dept_id,
  1785. a.beh_dept_name,
  1786. count(*) AS num
  1787. FROM
  1788. med_behospital_info a,
  1789. med_qcresult_info c,
  1790. med_qcresult_detail d
  1791. WHERE
  1792. a.behospital_code = c.behospital_code
  1793. AND a.hospital_id = c.hospital_id
  1794. AND a.behospital_code = d.behospital_code
  1795. AND a.hospital_id = d.hospital_id
  1796. AND a.is_deleted = 'N'
  1797. AND c.is_deleted = 'N'
  1798. AND d.is_deleted = 'N'
  1799. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1800. and a.is_placefile = #{filterPageVO.isPlacefile}
  1801. </if>
  1802. <![CDATA[AND a.qc_type_id <>0 ]]>
  1803. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1804. AND a.hospital_id = #{filterPageVO.hospitalId}
  1805. </if>
  1806. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1807. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1808. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1809. </if>
  1810. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1811. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1812. </if>
  1813. </if>
  1814. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1815. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1816. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1817. </if>
  1818. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1819. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1820. </if>
  1821. </if>
  1822. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1823. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1824. </if>
  1825. GROUP BY
  1826. a.beh_dept_id,
  1827. a.beh_dept_name
  1828. ORDER BY
  1829. count(*) DESC
  1830. ) t1,
  1831. (
  1832. SELECT
  1833. count(*) AS totle
  1834. FROM
  1835. med_behospital_info a,
  1836. med_qcresult_info c,
  1837. med_qcresult_detail d
  1838. WHERE
  1839. a.behospital_code = c.behospital_code
  1840. AND a.hospital_id = c.hospital_id
  1841. AND a.behospital_code = d.behospital_code
  1842. AND a.hospital_id = d.hospital_id
  1843. AND a.is_deleted = 'N'
  1844. AND c.is_deleted = 'N'
  1845. AND d.is_deleted = 'N'
  1846. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1847. and a.is_placefile = #{filterPageVO.isPlacefile}
  1848. </if>
  1849. <![CDATA[AND a.qc_type_id <>0 ]]>
  1850. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1851. AND a.hospital_id = #{filterPageVO.hospitalId}
  1852. </if>
  1853. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1854. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1855. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1856. </if>
  1857. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1858. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1859. </if>
  1860. </if>
  1861. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1862. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1863. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1864. </if>
  1865. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1866. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1867. </if>
  1868. </if>
  1869. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1870. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1871. </if>
  1872. ) t2
  1873. )t
  1874. </select>
  1875. <!-- 科室缺陷占比(主任医生) -->
  1876. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  1877. SELECT
  1878. t.*
  1879. FROM
  1880. (
  1881. SELECT
  1882. t1.NAME,
  1883. t1.num AS num,
  1884. t2.totle AS totleNum,
  1885. round( t1.num / t2.totle, 4 ) AS percent,
  1886. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1887. FROM
  1888. (
  1889. SELECT
  1890. d.msg as name,
  1891. count(*) AS num
  1892. FROM
  1893. med_behospital_info a,
  1894. med_qcresult_info c,
  1895. med_qcresult_detail d,
  1896. sys_user_dept e
  1897. WHERE
  1898. a.behospital_code = c.behospital_code
  1899. AND a.hospital_id = c.hospital_id
  1900. AND a.behospital_code = d.behospital_code
  1901. AND a.hospital_id = d.hospital_id
  1902. AND a.is_deleted = 'N'
  1903. AND c.is_deleted = 'N'
  1904. AND d.is_deleted = 'N'
  1905. AND e.is_deleted = 'N'
  1906. AND a.beh_dept_id = e.dept_id
  1907. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1908. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1909. </if>
  1910. <![CDATA[AND a.qc_type_id <>0 ]]>
  1911. <if test="filterPageByDeptVO.userId!=null">
  1912. AND e.user_id = #{filterPageByDeptVO.userId}
  1913. </if>
  1914. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1915. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1916. </if>
  1917. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1918. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1919. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1920. </if>
  1921. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1922. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1923. </if>
  1924. </if>
  1925. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1926. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1927. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1928. </if>
  1929. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1930. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1931. </if>
  1932. </if>
  1933. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1934. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1935. </if>
  1936. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1937. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1938. </if>
  1939. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1940. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1941. </if>
  1942. GROUP BY
  1943. d.msg
  1944. ORDER BY
  1945. count(*) DESC
  1946. ) t1,
  1947. (
  1948. SELECT
  1949. count(*) AS totle
  1950. FROM
  1951. med_behospital_info a,
  1952. med_qcresult_info c,
  1953. med_qcresult_detail d,
  1954. sys_user_dept e
  1955. WHERE
  1956. a.behospital_code = c.behospital_code
  1957. AND a.hospital_id = c.hospital_id
  1958. AND a.behospital_code = d.behospital_code
  1959. AND a.hospital_id = d.hospital_id
  1960. AND a.is_deleted = 'N'
  1961. AND c.is_deleted = 'N'
  1962. AND d.is_deleted = 'N'
  1963. AND e.is_deleted = 'N'
  1964. AND a.beh_dept_id = e.dept_id
  1965. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1966. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1967. </if>
  1968. <![CDATA[AND a.qc_type_id <>0 ]]>
  1969. <if test="filterPageByDeptVO.userId!=null">
  1970. AND e.user_id = #{filterPageByDeptVO.userId}
  1971. </if>
  1972. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1973. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1974. </if>
  1975. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1976. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1977. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1978. </if>
  1979. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1980. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1981. </if>
  1982. </if>
  1983. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1984. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1985. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1986. </if>
  1987. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1988. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1989. </if>
  1990. </if>
  1991. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1992. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1993. </if>
  1994. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1995. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1996. </if>
  1997. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1998. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1999. </if>
  2000. ) t2
  2001. )t
  2002. </select>
  2003. <!-- 各科室缺陷占比(组合)-全院 -->
  2004. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  2005. resultType="com.diagbot.dto.LevelStatisticsDTO">
  2006. SELECT
  2007. m1.deptId,
  2008. m1.deptName,
  2009. m1.entryNum,
  2010. m2.sameNum,
  2011. m1.mrNum,
  2012. m2.sameMrNum,
  2013. m1.totleValue,
  2014. m2.sameTotleValue,
  2015. m1.averageValue,
  2016. m2.sameAvgValue,
  2017. m1.firstLevelNum,
  2018. m2.sameFirstLevelNum,
  2019. m1.secondLevelNum,
  2020. m2.sameSecondLevelNum,
  2021. m1.thirdLevelNum,
  2022. m2.sameThirdLevelNum,
  2023. m1.firstLevelPercent,
  2024. m2.sameFirstLevelPercent,
  2025. m1.secondLevelPercent,
  2026. m2.sameSecondLevelPercent,
  2027. m1.thirdLevelPercent,
  2028. m2.sameThirdLevelPercent,
  2029. m1.firstLevelPercentStr,
  2030. m2.sameFirstLevelPercentStr,
  2031. m1.secondLevelPercentStr,
  2032. m2.sameSecondLevelPercentStr,
  2033. m1.thirdLevelPercentStr,
  2034. m2.sameThirdLevelPercentStr
  2035. FROM
  2036. (
  2037. SELECT
  2038. t1.deptId,
  2039. t1.deptName,
  2040. t2.entryNum,
  2041. t1.mrNum,
  2042. t1.totleValue,
  2043. t1.averageValue,
  2044. t1.firstLevelNum,
  2045. t1.secondLevelNum,
  2046. t1.thirdLevelNum,
  2047. t1.firstLevelPercent,
  2048. t1.secondLevelPercent,
  2049. t1.thirdLevelPercent,
  2050. t1.firstLevelPercentStr,
  2051. t1.secondLevelPercentStr,
  2052. t1.thirdLevelPercentStr
  2053. FROM
  2054. (
  2055. SELECT
  2056. a.beh_dept_id AS deptId,
  2057. a.beh_dept_name AS deptName,
  2058. count(*) AS mrNum,
  2059. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2060. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2061. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2062. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2063. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2064. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2065. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2066. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2067. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2068. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2069. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2070. FROM
  2071. med_behospital_info a,
  2072. med_qcresult_info c
  2073. WHERE
  2074. a.is_deleted = 'N'
  2075. AND c.is_deleted = 'N'
  2076. AND a.hospital_id = c.hospital_id
  2077. AND a.behospital_code = c.behospital_code
  2078. <if test="isPlacefile != null and isPlacefile != ''">
  2079. and a.is_placefile = #{isPlacefile}
  2080. </if>
  2081. AND a.qc_type_id != 0
  2082. <if test="hospitalId != null and hospitalId != ''">
  2083. AND a.hospital_id = #{hospitalId}
  2084. </if>
  2085. <if test="isPlacefile != null and isPlacefile == 0">
  2086. <if test="startDate != null and startDate != ''">
  2087. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2088. </if>
  2089. <if test="endDate != null and endDate != ''">
  2090. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2091. </if>
  2092. </if>
  2093. <if test="isPlacefile != null and isPlacefile == 1">
  2094. <if test="startDate != null and startDate != ''">
  2095. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2096. </if>
  2097. <if test="endDate != null and endDate != ''">
  2098. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2099. </if>
  2100. </if>
  2101. <if test="level != null and level != ''">
  2102. and c.level = #{level}
  2103. </if>
  2104. <if test="deptName != null and deptName != ''">
  2105. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2106. </if>
  2107. GROUP BY
  2108. a.beh_dept_id,
  2109. a.beh_dept_name
  2110. ) t1,
  2111. (
  2112. SELECT
  2113. a.beh_dept_id AS deptId,
  2114. a.beh_dept_name AS deptName,
  2115. count( * ) AS entryNum
  2116. FROM
  2117. med_behospital_info a,
  2118. med_qcresult_info c,
  2119. med_qcresult_detail d,
  2120. qc_cases_entry e
  2121. WHERE
  2122. a.is_deleted = 'N'
  2123. AND c.is_deleted = 'N'
  2124. AND d.is_deleted = 'N'
  2125. AND e.is_deleted = 'N'
  2126. AND a.hospital_id = c.hospital_id
  2127. AND a.hospital_id = d.hospital_id
  2128. AND a.behospital_code = c.behospital_code
  2129. AND a.behospital_code = d.behospital_code
  2130. AND d.cases_id = e.cases_id
  2131. AND d.cases_entry_id = e.id
  2132. <if test="isPlacefile != null and isPlacefile != ''">
  2133. and a.is_placefile = #{isPlacefile}
  2134. </if>
  2135. AND a.qc_type_id != 0
  2136. <if test="hospitalId != null and hospitalId != ''">
  2137. AND a.hospital_id = #{hospitalId}
  2138. </if>
  2139. <if test="isPlacefile != null and isPlacefile == 0">
  2140. <if test="startDate != null and startDate != ''">
  2141. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2142. </if>
  2143. <if test="endDate != null and endDate != ''">
  2144. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2145. </if>
  2146. </if>
  2147. <if test="isPlacefile != null and isPlacefile == 1">
  2148. <if test="startDate != null and startDate != ''">
  2149. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2150. </if>
  2151. <if test="endDate != null and endDate != ''">
  2152. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2153. </if>
  2154. </if>
  2155. <if test="level != null and level != ''">
  2156. and c.level = #{level}
  2157. </if>
  2158. <if test="deptName != null and deptName != ''">
  2159. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2160. </if>
  2161. GROUP BY
  2162. a.beh_dept_id,
  2163. a.beh_dept_name
  2164. ) t2
  2165. WHERE
  2166. t1.deptId = t2.deptId
  2167. AND t1.deptName = t2.deptName)m1 left join
  2168. ( SELECT
  2169. t1.deptId,
  2170. t1.deptName,
  2171. t2.entryNum as sameNum,
  2172. t1.mrNum as sameMrNum,
  2173. t1.totleValue as sameTotleValue,
  2174. t1.averageValue as sameAvgValue,
  2175. t1.firstLevelNum as sameFirstLevelNum,
  2176. t1.secondLevelNum as sameSecondLevelNum,
  2177. t1.thirdLevelNum as sameThirdLevelNum,
  2178. t1.firstLevelPercent as sameFirstLevelPercent,
  2179. t1.secondLevelPercent as sameSecondLevelPercent,
  2180. t1.thirdLevelPercent as sameThirdLevelPercent,
  2181. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2182. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2183. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2184. FROM
  2185. (
  2186. SELECT
  2187. a.beh_dept_id AS deptId,
  2188. a.beh_dept_name AS deptName,
  2189. count(*) AS mrNum,
  2190. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2191. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2192. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2193. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2194. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2195. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2196. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2197. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2198. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2199. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2200. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2201. FROM
  2202. med_behospital_info a,
  2203. med_qcresult_info c
  2204. WHERE
  2205. a.is_deleted = 'N'
  2206. AND c.is_deleted = 'N'
  2207. AND a.hospital_id = c.hospital_id
  2208. AND a.behospital_code = c.behospital_code
  2209. <if test="isPlacefile != null and isPlacefile != ''">
  2210. and a.is_placefile = #{isPlacefile}
  2211. </if>
  2212. AND a.qc_type_id != 0
  2213. <if test="hospitalId != null and hospitalId != ''">
  2214. AND a.hospital_id = #{hospitalId}
  2215. </if>
  2216. <if test="isPlacefile != null and isPlacefile == 0">
  2217. <if test="lastStartDate != null and lastStartDate != ''">
  2218. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2219. </if>
  2220. <if test="lastEndDate != null and lastEndDate != ''">
  2221. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2222. </if>
  2223. </if>
  2224. <if test="isPlacefile != null and isPlacefile == 1">
  2225. <if test="lastStartDate != null and lastStartDate != ''">
  2226. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2227. </if>
  2228. <if test="lastEndDate != null and lastEndDate != ''">
  2229. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2230. </if>
  2231. </if>
  2232. <if test="level != null and level != ''">
  2233. and c.level = #{level}
  2234. </if>
  2235. <if test="deptName != null and deptName != ''">
  2236. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2237. </if>
  2238. GROUP BY
  2239. a.beh_dept_id,
  2240. a.beh_dept_name
  2241. ) t1,
  2242. (
  2243. SELECT
  2244. a.beh_dept_id AS deptId,
  2245. a.beh_dept_name AS deptName,
  2246. count( * ) AS entryNum
  2247. FROM
  2248. med_behospital_info a,
  2249. med_qcresult_info c,
  2250. med_qcresult_detail d,
  2251. qc_cases_entry e
  2252. WHERE
  2253. a.is_deleted = 'N'
  2254. AND c.is_deleted = 'N'
  2255. AND d.is_deleted = 'N'
  2256. AND e.is_deleted = 'N'
  2257. AND a.hospital_id = c.hospital_id
  2258. AND a.hospital_id = d.hospital_id
  2259. AND a.behospital_code = c.behospital_code
  2260. AND a.behospital_code = d.behospital_code
  2261. AND d.cases_id = e.cases_id
  2262. AND d.cases_entry_id = e.id
  2263. <if test="isPlacefile != null and isPlacefile != ''">
  2264. and a.is_placefile = #{isPlacefile}
  2265. </if>
  2266. AND a.qc_type_id != 0
  2267. <if test="hospitalId != null and hospitalId != ''">
  2268. AND a.hospital_id = #{hospitalId}
  2269. </if>
  2270. <if test="isPlacefile != null and isPlacefile == 0">
  2271. <if test="lastStartDate != null and lastStartDate != ''">
  2272. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2273. </if>
  2274. <if test="lastEndDate != null and lastEndDate != ''">
  2275. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2276. </if>
  2277. </if>
  2278. <if test="isPlacefile != null and isPlacefile == 1">
  2279. <if test="lastStartDate != null and lastStartDate != ''">
  2280. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2281. </if>
  2282. <if test="lastEndDate != null and lastEndDate != ''">
  2283. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2284. </if>
  2285. </if>
  2286. <if test="level != null and level != ''">
  2287. and c.level = #{level}
  2288. </if>
  2289. <if test="deptName != null and deptName != ''">
  2290. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2291. </if>
  2292. GROUP BY
  2293. a.beh_dept_id,
  2294. a.beh_dept_name
  2295. ) t2
  2296. WHERE
  2297. t1.deptId = t2.deptId
  2298. AND t1.deptName = t2.deptName)m2
  2299. on
  2300. m1.deptId = m2.deptId
  2301. AND m1.deptName = m2.deptName
  2302. <if test="asc != null and asc !=''">
  2303. order by
  2304. <choose>
  2305. <when test='asc=="deptId"'>m1.deptId asc</when>
  2306. <when test='asc=="deptName"'>m1.deptName asc</when>
  2307. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2308. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2309. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2310. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2311. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2312. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2313. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2314. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2315. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2316. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2317. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2318. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2319. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2320. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2321. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2322. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2323. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2324. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2325. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2326. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2327. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2328. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2329. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2330. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2331. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2332. <otherwise>deptName asc</otherwise>
  2333. </choose>
  2334. </if>
  2335. <if test="desc != null and desc!=''">
  2336. order by
  2337. <choose>
  2338. <when test='desc=="deptId"'>m1.deptId desc</when>
  2339. <when test='desc=="deptName"'>m1.deptName desc</when>
  2340. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2341. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2342. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2343. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2344. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2345. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2346. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2347. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2348. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2349. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2350. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2351. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2352. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2353. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2354. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2355. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2356. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2357. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2358. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2359. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2360. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2361. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2362. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2363. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2364. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2365. <otherwise>deptName desc</otherwise>
  2366. </choose>
  2367. </if>
  2368. </select>
  2369. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  2370. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  2371. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2372. SELECT
  2373. t1.deptId,
  2374. t1.deptName,
  2375. t1.deptClassId,
  2376. t1.deptClass,
  2377. t2.entryNum,
  2378. t1.mrNum,
  2379. t1.totleValue,
  2380. t1.averageValue,
  2381. t1.firstLevelNum,
  2382. t1.secondLevelNum,
  2383. t1.thirdLevelNum,
  2384. t1.firstLevelPercent,
  2385. t1.secondLevelPercent,
  2386. t1.thirdLevelPercent,
  2387. t1.firstLevelPercentStr,
  2388. t1.secondLevelPercentStr,
  2389. t1.thirdLevelPercentStr
  2390. FROM
  2391. (
  2392. SELECT
  2393. a.beh_dept_id AS deptId,
  2394. a.beh_dept_name AS deptName,
  2395. e.dept_id AS deptClassId,
  2396. e.dept_name AS deptClass,
  2397. count( DISTINCT c.id ) AS mrNum,
  2398. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2399. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  2400. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  2401. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  2402. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  2403. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  2404. ) AS firstLevelPercent,
  2405. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2406. ) AS secondLevelPercent,
  2407. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  2408. ) AS thirdLevelPercent,
  2409. concat(
  2410. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  2411. 100, 2 ),
  2412. '%'
  2413. ) AS firstLevelPercentStr,
  2414. concat(
  2415. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  2416. 100, 2 ),
  2417. '%'
  2418. ) AS secondLevelPercentStr,
  2419. concat(
  2420. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  2421. 100, 2 ),
  2422. '%'
  2423. ) AS thirdLevelPercentStr
  2424. FROM
  2425. med_behospital_info a,
  2426. med_qcresult_info c,
  2427. bas_dept_info d,
  2428. bas_dept_info e
  2429. WHERE
  2430. a.is_deleted = 'N'
  2431. AND c.is_deleted = 'N'
  2432. AND d.is_deleted = 'N'
  2433. AND e.is_deleted = 'N'
  2434. AND a.hospital_id = c.hospital_id
  2435. AND a.hospital_id = d.hospital_id
  2436. AND a.hospital_id = e.hospital_id
  2437. AND a.behospital_code = c.behospital_code
  2438. AND a.beh_dept_id = d.dept_id
  2439. AND d.parent_dept_id = e.dept_id
  2440. <if test="isPlacefile != null and isPlacefile != ''">
  2441. and a.is_placefile = #{isPlacefile}
  2442. </if>
  2443. <![CDATA[AND a.qc_type_id <>0 ]]>
  2444. <if test="hospitalId != null and hospitalId != ''">
  2445. AND a.hospital_id = #{hospitalId}
  2446. </if>
  2447. <if test="isPlacefile != null and isPlacefile == 0">
  2448. <if test="startDate != null and startDate != ''">
  2449. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2450. </if>
  2451. <if test="endDate != null and endDate != ''">
  2452. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2453. </if>
  2454. </if>
  2455. <if test="isPlacefile != null and isPlacefile == 1">
  2456. <if test="startDate != null and startDate != ''">
  2457. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2458. </if>
  2459. <if test="endDate != null and endDate != ''">
  2460. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2461. </if>
  2462. </if>
  2463. <if test="level != null and level != ''">
  2464. and c.level = #{level}
  2465. </if>
  2466. <if test="deptName != null and deptName != ''">
  2467. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2468. </if>
  2469. <if test="deptClass != null and deptClass != ''">
  2470. and e.dept_name = #{deptClass}
  2471. </if>
  2472. GROUP BY
  2473. a.beh_dept_id,
  2474. a.beh_dept_name,
  2475. e.dept_id,
  2476. e.dept_name
  2477. ) t1,
  2478. (
  2479. SELECT
  2480. a.beh_dept_id AS deptId,
  2481. a.beh_dept_name AS deptName,
  2482. g.dept_id AS deptClassId,
  2483. g.dept_name AS deptClass,
  2484. count( * ) AS entryNum
  2485. FROM
  2486. med_behospital_info a,
  2487. med_qcresult_info c,
  2488. med_qcresult_detail d,
  2489. qc_cases_entry e,
  2490. bas_dept_info f,
  2491. bas_dept_info g
  2492. WHERE
  2493. a.is_deleted = 'N'
  2494. AND c.is_deleted = 'N'
  2495. AND d.is_deleted = 'N'
  2496. AND e.is_deleted = 'N'
  2497. AND f.is_deleted = 'N'
  2498. AND g.is_deleted = 'N'
  2499. AND a.hospital_id = c.hospital_id
  2500. AND a.hospital_id = d.hospital_id
  2501. AND a.hospital_id = f.hospital_id
  2502. AND a.hospital_id = g.hospital_id
  2503. AND a.behospital_code = c.behospital_code
  2504. AND a.behospital_code = d.behospital_code
  2505. AND d.cases_id = e.cases_id
  2506. AND d.cases_entry_id = e.id
  2507. AND a.beh_dept_id = f.dept_id
  2508. AND f.parent_dept_id = g.dept_id
  2509. <if test="isPlacefile != null and isPlacefile != ''">
  2510. and a.is_placefile = #{isPlacefile}
  2511. </if>
  2512. <![CDATA[AND a.qc_type_id <>0 ]]>
  2513. <if test="hospitalId != null and hospitalId != ''">
  2514. AND a.hospital_id = #{hospitalId}
  2515. </if>
  2516. <if test="isPlacefile != null and isPlacefile == 0">
  2517. <if test="startDate != null and startDate != ''">
  2518. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2519. </if>
  2520. <if test="endDate != null and endDate != ''">
  2521. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2522. </if>
  2523. </if>
  2524. <if test="isPlacefile != null and isPlacefile == 1">
  2525. <if test="startDate != null and startDate != ''">
  2526. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2527. </if>
  2528. <if test="endDate != null and endDate != ''">
  2529. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2530. </if>
  2531. </if>
  2532. <if test="level != null and level != ''">
  2533. and c.level = #{level}
  2534. </if>
  2535. <if test="deptName != null and deptName != ''">
  2536. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  2537. </if>
  2538. <if test="deptClass != null and deptClass != ''">
  2539. and g.dept_name = #{deptClass}
  2540. </if>
  2541. GROUP BY
  2542. a.beh_dept_id,
  2543. a.beh_dept_name,
  2544. g.dept_id,
  2545. g.dept_name
  2546. ) t2
  2547. WHERE
  2548. t1.deptId = t2.deptId
  2549. AND t1.deptName = t2.deptName
  2550. AND t1.deptClassId = t2.deptClassId
  2551. AND t1.deptClass = t2.deptClass
  2552. <if test="asc != null and asc !=''">
  2553. order by
  2554. <choose>
  2555. <when test='asc=="deptId"'>deptId asc</when>
  2556. <when test='asc=="deptName"'>deptName asc</when>
  2557. <when test='asc=="deptClassId"'>deptClassId asc</when>
  2558. <when test='asc=="deptClass"'>deptClass asc</when>
  2559. <when test='asc=="entryNum"'>entryNum asc</when>
  2560. <when test='asc=="mrNum"'>mrNum asc</when>
  2561. <when test='asc=="totleValue"'>totleValue asc</when>
  2562. <when test='asc=="averageValue"'>averageValue asc</when>
  2563. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  2564. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  2565. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  2566. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  2567. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  2568. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  2569. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  2570. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  2571. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  2572. <otherwise>deptName asc</otherwise>
  2573. </choose>
  2574. </if>
  2575. <if test="desc != null and desc!=''">
  2576. order by
  2577. <choose>
  2578. <when test='desc=="deptId"'>deptId desc</when>
  2579. <when test='desc=="deptName"'>deptName desc</when>
  2580. <when test='desc=="deptClassId"'>deptClassId desc</when>
  2581. <when test='desc=="deptClass"'>deptClass desc</when>
  2582. <when test='desc=="entryNum"'>entryNum desc</when>
  2583. <when test='desc=="mrNum"'>mrNum desc</when>
  2584. <when test='desc=="totleValue"'>totleValue desc</when>
  2585. <when test='desc=="averageValue"'>averageValue desc</when>
  2586. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  2587. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  2588. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  2589. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  2590. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  2591. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  2592. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  2593. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  2594. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  2595. <otherwise>deptName desc</otherwise>
  2596. </choose>
  2597. </if>
  2598. </select>
  2599. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  2600. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  2601. select
  2602. m1.deptId,
  2603. m1.deptName,
  2604. m1.deptClassId,
  2605. m1.deptClass,
  2606. m1.entryNum,
  2607. m2.sameNum,
  2608. m1.mrNum,
  2609. m2.sameMrNum,
  2610. m1.totleValue,
  2611. m2.sameTotleValue,
  2612. m1.averageValue,
  2613. m2.sameAvgValue,
  2614. m1.firstLevelNum,
  2615. m2.sameFirstLevelNum,
  2616. m1.secondLevelNum,
  2617. m2.sameSecondLevelNum,
  2618. m1.thirdLevelNum,
  2619. m2.sameThirdLevelNum,
  2620. m1.firstLevelPercent,
  2621. m2.sameFirstLevelPercent,
  2622. m1.secondLevelPercent,
  2623. m2.sameSecondLevelPercent,
  2624. m1.thirdLevelPercent,
  2625. m2.sameThirdLevelPercent,
  2626. m1.firstLevelPercentStr,
  2627. m2.sameFirstLevelPercentStr,
  2628. m1.secondLevelPercentStr,
  2629. m2.sameSecondLevelPercentStr,
  2630. m1.thirdLevelPercentStr,
  2631. m2.sameThirdLevelPercentStr
  2632. from (
  2633. SELECT
  2634. t1.deptId,
  2635. t1.deptName,
  2636. t1.deptClassId,
  2637. t1.deptClass,
  2638. t2.entryNum,
  2639. t1.mrNum,
  2640. t1.totleValue,
  2641. t1.averageValue,
  2642. t1.firstLevelNum,
  2643. t1.secondLevelNum,
  2644. t1.thirdLevelNum,
  2645. t1.firstLevelPercent,
  2646. t1.secondLevelPercent,
  2647. t1.thirdLevelPercent,
  2648. t1.firstLevelPercentStr,
  2649. t1.secondLevelPercentStr,
  2650. t1.thirdLevelPercentStr
  2651. FROM
  2652. (
  2653. SELECT
  2654. tt1.deptId,
  2655. tt1.deptName,
  2656. e.dept_id AS deptClassId,
  2657. e.dept_name AS deptClass,
  2658. count(*) AS mrNum,
  2659. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2660. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2661. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2662. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2663. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2664. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2665. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2666. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2667. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2668. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2669. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2670. FROM
  2671. (
  2672. SELECT
  2673. a.beh_dept_id AS deptId,
  2674. a.beh_dept_name AS deptName,
  2675. d.parent_dept_id AS parentDeptId,
  2676. a.hospital_id AS hospitalId,
  2677. a.behospital_code AS behospitalCode,
  2678. c.score_res AS score,
  2679. c.LEVEL
  2680. FROM
  2681. med_behospital_info a,
  2682. med_qcresult_info c,
  2683. bas_dept_info d
  2684. WHERE
  2685. a.is_deleted = 'N'
  2686. AND c.is_deleted = 'N'
  2687. AND d.is_deleted = 'N'
  2688. AND a.hospital_id = c.hospital_id
  2689. AND a.hospital_id = d.hospital_id
  2690. AND a.behospital_code = c.behospital_code
  2691. AND a.beh_dept_id = d.dept_id
  2692. <if test="isPlacefile != null and isPlacefile != ''">
  2693. and a.is_placefile = #{isPlacefile}
  2694. </if>
  2695. AND a.qc_type_id != 0
  2696. <if test="hospitalId != null and hospitalId != ''">
  2697. AND a.hospital_id = #{hospitalId}
  2698. </if>
  2699. <if test="isPlacefile != null and isPlacefile == 0">
  2700. <if test="startDate != null and startDate != ''">
  2701. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2702. </if>
  2703. <if test="endDate != null and endDate != ''">
  2704. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2705. </if>
  2706. </if>
  2707. <if test="isPlacefile != null and isPlacefile == 1">
  2708. <if test="startDate != null and startDate != ''">
  2709. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2710. </if>
  2711. <if test="endDate != null and endDate != ''">
  2712. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2713. </if>
  2714. </if>
  2715. <if test="level != null and level != ''">
  2716. and c.level = #{level}
  2717. </if>
  2718. <if test="deptName != null and deptName != ''">
  2719. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2720. </if>
  2721. ) tt1
  2722. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2723. AND e.is_deleted = 'N'
  2724. AND tt1.hospitalId = e.hospital_id
  2725. <if test="deptClass != null and deptClass != ''">
  2726. WHERE e.dept_name = #{deptClass}
  2727. </if>
  2728. GROUP BY
  2729. tt1.deptId,
  2730. tt1.deptName,
  2731. e.dept_id,
  2732. e.dept_name
  2733. ) t1,
  2734. (
  2735. SELECT
  2736. tt2.deptId,
  2737. tt2.deptName,
  2738. g.dept_id AS deptClassId,
  2739. g.dept_name AS deptClass,
  2740. count( * ) AS entryNum
  2741. FROM
  2742. (
  2743. SELECT
  2744. a.beh_dept_id AS deptId,
  2745. a.beh_dept_name AS deptName,
  2746. f.parent_dept_id AS parentDeptId,
  2747. a.hospital_id AS hospitalId,
  2748. a.behospital_code AS behospitalCode
  2749. FROM
  2750. med_behospital_info a,
  2751. med_qcresult_info c,
  2752. med_qcresult_detail d,
  2753. qc_cases_entry e,
  2754. bas_dept_info f
  2755. WHERE
  2756. a.is_deleted = 'N'
  2757. AND c.is_deleted = 'N'
  2758. AND d.is_deleted = 'N'
  2759. AND e.is_deleted = 'N'
  2760. AND f.is_deleted = 'N'
  2761. AND a.hospital_id = c.hospital_id
  2762. AND a.hospital_id = d.hospital_id
  2763. AND a.hospital_id = f.hospital_id
  2764. AND a.behospital_code = c.behospital_code
  2765. AND a.behospital_code = d.behospital_code
  2766. AND d.cases_id = e.cases_id
  2767. AND d.cases_entry_id = e.id
  2768. AND a.beh_dept_id = f.dept_id
  2769. <if test="isPlacefile != null and isPlacefile != ''">
  2770. and a.is_placefile = #{isPlacefile}
  2771. </if>
  2772. AND a.qc_type_id != 0
  2773. <if test="hospitalId != null and hospitalId != ''">
  2774. AND a.hospital_id = #{hospitalId}
  2775. </if>
  2776. <if test="isPlacefile != null and isPlacefile == 0">
  2777. <if test="startDate != null and startDate != ''">
  2778. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2779. </if>
  2780. <if test="endDate != null and endDate != ''">
  2781. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2782. </if>
  2783. </if>
  2784. <if test="isPlacefile != null and isPlacefile == 1">
  2785. <if test="startDate != null and startDate != ''">
  2786. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2787. </if>
  2788. <if test="endDate != null and endDate != ''">
  2789. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2790. </if>
  2791. </if>
  2792. <if test="level != null and level != ''">
  2793. and c.level = #{level}
  2794. </if>
  2795. <if test="deptName != null and deptName != ''">
  2796. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2797. </if>
  2798. ) tt2
  2799. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2800. AND g.is_deleted = 'N'
  2801. AND tt2.hospitalId = g.hospital_id
  2802. <if test="deptClass != null and deptClass != ''">
  2803. WHERE g.dept_name = #{deptClass}
  2804. </if>
  2805. GROUP BY
  2806. tt2.deptId,
  2807. tt2.deptName,
  2808. g.dept_id,
  2809. g.dept_name
  2810. ) t2
  2811. WHERE
  2812. t1.deptId = t2.deptId
  2813. AND t1.deptName = t2.deptName)m1 left join
  2814. ( SELECT
  2815. t1.deptId,
  2816. t1.deptName,
  2817. t1.deptClassId,
  2818. t1.deptClass,
  2819. t2.entryNum as sameNum,
  2820. t1.mrNum as sameMrNum,
  2821. t1.totleValue as sameTotleValue,
  2822. t1.averageValue as sameAvgValue,
  2823. t1.firstLevelNum as sameFirstLevelNum,
  2824. t1.secondLevelNum as sameSecondLevelNum,
  2825. t1.thirdLevelNum as sameThirdLevelNum,
  2826. t1.firstLevelPercent as sameFirstLevelPercent,
  2827. t1.secondLevelPercent as sameSecondLevelPercent,
  2828. t1.thirdLevelPercent as sameThirdLevelPercent,
  2829. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2830. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2831. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2832. FROM
  2833. (
  2834. SELECT
  2835. tt1.deptId,
  2836. tt1.deptName,
  2837. e.dept_id AS deptClassId,
  2838. e.dept_name AS deptClass,
  2839. count(*) AS mrNum,
  2840. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2841. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2842. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2843. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2844. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2845. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2846. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2847. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2848. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2849. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2850. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2851. FROM
  2852. (
  2853. SELECT
  2854. a.beh_dept_id AS deptId,
  2855. a.beh_dept_name AS deptName,
  2856. d.parent_dept_id AS parentDeptId,
  2857. a.hospital_id AS hospitalId,
  2858. a.behospital_code AS behospitalCode,
  2859. c.score_res AS score,
  2860. c.LEVEL
  2861. FROM
  2862. med_behospital_info a,
  2863. med_qcresult_info c,
  2864. bas_dept_info d
  2865. WHERE
  2866. a.is_deleted = 'N'
  2867. AND c.is_deleted = 'N'
  2868. AND d.is_deleted = 'N'
  2869. AND a.hospital_id = c.hospital_id
  2870. AND a.hospital_id = d.hospital_id
  2871. AND a.behospital_code = c.behospital_code
  2872. AND a.beh_dept_id = d.dept_id
  2873. <if test="isPlacefile != null and isPlacefile != ''">
  2874. and a.is_placefile = #{isPlacefile}
  2875. </if>
  2876. AND a.qc_type_id != 0
  2877. <if test="hospitalId != null and hospitalId != ''">
  2878. AND a.hospital_id = #{hospitalId}
  2879. </if>
  2880. <if test="isPlacefile != null and isPlacefile == 0">
  2881. <if test="lastStartDate != null and lastStartDate != ''">
  2882. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2883. </if>
  2884. <if test="lastEndDate != null and lastEndDate != ''">
  2885. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2886. </if>
  2887. </if>
  2888. <if test="isPlacefile != null and isPlacefile == 1">
  2889. <if test="lastStartDate != null and lastStartDate != ''">
  2890. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2891. </if>
  2892. <if test="lastEndDate != null and lastEndDate != ''">
  2893. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2894. </if>
  2895. </if>
  2896. <if test="level != null and level != ''">
  2897. and c.level = #{level}
  2898. </if>
  2899. <if test="deptName != null and deptName != ''">
  2900. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2901. </if>
  2902. ) tt1
  2903. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2904. AND e.is_deleted = 'N'
  2905. AND tt1.hospitalId = e.hospital_id
  2906. <if test="deptClass != null and deptClass != ''">
  2907. WHERE e.dept_name = #{deptClass}
  2908. </if>
  2909. GROUP BY
  2910. tt1.deptId,
  2911. tt1.deptName,
  2912. e.dept_id,
  2913. e.dept_name
  2914. ) t1,
  2915. (
  2916. SELECT
  2917. tt2.deptId,
  2918. tt2.deptName,
  2919. g.dept_id AS deptClassId,
  2920. g.dept_name AS deptClass,
  2921. count( * ) AS entryNum
  2922. FROM
  2923. (
  2924. SELECT
  2925. a.beh_dept_id AS deptId,
  2926. a.beh_dept_name AS deptName,
  2927. f.parent_dept_id AS parentDeptId,
  2928. a.hospital_id AS hospitalId,
  2929. a.behospital_code AS behospitalCode
  2930. FROM
  2931. med_behospital_info a,
  2932. med_qcresult_info c,
  2933. med_qcresult_detail d,
  2934. qc_cases_entry e,
  2935. bas_dept_info f
  2936. WHERE
  2937. a.is_deleted = 'N'
  2938. AND c.is_deleted = 'N'
  2939. AND d.is_deleted = 'N'
  2940. AND e.is_deleted = 'N'
  2941. AND f.is_deleted = 'N'
  2942. AND a.hospital_id = c.hospital_id
  2943. AND a.hospital_id = d.hospital_id
  2944. AND a.hospital_id = f.hospital_id
  2945. AND a.behospital_code = c.behospital_code
  2946. AND a.behospital_code = d.behospital_code
  2947. AND d.cases_id = e.cases_id
  2948. AND d.cases_entry_id = e.id
  2949. AND a.beh_dept_id = f.dept_id
  2950. <if test="isPlacefile != null and isPlacefile != ''">
  2951. and a.is_placefile = #{isPlacefile}
  2952. </if>
  2953. AND a.qc_type_id != 0
  2954. <if test="hospitalId != null and hospitalId != ''">
  2955. AND a.hospital_id = #{hospitalId}
  2956. </if>
  2957. <if test="isPlacefile != null and isPlacefile == 0">
  2958. <if test="lastStartDate != null and lastStartDate != ''">
  2959. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2960. </if>
  2961. <if test="lastEndDate != null and lastEndDate != ''">
  2962. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2963. </if>
  2964. </if>
  2965. <if test="isPlacefile != null and isPlacefile == 1">
  2966. <if test="lastStartDate != null and lastStartDate != ''">
  2967. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2968. </if>
  2969. <if test="lastEndDate != null and lastEndDate != ''">
  2970. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2971. </if>
  2972. </if>
  2973. <if test="level != null and level != ''">
  2974. and c.level = #{level}
  2975. </if>
  2976. <if test="deptName != null and deptName != ''">
  2977. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2978. </if>
  2979. ) tt2
  2980. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2981. AND g.is_deleted = 'N'
  2982. AND tt2.hospitalId = g.hospital_id
  2983. <if test="deptClass != null and deptClass != ''">
  2984. WHERE g.dept_name = #{deptClass}
  2985. </if>
  2986. GROUP BY
  2987. tt2.deptId,
  2988. tt2.deptName,
  2989. g.dept_id,
  2990. g.dept_name
  2991. ) t2
  2992. WHERE
  2993. t1.deptId = t2.deptId
  2994. AND t1.deptName = t2.deptName)m2
  2995. on
  2996. m1.deptId = m2.deptId
  2997. and m1.deptName = m2.deptName
  2998. <if test="asc != null and asc !=''">
  2999. order by
  3000. <choose>
  3001. <when test='asc=="deptId"'>m1.deptId asc</when>
  3002. <when test='asc=="deptName"'>m1.deptName asc</when>
  3003. <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
  3004. <when test='asc=="deptClass"'>m1.deptClass asc</when>
  3005. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3006. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3007. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3008. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3009. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3010. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3011. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3012. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3013. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3014. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3015. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3016. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3017. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3018. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3019. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3020. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3021. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3022. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3023. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3024. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3025. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3026. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3027. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3028. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3029. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3030. <otherwise>deptName asc</otherwise>
  3031. </choose>
  3032. </if>
  3033. <if test="desc != null and desc!=''">
  3034. order by
  3035. <choose>
  3036. <when test='desc=="deptId"'>m1.deptId desc</when>
  3037. <when test='desc=="deptName"'>m1.deptName desc</when>
  3038. <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
  3039. <when test='desc=="deptClass"'>m1.deptClass desc</when>
  3040. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3041. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3042. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3043. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3044. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3045. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3046. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3047. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3048. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3049. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3050. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3051. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3052. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3053. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3054. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3055. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3056. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3057. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3058. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3059. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3060. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3061. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3062. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3063. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3064. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3065. <otherwise>deptName desc</otherwise>
  3066. </choose>
  3067. </if>
  3068. </select>
  3069. <!-- 病案首页合格率占比 -全院-->
  3070. <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  3071. resultType="com.diagbot.dto.HomePageNumDTO">
  3072. SELECT
  3073. t1.deptId,
  3074. t1.deptName,
  3075. t2.entryNum,
  3076. t1.mrNum,
  3077. t1.totleValue,
  3078. t1.averageValue,
  3079. t1.firstLevelNum,
  3080. t1.secondLevelNum,
  3081. t1.firstLevelPercent,
  3082. t1.secondLevelPercent,
  3083. t1.firstLevelPercentStr,
  3084. t1.secondLevelPercentStr,
  3085. t3.emptyNum,
  3086. t3.errorNum,
  3087. t3.entryTotleNum,
  3088. t3.emptyPercent,
  3089. t3.errorPercent,
  3090. t3.emptyPercentStr,
  3091. t3.errorPercentStr
  3092. FROM
  3093. (
  3094. SELECT
  3095. a.beh_dept_id AS deptId,
  3096. a.beh_dept_name AS deptName,
  3097. count( * ) AS mrNum,
  3098. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3099. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3100. SUM( c.`level` = '合格' ) AS firstLevelNum,
  3101. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  3102. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  3103. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3104. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
  3105. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
  3106. FROM
  3107. med_behospital_info a,
  3108. med_qcresult_cases c
  3109. WHERE
  3110. a.is_deleted = 'N'
  3111. AND c.is_deleted = 'N'
  3112. AND a.hospital_id = c.hospital_id
  3113. AND a.behospital_code = c.behospital_code
  3114. AND c.cases_id = 243
  3115. <if test="isPlacefile != null and isPlacefile != ''">
  3116. and a.is_placefile = #{isPlacefile}
  3117. </if>
  3118. AND a.qc_type_id != 0
  3119. <if test="hospitalId != null and hospitalId != ''">
  3120. AND a.hospital_id = #{hospitalId}
  3121. </if>
  3122. <if test="isPlacefile != null and isPlacefile == 0">
  3123. <if test="startDate != null and startDate != ''">
  3124. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3125. </if>
  3126. <if test="endDate != null and endDate != ''">
  3127. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3128. </if>
  3129. </if>
  3130. <if test="isPlacefile != null and isPlacefile == 1">
  3131. <if test="startDate != null and startDate != ''">
  3132. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3133. </if>
  3134. <if test="endDate != null and endDate != ''">
  3135. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3136. </if>
  3137. </if>
  3138. <if test="level != null and level != ''">
  3139. and c.level = #{level}
  3140. </if>
  3141. <if test="deptName != null and deptName != ''">
  3142. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3143. </if>
  3144. GROUP BY
  3145. a.beh_dept_id,
  3146. a.beh_dept_name
  3147. ) t1,
  3148. (
  3149. SELECT
  3150. a.beh_dept_id AS deptId,
  3151. a.beh_dept_name AS deptName,
  3152. count( * ) AS entryNum
  3153. FROM
  3154. med_behospital_info a,
  3155. med_qcresult_cases c,
  3156. med_qcresult_detail d,
  3157. qc_cases_entry e
  3158. WHERE
  3159. a.is_deleted = 'N'
  3160. AND c.is_deleted = 'N'
  3161. AND d.is_deleted = 'N'
  3162. AND e.is_deleted = 'N'
  3163. AND a.hospital_id = c.hospital_id
  3164. AND a.hospital_id = d.hospital_id
  3165. AND a.behospital_code = c.behospital_code
  3166. AND a.behospital_code = d.behospital_code
  3167. AND c.cases_id = d.cases_id
  3168. AND d.cases_id = e.cases_id
  3169. AND d.cases_entry_id = e.id
  3170. AND d.cases_id = 243
  3171. <if test="isPlacefile != null and isPlacefile != ''">
  3172. and a.is_placefile = #{isPlacefile}
  3173. </if>
  3174. AND a.qc_type_id != 0
  3175. <if test="hospitalId != null and hospitalId != ''">
  3176. AND a.hospital_id = #{hospitalId}
  3177. </if>
  3178. <if test="isPlacefile != null and isPlacefile == 0">
  3179. <if test="startDate != null and startDate != ''">
  3180. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3181. </if>
  3182. <if test="endDate != null and endDate != ''">
  3183. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3184. </if>
  3185. </if>
  3186. <if test="isPlacefile != null and isPlacefile == 1">
  3187. <if test="startDate != null and startDate != ''">
  3188. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3189. </if>
  3190. <if test="endDate != null and endDate != ''">
  3191. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3192. </if>
  3193. </if>
  3194. <if test="level != null and level != ''">
  3195. and c.level = #{level}
  3196. </if>
  3197. <if test="deptName != null and deptName != ''">
  3198. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3199. </if>
  3200. GROUP BY
  3201. a.beh_dept_id,
  3202. a.beh_dept_name
  3203. ) t2,(
  3204. SELECT
  3205. h1.deptId,
  3206. h1.deptName,
  3207. h1.emptyNum,
  3208. h1.errorNum,
  3209. h1.mrNum,
  3210. h2.entryNum,
  3211. h1.mrNum * h2.entryNum AS entryTotleNum,
  3212. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3213. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3214. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3215. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3216. FROM
  3217. (
  3218. SELECT
  3219. a.beh_dept_id AS deptId,
  3220. a.beh_dept_name AS deptName,
  3221. sum( d.rule_type = 1 ) AS emptyNum,
  3222. sum( d.rule_type = 2 ) AS errorNum,
  3223. count( DISTINCT a.behospital_code ) AS mrNum
  3224. FROM
  3225. med_behospital_info a,
  3226. med_qcresult_cases b,
  3227. med_qcresult_detail c,
  3228. qc_cases_entry d
  3229. WHERE
  3230. a.is_deleted = 'N'
  3231. AND b.is_deleted = 'N'
  3232. AND c.is_deleted = 'N'
  3233. AND d.is_deleted = 'N'
  3234. AND a.hospital_id = b.hospital_id
  3235. AND a.hospital_id = c.hospital_id
  3236. AND a.behospital_code = b.behospital_code
  3237. AND a.behospital_code = c.behospital_code
  3238. AND b.cases_id = c.cases_id
  3239. AND c.cases_id = d.cases_id
  3240. AND c.cases_entry_id = d.id
  3241. <if test="isPlacefile != null and isPlacefile != ''">
  3242. and a.is_placefile = #{isPlacefile}
  3243. </if>
  3244. AND d.cases_id = 243
  3245. AND a.qc_type_id != 0
  3246. <if test="hospitalId != null and hospitalId != ''">
  3247. AND a.hospital_id = #{hospitalId}
  3248. </if>
  3249. <if test="isPlacefile != null and isPlacefile == 0">
  3250. <if test="startDate != null and startDate != ''">
  3251. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3252. </if>
  3253. <if test="endDate != null and endDate != ''">
  3254. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3255. </if>
  3256. </if>
  3257. <if test="isPlacefile != null and isPlacefile == 1">
  3258. <if test="startDate != null and startDate != ''">
  3259. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3260. </if>
  3261. <if test="endDate != null and endDate != ''">
  3262. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3263. </if>
  3264. </if>
  3265. <if test="level != null and level != ''">
  3266. and b.level = #{level}
  3267. </if>
  3268. <if test="deptName != null and deptName != ''">
  3269. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  3270. </if>
  3271. GROUP BY
  3272. a.beh_dept_id,
  3273. a.beh_dept_name
  3274. ) h1,(
  3275. SELECT
  3276. count(*) AS entryNum
  3277. FROM
  3278. qc_cases_entry
  3279. WHERE
  3280. is_deleted = 'N'
  3281. AND cases_id = 243
  3282. ) h2
  3283. ) t3
  3284. WHERE
  3285. t1.deptId = t2.deptId
  3286. AND t1.deptId = t3.deptId
  3287. AND t1.deptName = t2.deptName
  3288. AND t1.deptName = t3.deptName
  3289. <if test="asc != null and asc !=''">
  3290. order by
  3291. <choose>
  3292. <when test='asc=="deptId"'>deptId asc</when>
  3293. <when test='asc=="deptName"'>deptName asc</when>
  3294. <when test='asc=="entryNum"'>entryNum asc</when>
  3295. <when test='asc=="mrNum"'>mrNum asc</when>
  3296. <when test='asc=="totleValue"'>totleValue asc</when>
  3297. <when test='asc=="averageValue"'>averageValue asc</when>
  3298. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  3299. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  3300. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  3301. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  3302. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  3303. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  3304. <when test='asc=="emptyNum"'>emptyNum asc</when>
  3305. <when test='asc=="errorNum"'>errorNum asc</when>
  3306. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  3307. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  3308. <when test='asc=="errorPercent"'>errorPercent asc</when>
  3309. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  3310. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  3311. <otherwise>deptName asc</otherwise>
  3312. </choose>
  3313. </if>
  3314. <if test="desc != null and desc!=''">
  3315. order by
  3316. <choose>
  3317. <when test='desc=="deptId"'>deptId desc</when>
  3318. <when test='desc=="deptName"'>deptName desc</when>
  3319. <when test='desc=="entryNum"'>entryNum desc</when>
  3320. <when test='desc=="mrNum"'>mrNum desc</when>
  3321. <when test='desc=="totleValue"'>totleValue desc</when>
  3322. <when test='desc=="averageValue"'>averageValue desc</when>
  3323. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  3324. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  3325. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  3326. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  3327. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  3328. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  3329. <when test='desc=="emptyNum"'>emptyNum desc</when>
  3330. <when test='desc=="errorNum"'>errorNum desc</when>
  3331. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  3332. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  3333. <when test='desc=="errorPercent"'>errorPercent desc</when>
  3334. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  3335. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  3336. <otherwise>deptName desc</otherwise>
  3337. </choose>
  3338. </if>
  3339. </select>
  3340. <!-- 各科室缺陷占比-科室 -->
  3341. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3342. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  3343. SELECT
  3344. m1.doctorId,
  3345. m1.doctorName,
  3346. m1.entryNum,
  3347. m2.sameNum,
  3348. m1.mrNum,
  3349. m2.sameMrNum,
  3350. m1.totleValue,
  3351. m2.sameTotleValue,
  3352. m1.averageValue,
  3353. m2.sameAvgValue,
  3354. m1.firstLevelNum,
  3355. m2.sameFirstLevelNum,
  3356. m1.secondLevelNum,
  3357. m2.sameSecondLevelNum,
  3358. m1.thirdLevelNum,
  3359. m2.sameThirdLevelNum,
  3360. m1.firstLevelPercent,
  3361. m2.sameFirstLevelPercent,
  3362. m1.secondLevelPercent,
  3363. m2.sameSecondLevelPercent,
  3364. m1.thirdLevelPercent,
  3365. m2.sameThirdLevelPercent,
  3366. m1.firstLevelPercentStr,
  3367. m2.sameFirstLevelPercentStr,
  3368. m1.secondLevelPercentStr,
  3369. m2.sameSecondLevelPercentStr,
  3370. m1.thirdLevelPercentStr,
  3371. m2.sameThirdLevelPercentStr
  3372. FROM
  3373. (
  3374. SELECT
  3375. t1.doctorId,
  3376. t1.doctorName,
  3377. t2.entryNum,
  3378. t1.mrNum,
  3379. t1.totleValue,
  3380. t1.averageValue,
  3381. t1.firstLevelNum,
  3382. t1.secondLevelNum,
  3383. t1.thirdLevelNum,
  3384. t1.firstLevelPercent,
  3385. t1.secondLevelPercent,
  3386. t1.thirdLevelPercent,
  3387. t1.firstLevelPercentStr,
  3388. t1.secondLevelPercentStr,
  3389. t1.thirdLevelPercentStr
  3390. FROM
  3391. (
  3392. SELECT
  3393. a.doctor_id AS doctorId,
  3394. a.doctor_name AS doctorName,
  3395. count(*) AS mrNum,
  3396. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3397. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3398. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3399. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3400. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3401. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3402. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3403. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3404. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3405. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3406. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3407. FROM
  3408. med_behospital_info a,
  3409. med_qcresult_info c,
  3410. sys_user_dept e
  3411. WHERE
  3412. a.is_deleted = 'N'
  3413. AND c.is_deleted = 'N'
  3414. AND e.is_deleted = 'N'
  3415. AND a.hospital_id = c.hospital_id
  3416. AND a.behospital_code = c.behospital_code
  3417. AND a.beh_dept_id = e.dept_id
  3418. <if test="isPlacefile != null and isPlacefile != ''">
  3419. and a.is_placefile = #{isPlacefile}
  3420. </if>
  3421. AND a.qc_type_id != 0
  3422. <if test="hospitalId != null and hospitalId != ''">
  3423. AND a.hospital_id = #{hospitalId}
  3424. </if>
  3425. <if test="isPlacefile != null and isPlacefile == 0">
  3426. <if test="startDate != null and startDate != ''">
  3427. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3428. </if>
  3429. <if test="endDate != null and endDate != ''">
  3430. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3431. </if>
  3432. </if>
  3433. <if test="isPlacefile != null and isPlacefile == 1">
  3434. <if test="startDate != null and startDate != ''">
  3435. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3436. </if>
  3437. <if test="endDate != null and endDate != ''">
  3438. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3439. </if>
  3440. </if>
  3441. <if test="level != null and level != ''">
  3442. and c.level = #{level}
  3443. </if>
  3444. <if test="doctorName != null and doctorName != ''">
  3445. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3446. </if>
  3447. <if test="userId!=null and userId !=''">
  3448. AND e.user_id = #{userId}
  3449. </if>
  3450. <if test="deptName != null and deptName != ''">
  3451. and a.beh_dept_name = #{deptName}
  3452. </if>
  3453. GROUP BY
  3454. a.doctor_id,
  3455. a.doctor_name
  3456. ) t1,
  3457. (
  3458. SELECT
  3459. a.doctor_id AS doctorId,
  3460. a.doctor_name AS doctorName,
  3461. count( * ) AS entryNum
  3462. FROM
  3463. med_behospital_info a,
  3464. med_qcresult_info c,
  3465. med_qcresult_detail d,
  3466. qc_cases_entry e,
  3467. sys_user_dept f
  3468. WHERE
  3469. a.is_deleted = 'N'
  3470. AND c.is_deleted = 'N'
  3471. AND d.is_deleted = 'N'
  3472. AND e.is_deleted = 'N'
  3473. AND f.is_deleted = 'N'
  3474. AND a.hospital_id = c.hospital_id
  3475. AND a.hospital_id = d.hospital_id
  3476. AND a.behospital_code = c.behospital_code
  3477. AND a.behospital_code = d.behospital_code
  3478. AND d.cases_id = e.cases_id
  3479. AND d.cases_entry_id = e.id
  3480. AND a.beh_dept_id = f.dept_id
  3481. <if test="isPlacefile != null and isPlacefile != ''">
  3482. and a.is_placefile = #{isPlacefile}
  3483. </if>
  3484. AND a.qc_type_id != 0
  3485. <if test="hospitalId != null and hospitalId != ''">
  3486. AND a.hospital_id = #{hospitalId}
  3487. </if>
  3488. <if test="isPlacefile != null and isPlacefile == 0">
  3489. <if test="startDate != null and startDate != ''">
  3490. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3491. </if>
  3492. <if test="endDate != null and endDate != ''">
  3493. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3494. </if>
  3495. </if>
  3496. <if test="isPlacefile != null and isPlacefile == 1">
  3497. <if test="startDate != null and startDate != ''">
  3498. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3499. </if>
  3500. <if test="endDate != null and endDate != ''">
  3501. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3502. </if>
  3503. </if>
  3504. <if test="level != null and level != ''">
  3505. and c.level = #{level}
  3506. </if>
  3507. <if test="doctorName != null and doctorName != ''">
  3508. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3509. </if>
  3510. <if test="userId!=null and userId !=''">
  3511. AND f.user_id = #{userId}
  3512. </if>
  3513. <if test="deptName != null and deptName != ''">
  3514. and a.beh_dept_name = #{deptName}
  3515. </if>
  3516. GROUP BY
  3517. a.doctor_id,
  3518. a.doctor_name
  3519. ) t2
  3520. WHERE
  3521. t1.doctorId = t2.doctorId
  3522. AND t1.doctorName = t2.doctorName
  3523. )m1 left join
  3524. ( SELECT
  3525. t1.doctorId,
  3526. t1.doctorName,
  3527. t2.entryNum as sameNum,
  3528. t1.mrNum as sameMrNum,
  3529. t1.totleValue as sameTotleValue,
  3530. t1.averageValue as sameAvgValue,
  3531. t1.firstLevelNum as sameFirstLevelNum,
  3532. t1.secondLevelNum as sameSecondLevelNum,
  3533. t1.thirdLevelNum as sameThirdLevelNum,
  3534. t1.firstLevelPercent as sameFirstLevelPercent,
  3535. t1.secondLevelPercent as sameSecondLevelPercent,
  3536. t1.thirdLevelPercent as sameThirdLevelPercent,
  3537. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  3538. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  3539. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  3540. FROM
  3541. (
  3542. SELECT
  3543. a.doctor_id AS doctorId,
  3544. a.doctor_name AS doctorName,
  3545. count(*) AS mrNum,
  3546. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3547. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3548. SUM( c.`level` = '甲' ) AS firstLevelNum,
  3549. SUM( c.`level` = '乙' ) AS secondLevelNum,
  3550. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  3551. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  3552. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  3553. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  3554. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3555. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  3556. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  3557. FROM
  3558. med_behospital_info a,
  3559. med_qcresult_info c,
  3560. sys_user_dept e
  3561. WHERE
  3562. a.is_deleted = 'N'
  3563. AND c.is_deleted = 'N'
  3564. AND e.is_deleted = 'N'
  3565. AND a.hospital_id = c.hospital_id
  3566. AND a.behospital_code = c.behospital_code
  3567. AND a.beh_dept_id = e.dept_id
  3568. <if test="isPlacefile != null and isPlacefile != ''">
  3569. and a.is_placefile = #{isPlacefile}
  3570. </if>
  3571. AND a.qc_type_id != 0
  3572. <if test="hospitalId != null and hospitalId != ''">
  3573. AND a.hospital_id = #{hospitalId}
  3574. </if>
  3575. <if test="isPlacefile != null and isPlacefile == 0">
  3576. <if test="lastStartDate != null and lastStartDate != ''">
  3577. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3578. </if>
  3579. <if test="lastEndDate != null and lastEndDate != ''">
  3580. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3581. </if>
  3582. </if>
  3583. <if test="isPlacefile != null and isPlacefile == 1">
  3584. <if test="lastStartDate != null and lastStartDate != ''">
  3585. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3586. </if>
  3587. <if test="lastEndDate != null and lastEndDate != ''">
  3588. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3589. </if>
  3590. </if>
  3591. <if test="level != null and level != ''">
  3592. and c.level = #{level}
  3593. </if>
  3594. <if test="doctorName != null and doctorName != ''">
  3595. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3596. </if>
  3597. <if test="userId!=null and userId !=''">
  3598. AND e.user_id = #{userId}
  3599. </if>
  3600. <if test="deptName != null and deptName != ''">
  3601. and a.beh_dept_name = #{deptName}
  3602. </if>
  3603. GROUP BY
  3604. a.doctor_id,
  3605. a.doctor_name
  3606. ) t1,
  3607. (
  3608. SELECT
  3609. a.doctor_id AS doctorId,
  3610. a.doctor_name AS doctorName,
  3611. count( * ) AS entryNum
  3612. FROM
  3613. med_behospital_info a,
  3614. med_qcresult_info c,
  3615. med_qcresult_detail d,
  3616. qc_cases_entry e,
  3617. sys_user_dept f
  3618. WHERE
  3619. a.is_deleted = 'N'
  3620. AND c.is_deleted = 'N'
  3621. AND d.is_deleted = 'N'
  3622. AND e.is_deleted = 'N'
  3623. AND f.is_deleted = 'N'
  3624. AND a.hospital_id = c.hospital_id
  3625. AND a.hospital_id = d.hospital_id
  3626. AND a.behospital_code = c.behospital_code
  3627. AND a.behospital_code = d.behospital_code
  3628. AND d.cases_id = e.cases_id
  3629. AND d.cases_entry_id = e.id
  3630. AND a.beh_dept_id = f.dept_id
  3631. <if test="isPlacefile != null and isPlacefile != ''">
  3632. and a.is_placefile = #{isPlacefile}
  3633. </if>
  3634. AND a.qc_type_id != 0
  3635. <if test="hospitalId != null and hospitalId != ''">
  3636. AND a.hospital_id = #{hospitalId}
  3637. </if>
  3638. <if test="isPlacefile != null and isPlacefile == 0">
  3639. <if test="lastStartDate != null and lastStartDate != ''">
  3640. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  3641. </if>
  3642. <if test="lastEndDate != null and lastEndDate != ''">
  3643. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  3644. </if>
  3645. </if>
  3646. <if test="isPlacefile != null and isPlacefile == 1">
  3647. <if test="lastStartDate != null and lastStartDate != ''">
  3648. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  3649. </if>
  3650. <if test="lastEndDate != null and lastEndDate != ''">
  3651. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  3652. </if>
  3653. </if>
  3654. <if test="level != null and level != ''">
  3655. and c.level = #{level}
  3656. </if>
  3657. <if test="doctorName != null and doctorName != ''">
  3658. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  3659. </if>
  3660. <if test="userId!=null and userId !=''">
  3661. AND f.user_id = #{userId}
  3662. </if>
  3663. <if test="deptName != null and deptName != ''">
  3664. and a.beh_dept_name = #{deptName}
  3665. </if>
  3666. GROUP BY
  3667. a.doctor_id,
  3668. a.doctor_name
  3669. ) t2
  3670. WHERE
  3671. t1.doctorId = t2.doctorId
  3672. AND t1.doctorName = t2.doctorName
  3673. )m2
  3674. on
  3675. m1.doctorId = m2.doctorId
  3676. AND m1.doctorName = m2.doctorName
  3677. <if test="asc != null and asc !=''">
  3678. order by
  3679. <choose>
  3680. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  3681. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  3682. <when test='asc=="name"'>m1.doctorName asc</when>
  3683. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  3684. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  3685. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  3686. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  3687. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  3688. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  3689. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  3690. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  3691. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  3692. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  3693. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  3694. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  3695. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  3696. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  3697. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  3698. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  3699. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  3700. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  3701. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  3702. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  3703. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  3704. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  3705. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  3706. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  3707. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  3708. <otherwise>doctorName asc</otherwise>
  3709. </choose>
  3710. </if>
  3711. <if test="desc != null and desc!=''">
  3712. order by
  3713. <choose>
  3714. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  3715. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  3716. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  3717. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  3718. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  3719. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  3720. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  3721. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  3722. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  3723. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  3724. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  3725. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  3726. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  3727. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  3728. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  3729. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  3730. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  3731. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  3732. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  3733. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  3734. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  3735. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  3736. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  3737. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  3738. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  3739. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  3740. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  3741. <otherwise>doctorName desc</otherwise>
  3742. </choose>
  3743. </if>
  3744. </select>
  3745. <!-- 病案首页合格率占比-科室 -->
  3746. <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  3747. resultType="com.diagbot.dto.HomePageByDeptDTO">
  3748. SELECT
  3749. t1.doctorId,
  3750. t1.doctorName,
  3751. t2.entryNum,
  3752. t1.mrNum,
  3753. t1.totleValue,
  3754. t1.averageValue,
  3755. t1.firstLevelNum,
  3756. t1.secondLevelNum,
  3757. t1.firstLevelPercent,
  3758. t1.secondLevelPercent,
  3759. t1.firstLevelPercentStr,
  3760. t1.secondLevelPercentStr,
  3761. t3.emptyNum,
  3762. t3.errorNum,
  3763. t3.entryTotleNum,
  3764. t3.emptyPercent,
  3765. t3.errorPercent,
  3766. t3.emptyPercentStr,
  3767. t3.errorPercentStr
  3768. FROM
  3769. (
  3770. SELECT
  3771. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3772. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3773. count( * ) AS mrNum,
  3774. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  3775. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  3776. sum( c.`level` = '合格' ) AS firstLevelNum,
  3777. sum( c.`level` = '不合格' ) AS secondLevelNum,
  3778. ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
  3779. ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  3780. concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  3781. concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  3782. FROM
  3783. med_behospital_info a,
  3784. med_qcresult_cases c,
  3785. sys_user_dept f
  3786. WHERE
  3787. a.is_deleted = 'N'
  3788. AND c.is_deleted = 'N'
  3789. AND f.is_deleted = 'N'
  3790. AND a.hospital_id = c.hospital_id
  3791. AND a.behospital_code = c.behospital_code
  3792. AND a.beh_dept_id = f.dept_id
  3793. AND c.cases_id = 243
  3794. <if test="isPlacefile != null and isPlacefile != ''">
  3795. and a.is_placefile = #{isPlacefile}
  3796. </if>
  3797. <![CDATA[AND a.qc_type_id <>0 ]]>
  3798. <if test="hospitalId != null and hospitalId != ''">
  3799. AND a.hospital_id = #{hospitalId}
  3800. </if>
  3801. <if test="isPlacefile != null and isPlacefile == 0">
  3802. <if test="startDate != null and startDate != ''">
  3803. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3804. </if>
  3805. <if test="endDate != null and endDate != ''">
  3806. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3807. </if>
  3808. </if>
  3809. <if test="isPlacefile != null and isPlacefile == 1">
  3810. <if test="startDate != null and startDate != ''">
  3811. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3812. </if>
  3813. <if test="endDate != null and endDate != ''">
  3814. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3815. </if>
  3816. </if>
  3817. <if test="level != null and level != ''">
  3818. and c.level = #{level}
  3819. </if>
  3820. <if test="name != null and name != ''">
  3821. <if test="name == '未知'">
  3822. and (a.doctor_name is null or a.doctor_name='')
  3823. </if>
  3824. <if test="name != '未知'">
  3825. and a.doctor_name like CONCAT('%',#{name},'%')
  3826. </if>
  3827. </if>
  3828. <if test="userId!=null and userId !=''">
  3829. AND f.user_id = #{userId}
  3830. </if>
  3831. <if test="deptName!=null and deptName !=''">
  3832. AND a.beh_dept_name = #{deptName}
  3833. </if>
  3834. <if test="name != null and name != ''">
  3835. AND a.doctor_name like CONCAT('%', #{name}, '%')
  3836. </if>
  3837. GROUP BY
  3838. a.doctor_id,
  3839. a.doctor_name
  3840. ) t1,
  3841. (
  3842. SELECT
  3843. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3844. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3845. count( * ) AS entryNum
  3846. FROM
  3847. med_behospital_info a,
  3848. med_qcresult_cases c,
  3849. med_qcresult_detail d,
  3850. qc_cases_entry e,
  3851. sys_user_dept f
  3852. WHERE
  3853. a.is_deleted = 'N'
  3854. AND c.is_deleted = 'N'
  3855. AND d.is_deleted = 'N'
  3856. AND e.is_deleted = 'N'
  3857. AND f.is_deleted = 'N'
  3858. AND a.hospital_id = c.hospital_id
  3859. AND a.hospital_id = d.hospital_id
  3860. AND a.behospital_code = c.behospital_code
  3861. AND a.behospital_code = d.behospital_code
  3862. AND a.beh_dept_id = f.dept_id
  3863. AND c.cases_id = d.cases_id
  3864. AND d.cases_id = e.cases_id
  3865. AND d.cases_entry_id = e.id
  3866. AND c.cases_id = 243
  3867. <if test="isPlacefile != null and isPlacefile != ''">
  3868. and a.is_placefile = #{isPlacefile}
  3869. </if>
  3870. <![CDATA[AND a.qc_type_id <>0 ]]>
  3871. <if test="hospitalId != null and hospitalId != ''">
  3872. AND a.hospital_id = #{hospitalId}
  3873. </if>
  3874. <if test="isPlacefile != null and isPlacefile == 0">
  3875. <if test="startDate != null and startDate != ''">
  3876. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3877. </if>
  3878. <if test="endDate != null and endDate != ''">
  3879. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3880. </if>
  3881. </if>
  3882. <if test="isPlacefile != null and isPlacefile == 1">
  3883. <if test="startDate != null and startDate != ''">
  3884. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3885. </if>
  3886. <if test="endDate != null and endDate != ''">
  3887. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3888. </if>
  3889. </if>
  3890. <if test="level != null and level != ''">
  3891. and c.level = #{level}
  3892. </if>
  3893. <if test="name != null and name != ''">
  3894. <if test="name == '未知'">
  3895. and (a.doctor_name is null or a.doctor_name='')
  3896. </if>
  3897. <if test="name != '未知'">
  3898. and a.doctor_name like CONCAT('%',#{name},'%')
  3899. </if>
  3900. </if>
  3901. <if test="userId!=null and userId !=''">
  3902. AND f.user_id = #{userId}
  3903. </if>
  3904. <if test="deptName!=null and deptName !=''">
  3905. AND a.beh_dept_name = #{deptName}
  3906. </if>
  3907. <if test="name != null and name != ''">
  3908. AND a.doctor_name like CONCAT('%', #{name}, '%')
  3909. </if>
  3910. GROUP BY
  3911. a.doctor_id,
  3912. a.doctor_name
  3913. ) t2,(
  3914. SELECT
  3915. h1.doctorId,
  3916. h1.doctorName,
  3917. h1.emptyNum,
  3918. h1.errorNum,
  3919. h1.mrNum,
  3920. h2.entryNum,
  3921. h1.mrNum * h2.entryNum AS entryTotleNum,
  3922. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  3923. ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS errorPercent,
  3924. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS emptyPercentStr,
  3925. CONCAT( ROUND( ( h1.mrNum * h2.entryNum - h1.errorNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ), '%' ) AS errorPercentStr
  3926. FROM
  3927. (
  3928. SELECT
  3929. CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
  3930. CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
  3931. sum( d.rule_type = 1 ) AS emptyNum,
  3932. sum( d.rule_type = 2 ) AS errorNum,
  3933. count( DISTINCT a.behospital_code ) AS mrNum
  3934. FROM
  3935. med_behospital_info a,
  3936. med_qcresult_cases b,
  3937. med_qcresult_detail c,
  3938. qc_cases_entry d,
  3939. sys_user_dept e
  3940. WHERE
  3941. a.is_deleted = 'N'
  3942. AND b.is_deleted = 'N'
  3943. AND c.is_deleted = 'N'
  3944. AND d.is_deleted = 'N'
  3945. AND e.is_deleted = 'N'
  3946. AND a.hospital_id = b.hospital_id
  3947. AND a.hospital_id = c.hospital_id
  3948. AND a.hospital_id = e.hospital_id
  3949. AND a.behospital_code = b.behospital_code
  3950. AND a.behospital_code = c.behospital_code
  3951. AND b.cases_id = c.cases_id
  3952. AND c.cases_id = d.cases_id
  3953. AND c.cases_entry_id = d.id
  3954. AND a.beh_dept_id = e.dept_id
  3955. <if test="isPlacefile != null and isPlacefile != ''">
  3956. and a.is_placefile = #{isPlacefile}
  3957. </if>
  3958. AND d.cases_id = 243
  3959. <![CDATA[AND a.qc_type_id <>0 ]]>
  3960. <if test="hospitalId != null and hospitalId != ''">
  3961. AND a.hospital_id = #{hospitalId}
  3962. </if>
  3963. <if test="isPlacefile != null and isPlacefile == 0">
  3964. <if test="startDate != null and startDate != ''">
  3965. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3966. </if>
  3967. <if test="endDate != null and endDate != ''">
  3968. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3969. </if>
  3970. </if>
  3971. <if test="isPlacefile != null and isPlacefile == 1">
  3972. <if test="startDate != null and startDate != ''">
  3973. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3974. </if>
  3975. <if test="endDate != null and endDate != ''">
  3976. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  3977. </if>
  3978. </if>
  3979. <if test="level != null and level != ''">
  3980. and b.level = #{level}
  3981. </if>
  3982. <if test="name != null and name != ''">
  3983. <if test="name == '未知'">
  3984. and (a.doctor_name is null or a.doctor_name='')
  3985. </if>
  3986. <if test="name != '未知'">
  3987. and a.doctor_name like CONCAT('%',#{name},'%')
  3988. </if>
  3989. </if>
  3990. <if test="userId!=null and userId !=''">
  3991. AND e.user_id = #{userId}
  3992. </if>
  3993. <if test="deptName!=null and deptName !=''">
  3994. AND a.beh_dept_name = #{deptName}
  3995. </if>
  3996. <if test="name != null and name != ''">
  3997. AND a.doctor_name like CONCAT('%', #{name}, '%')
  3998. </if>
  3999. GROUP BY
  4000. a.doctor_id,
  4001. a.doctor_name
  4002. ) h1,(
  4003. SELECT
  4004. count(*) AS entryNum
  4005. FROM
  4006. qc_cases_entry
  4007. WHERE
  4008. is_deleted = 'N'
  4009. AND cases_id = 243
  4010. ) h2
  4011. ) t3
  4012. WHERE
  4013. t1.doctorId = t2.doctorId
  4014. AND t1.doctorId = t3.doctorId
  4015. AND t1.doctorName = t2.doctorName
  4016. AND t1.doctorName = t3.doctorName
  4017. <if test="asc != null and asc !=''">
  4018. order by
  4019. <choose>
  4020. <when test='asc=="doctorId"'>doctorId asc</when>
  4021. <when test='asc=="doctorName"'>doctorName asc</when>
  4022. <when test='asc=="entryNum"'>entryNum asc</when>
  4023. <when test='asc=="mrNum"'>mrNum asc</when>
  4024. <when test='asc=="totleValue"'>totleValue asc</when>
  4025. <when test='asc=="averageValue"'>averageValue asc</when>
  4026. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  4027. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  4028. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  4029. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  4030. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  4031. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  4032. <when test='asc=="emptyNum"'>emptyNum asc</when>
  4033. <when test='asc=="errorNum"'>errorNum asc</when>
  4034. <when test='asc=="entryTotleNum"'>entryTotleNum asc</when>
  4035. <when test='asc=="emptyPercent"'>emptyPercent asc</when>
  4036. <when test='asc=="errorPercent"'>errorPercent asc</when>
  4037. <when test='asc=="emptyPercentStr"'>emptyPercent asc</when>
  4038. <when test='asc=="errorPercentStr"'>errorPercent asc</when>
  4039. <otherwise>doctorName asc</otherwise>
  4040. </choose>
  4041. </if>
  4042. <if test="desc != null and desc!=''">
  4043. order by
  4044. <choose>
  4045. <when test='desc=="doctorId"'>doctorId desc</when>
  4046. <when test='desc=="doctorName"'>doctorName desc</when>
  4047. <when test='desc=="entryNum"'>entryNum desc</when>
  4048. <when test='desc=="mrNum"'>mrNum desc</when>
  4049. <when test='desc=="totleValue"'>totleValue desc</when>
  4050. <when test='desc=="averageValue"'>averageValue desc</when>
  4051. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  4052. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  4053. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  4054. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  4055. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  4056. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  4057. <when test='desc=="emptyNum"'>emptyNum desc</when>
  4058. <when test='desc=="errorNum"'>errorNum desc</when>
  4059. <when test='desc=="entryTotleNum"'>entryTotleNum desc</when>
  4060. <when test='desc=="emptyPercent"'>emptyPercent desc</when>
  4061. <when test='desc=="errorPercent"'>errorPercent desc</when>
  4062. <when test='desc=="emptyPercentStr"'>emptyPercent desc</when>
  4063. <when test='desc=="errorPercentStr"'>errorPercent desc</when>
  4064. <otherwise>doctorName desc</otherwise>
  4065. </choose>
  4066. </if>
  4067. </select>
  4068. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  4069. <result column="behDeptName" property="behDeptName"/>
  4070. <result column="doctorName" property="doctorName"/>
  4071. <result column="avgScore" property="avgScore"/>
  4072. <collection property="excelBehospitalDTOS"
  4073. ofType="com.diagbot.dto.ExportExcelBehByDeptDTO">
  4074. <result column="patName" property="patName"/>
  4075. <result column="behospitalCode" property="behospitalCode"/>
  4076. <result column="behospitalDate" property="behospitalDate"/>
  4077. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4078. <result column="score" property="score"/>
  4079. <result column="scoreBn" property="scoreBn"/>
  4080. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4081. <result column="caseName" property="caseName"/>
  4082. <collection property="exportExcelMsgDTOS"
  4083. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4084. <result column="msg" property="msg"/>
  4085. </collection>
  4086. </collection>
  4087. </collection>
  4088. </resultMap>
  4089. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  4090. <result column="behDeptName" property="behDeptName"/>
  4091. <result column="avgScore" property="avgScore"/>
  4092. <collection property="excelBehospitalDTOS"
  4093. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  4094. <result column="doctorName" property="doctorName"/>
  4095. <result column="patName" property="patName"/>
  4096. <result column="behospitalCode" property="behospitalCode"/>
  4097. <result column="behospitalDate" property="behospitalDate"/>
  4098. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  4099. <result column="score" property="score"/>
  4100. <result column="scoreBn" property="scoreBn"/>
  4101. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  4102. <result column="caseName" property="caseName"/>
  4103. <collection property="exportExcelMsgDTOS"
  4104. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  4105. <result column="msg" property="msg"/>
  4106. </collection>
  4107. </collection>
  4108. </collection>
  4109. </resultMap>
  4110. <select id="exportExcel" resultMap="ExportExcelMap">
  4111. SELECT DISTINCT
  4112. t1.beh_dept_name AS behDeptName,
  4113. t1.beh_doctor_name AS doctorName,
  4114. t1.`name` AS patName,
  4115. t1.behospital_code AS behospitalCode,
  4116. t1.behospital_date AS behospitalDate,
  4117. t1.leave_hospital_date AS leaveHospitalDate,
  4118. t2.score_res AS score,
  4119. "1" AS avgScore,
  4120. t4.`name` AS caseName,
  4121. t3.msg AS msg
  4122. FROM
  4123. med_behospital_info t1,
  4124. med_qcresult_info t2,
  4125. med_qcresult_detail t3,
  4126. qc_cases t4
  4127. WHERE
  4128. t1.is_deleted = 'N'
  4129. AND t2.is_deleted = 'N'
  4130. AND t3.is_deleted = 'N'
  4131. AND t4.is_deleted = 'N'
  4132. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  4133. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  4134. AND t1.hospital_id = t2.hospital_id
  4135. AND t1.behospital_code = t2.behospital_code
  4136. AND t1.hospital_id = t3.hospital_id
  4137. AND t1.behospital_code = t3.behospital_code
  4138. AND t3.cases_id = t4.id
  4139. ORDER BY
  4140. t1.beh_dept_id ASC,
  4141. t1.leave_hospital_date DESC,
  4142. t1.behospital_code ASC,
  4143. t4.`name` ASC
  4144. </select>
  4145. <!-- 质控评分导出到excel-->
  4146. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4147. SELECT * FROM (
  4148. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4149. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4150. g.check_type AS ch_type,
  4151. h.check_type AS mr_type,
  4152. g.check_name AS ch_name,
  4153. h.check_name AS mr_name,
  4154. g.check_time AS ch_time,
  4155. h.check_time AS mr_time
  4156. FROM (
  4157. SELECT
  4158. t1.behDeptId,
  4159. t1.behDeptName,
  4160. t1.doctorName,
  4161. t1.patName,
  4162. t1.behospitalCode,
  4163. t1.hospitalId,
  4164. t1.behospitalDate,
  4165. t1.leaveHospitalDate,
  4166. t1.score,
  4167. <if test="radioCheck !=null and radioCheck == 1">
  4168. t1.msg,
  4169. t1.caseName,
  4170. </if>
  4171. t1.scoreBn,
  4172. t2.avgScore
  4173. FROM
  4174. (
  4175. SELECT
  4176. a.doctor_name AS doctorName,
  4177. a.`name` AS patName,
  4178. a.behospital_code AS behospitalCode,
  4179. a.behospital_date AS behospitalDate,
  4180. a.leave_hospital_date AS leaveHospitalDate,
  4181. b.score_res AS score,
  4182. e.score_res as scoreBn,
  4183. <if test="radioCheck !=null and radioCheck == 1">
  4184. c.msg AS msg,
  4185. d.NAME AS caseName,
  4186. </if>
  4187. a.beh_dept_id AS behDeptId,
  4188. a.beh_dept_name AS behDeptName,
  4189. a.hospital_id AS hospitalId
  4190. FROM
  4191. med_behospital_info a
  4192. RIGHT JOIN
  4193. med_qcresult_info b
  4194. ON a.hospital_id = b.hospital_id
  4195. AND a.is_deleted = 'N'
  4196. AND b.is_deleted = 'N'
  4197. AND a.behospital_code = b.behospital_code
  4198. <if test="radioCheck !=null and radioCheck == 1">
  4199. LEFT JOIN
  4200. med_qcresult_detail c
  4201. ON c.is_deleted = 'N'
  4202. AND b.behospital_code = c.behospital_code
  4203. AND b.hospital_id = c.hospital_id
  4204. LEFT JOIN
  4205. qc_cases d
  4206. on d.is_deleted = 'N'
  4207. AND c.cases_id = d.id
  4208. </if>
  4209. LEFT JOIN med_qcresult_cases e
  4210. on b.behospital_code = e.behospital_code
  4211. and b.hospital_id = e.hospital_id
  4212. AND e.is_deleted = 'N'
  4213. and e.cases_id = 243
  4214. WHERE
  4215. 1=1
  4216. <if test="isPlacefile != null and isPlacefile != ''">
  4217. and a.is_placefile = #{isPlacefile}
  4218. </if>
  4219. <![CDATA[AND a.qc_type_id <>0 ]]>
  4220. <if test="hospitalId != null and hospitalId != ''">
  4221. AND a.hospital_id = #{hospitalId}
  4222. </if>
  4223. <if test="diagnose != null and diagnose != ''">
  4224. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4225. </if>
  4226. <if test="behosDateStart != null">
  4227. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4228. </if>
  4229. <if test="behosDateEnd != null">
  4230. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4231. </if>
  4232. <if test="leaveHosDateStart != null ">
  4233. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4234. </if>
  4235. <if test="leaveHosDateEnd != null ">
  4236. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4237. </if>
  4238. <if test="behospitalCode != null and behospitalCode != ''">
  4239. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4240. </if>
  4241. <if test="level != null and level != ''">
  4242. AND b.level = #{level}
  4243. </if>
  4244. <if test="doctorName != null and doctorName != ''">
  4245. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4246. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4247. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4248. </if>
  4249. <if test="doctorCode != null and doctorCode != ''">
  4250. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4251. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4252. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4253. </if>
  4254. <if test="deptName != null and deptName != ''">
  4255. and a.beh_dept_name = #{deptName}
  4256. </if>
  4257. <if test="name != null and name != ''">
  4258. AND a.name like CONCAT('%',#{name},'%')
  4259. </if>
  4260. ) t1,
  4261. (
  4262. SELECT
  4263. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4264. a.beh_dept_id AS behDeptId,
  4265. a.beh_dept_name AS behDeptName
  4266. FROM
  4267. med_behospital_info a,
  4268. med_qcresult_info b
  4269. WHERE
  4270. a.is_deleted = 'N'
  4271. AND b.is_deleted = 'N'
  4272. AND a.hospital_id = b.hospital_id
  4273. AND a.behospital_code = b.behospital_code
  4274. <if test="isPlacefile != null and isPlacefile != ''">
  4275. and a.is_placefile = #{isPlacefile}
  4276. </if>
  4277. <![CDATA[AND a.qc_type_id <>0 ]]>
  4278. <if test="hospitalId != null and hospitalId != ''">
  4279. AND a.hospital_id = #{hospitalId}
  4280. </if>
  4281. <if test="diagnose != null and diagnose != ''">
  4282. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4283. </if>
  4284. <if test="behosDateStart != null">
  4285. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4286. </if>
  4287. <if test="behosDateEnd != null">
  4288. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4289. </if>
  4290. <if test="leaveHosDateStart != null ">
  4291. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4292. </if>
  4293. <if test="leaveHosDateEnd != null ">
  4294. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4295. </if>
  4296. <if test="behospitalCode != null and behospitalCode != ''">
  4297. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4298. </if>
  4299. <if test="level != null and level != ''">
  4300. AND b.level = #{level}
  4301. </if>
  4302. <if test="doctorName != null and doctorName != ''">
  4303. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4304. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4305. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4306. </if>
  4307. <if test="doctorCode != null and doctorCode != ''">
  4308. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4309. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4310. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4311. </if>
  4312. <if test="deptName != null and deptName != ''">
  4313. and a.beh_dept_name = #{deptName}
  4314. </if>
  4315. <if test="name != null and name != ''">
  4316. AND a.name like CONCAT('%',#{name},'%')
  4317. </if>
  4318. GROUP BY
  4319. a.beh_dept_id,
  4320. a.beh_dept_name
  4321. ) t2
  4322. WHERE
  4323. t1.behDeptId = t2.behDeptId
  4324. AND t1.behDeptName = t2.behDeptName
  4325. ORDER BY
  4326. t1.behDeptName,
  4327. t1.doctorName,
  4328. t1.patName,
  4329. <if test="radioCheck !=null and radioCheck == 1">
  4330. t1.caseName,
  4331. </if>
  4332. t1.behospitalCode
  4333. )tp
  4334. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4335. ON tp.behospitalCode = g.behospital_code
  4336. AND tp.hospitalId = g.hospital_id
  4337. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4338. ON tp.behospitalCode = h.behospital_code
  4339. AND tp.hospitalId = h.hospital_id
  4340. ) tu
  4341. WHERE tu.behospitalCode IS NOT NULL
  4342. <if test="checkStatus != null ">
  4343. and tu.check_status = #{checkStatus}
  4344. </if>
  4345. <if test="mrStatus != null ">
  4346. AND tu.mr_status = #{mrStatus}
  4347. </if>
  4348. <if test="chName != null and chName !=''">
  4349. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4350. </if>
  4351. <if test="mrName != null and mrName !=''">
  4352. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4353. </if>
  4354. <if test="chTimeStart != null">
  4355. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4356. </if>
  4357. <if test="chTimeEnd != null">
  4358. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4359. </if>
  4360. <if test="mrTimeStart != null">
  4361. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4362. </if>
  4363. <if test="mrTimeEnd != null">
  4364. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4365. </if>
  4366. </select>
  4367. <!-- 科室质控评分导出到excel-->
  4368. <select id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4369. SELECT * FROM (
  4370. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4371. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4372. g.check_type AS ch_type,
  4373. h.check_type AS mr_type,
  4374. g.check_name AS ch_name,
  4375. h.check_name AS mr_name,
  4376. g.check_time AS ch_time,
  4377. h.check_time AS mr_time
  4378. FROM (
  4379. SELECT
  4380. t1.behDeptId,
  4381. t1.behDeptName,
  4382. t1.doctorName,
  4383. t1.patName,
  4384. t1.behospitalCode,
  4385. t1.hospitalId,
  4386. t1.behospitalDate,
  4387. t1.leaveHospitalDate,
  4388. t1.score,
  4389. t2.avgScore,
  4390. <if test="radioCheck !=null and radioCheck == 1">
  4391. t1.msg,
  4392. t1.caseName,
  4393. </if>
  4394. e.score_res as scoreBn
  4395. FROM
  4396. (
  4397. SELECT
  4398. a.doctor_name AS doctorName,
  4399. a.`name` AS patName,
  4400. a.behospital_code AS behospitalCode,
  4401. a.hospital_id AS hospital_id,
  4402. a.behospital_date AS behospitalDate,
  4403. a.leave_hospital_date AS leaveHospitalDate,
  4404. b.score_res AS score,
  4405. <if test="radioCheck !=null and radioCheck == 1">
  4406. c.msg AS msg,
  4407. d.NAME AS caseName,
  4408. </if>
  4409. a.beh_dept_id AS behDeptId,
  4410. a.beh_dept_name AS behDeptName,
  4411. a.hospital_id AS hospitalId
  4412. FROM
  4413. med_behospital_info a,
  4414. med_qcresult_info b,
  4415. med_qcresult_detail c,
  4416. qc_cases d,
  4417. sys_user_dept e
  4418. WHERE
  4419. a.is_deleted = 'N'
  4420. AND b.is_deleted = 'N'
  4421. AND c.is_deleted = 'N'
  4422. AND d.is_deleted = 'N'
  4423. AND e.is_deleted = 'N'
  4424. AND a.hospital_id = b.hospital_id
  4425. AND a.hospital_id = c.hospital_id
  4426. AND a.hospital_id = e.hospital_id
  4427. AND a.behospital_code = b.behospital_code
  4428. AND a.behospital_code = c.behospital_code
  4429. AND c.cases_id = d.id
  4430. AND a.beh_dept_id = e.dept_id
  4431. <if test="diagnose != null and diagnose != ''">
  4432. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4433. </if>
  4434. <if test="isPlacefile != null and isPlacefile != ''">
  4435. and a.is_placefile = #{isPlacefile}
  4436. </if>
  4437. <![CDATA[AND a.qc_type_id <>0 ]]>
  4438. <if test="hospitalId != null and hospitalId != ''">
  4439. AND a.hospital_id = #{hospitalId}
  4440. </if>
  4441. <if test="userId != null ">
  4442. AND e.user_id = #{userId}
  4443. </if>
  4444. <if test="behosDateStart != null">
  4445. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4446. </if>
  4447. <if test="behosDateEnd != null">
  4448. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4449. </if>
  4450. <if test="leaveHosDateStart != null ">
  4451. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4452. </if>
  4453. <if test="leaveHosDateEnd != null ">
  4454. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4455. </if>
  4456. <if test="behospitalCode != null and behospitalCode != ''">
  4457. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4458. </if>
  4459. <if test="level != null and level != ''">
  4460. AND b.level = #{level}
  4461. </if>
  4462. <if test="doctorName != null and doctorName != ''">
  4463. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4464. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4465. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4466. </if>
  4467. <if test="doctorCode != null and doctorCode != ''">
  4468. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4469. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4470. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4471. </if>
  4472. <if test="deptName != null and deptName != ''">
  4473. and a.beh_dept_name = #{deptName}
  4474. </if>
  4475. <if test="name != null and name != ''">
  4476. AND a.name like CONCAT('%',#{name},'%')
  4477. </if>
  4478. ) t1
  4479. LEFT JOIN med_qcresult_cases e
  4480. on t1.behospitalCode = e.behospital_code
  4481. and t1.hospital_id = e.hospital_id
  4482. AND e.is_deleted = 'N'
  4483. and e.cases_id = 243,
  4484. (
  4485. SELECT
  4486. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4487. a.beh_dept_id AS behDeptId,
  4488. a.beh_dept_name AS behDeptName
  4489. FROM
  4490. med_behospital_info a,
  4491. med_qcresult_info b,
  4492. sys_user_dept c
  4493. WHERE
  4494. a.is_deleted = 'N'
  4495. AND b.is_deleted = 'N'
  4496. AND c.is_deleted = 'N'
  4497. AND a.hospital_id = b.hospital_id
  4498. AND a.hospital_id = c.hospital_id
  4499. AND a.behospital_code = b.behospital_code
  4500. AND a.beh_dept_id = c.dept_id
  4501. <if test="diagnose != null and diagnose != ''">
  4502. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4503. </if>
  4504. <if test="isPlacefile != null and isPlacefile != ''">
  4505. and a.is_placefile = #{isPlacefile}
  4506. </if>
  4507. <![CDATA[AND a.qc_type_id <>0 ]]>
  4508. <if test="hospitalId != null and hospitalId != ''">
  4509. AND a.hospital_id = #{hospitalId}
  4510. </if>
  4511. <if test="userId != null ">
  4512. AND c.user_id = #{userId}
  4513. </if>
  4514. <if test="behosDateStart != null">
  4515. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4516. </if>
  4517. <if test="behosDateEnd != null">
  4518. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4519. </if>
  4520. <if test="leaveHosDateStart != null ">
  4521. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4522. </if>
  4523. <if test="leaveHosDateEnd != null ">
  4524. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4525. </if>
  4526. <if test="behospitalCode != null and behospitalCode != ''">
  4527. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4528. </if>
  4529. <if test="level != null and level != ''">
  4530. AND b.level = #{level}
  4531. </if>
  4532. <if test="doctorName != null and doctorName != ''">
  4533. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4534. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4535. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4536. </if>
  4537. <if test="doctorCode != null and doctorCode != ''">
  4538. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4539. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4540. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4541. </if>
  4542. <if test="deptName != null and deptName != ''">
  4543. and a.beh_dept_name = #{deptName}
  4544. </if>
  4545. <if test="name != null and name != ''">
  4546. AND a.name like CONCAT('%',#{name},'%')
  4547. </if>
  4548. GROUP BY
  4549. a.beh_dept_id,
  4550. a.beh_dept_name
  4551. ) t2
  4552. WHERE
  4553. t1.behDeptId = t2.behDeptId
  4554. AND t1.behDeptName = t2.behDeptName
  4555. ORDER BY
  4556. t1.behDeptName,
  4557. t1.doctorName,
  4558. t1.patName,
  4559. <if test="radioCheck !=null and radioCheck == 1">
  4560. t1.caseName,
  4561. </if>
  4562. t1.behospitalCode
  4563. )tp
  4564. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4565. ON tp.behospitalCode = g.behospital_code
  4566. AND tp.hospitalId = g.hospital_id
  4567. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4568. ON tp.behospitalCode = h.behospital_code
  4569. AND tp.hospitalId = h.hospital_id
  4570. ) tu
  4571. WHERE tu.behospitalCode IS NOT NULL
  4572. <if test="checkStatus != null ">
  4573. and tu.check_status = #{checkStatus}
  4574. </if>
  4575. <if test="mrStatus != null ">
  4576. AND tu.mr_status = #{mrStatus}
  4577. </if>
  4578. <if test="chName != null and chName !=''">
  4579. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4580. </if>
  4581. <if test="mrName != null and mrName !=''">
  4582. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4583. </if>
  4584. <if test="chTimeStart != null">
  4585. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4586. </if>
  4587. <if test="chTimeEnd != null">
  4588. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4589. </if>
  4590. <if test="mrTimeStart != null">
  4591. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4592. </if>
  4593. <if test="mrTimeEnd != null">
  4594. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4595. </if>
  4596. </select>
  4597. <!-- 个人质控评分导出到excel-->
  4598. <select id="exportQcresultByPerson" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4599. SELECT * FROM (
  4600. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4601. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4602. g.check_type AS ch_type,
  4603. h.check_type AS mr_type,
  4604. g.check_name AS ch_name,
  4605. h.check_name AS mr_name,
  4606. g.check_time AS ch_time,
  4607. h.check_time AS mr_time
  4608. FROM (
  4609. SELECT
  4610. t1.behDeptId,
  4611. t1.behDeptName,
  4612. t1.doctorName,
  4613. t1.patName,
  4614. t1.behospitalCode,
  4615. t1.hospitalId,
  4616. t1.behospitalDate,
  4617. t1.leaveHospitalDate,
  4618. t1.score,
  4619. t2.avgScore,
  4620. <if test="radioCheck !=null and radioCheck == 1">
  4621. t1.msg,
  4622. t1.caseName,
  4623. </if>
  4624. e.score_res as scoreBn
  4625. FROM
  4626. (
  4627. SELECT
  4628. a.doctor_name AS doctorName,
  4629. a.beh_doctor_name,
  4630. a.director_doctor_name,
  4631. a.`name` AS patName,
  4632. a.behospital_code AS behospitalCode,
  4633. a.behospital_date AS behospitalDate,
  4634. a.leave_hospital_date AS leaveHospitalDate,
  4635. b.score_res AS score,
  4636. <if test="radioCheck !=null and radioCheck == 1">
  4637. c.msg AS msg,
  4638. d.NAME AS caseName,
  4639. </if>
  4640. a.beh_dept_id AS behDeptId,
  4641. a.beh_dept_name AS behDeptName,
  4642. a.hospital_id AS hospitalId
  4643. FROM
  4644. med_behospital_info a,
  4645. med_qcresult_info b,
  4646. med_qcresult_detail c,
  4647. qc_cases d,
  4648. sys_user u,
  4649. sys_user_hospital uh
  4650. WHERE
  4651. a.is_deleted = 'N'
  4652. AND b.is_deleted = 'N'
  4653. AND c.is_deleted = 'N'
  4654. AND d.is_deleted = 'N'
  4655. AND u.is_deleted = 'N'
  4656. AND uh.is_deleted = 'N'
  4657. AND a.hospital_id = b.hospital_id
  4658. AND a.hospital_id = c.hospital_id
  4659. AND a.behospital_code = b.behospital_code
  4660. AND a.behospital_code = c.behospital_code
  4661. AND u.id = uh.user_id
  4662. AND a.hospital_id = uh.hospital_id
  4663. <if test="userId != null and userId != ''">
  4664. AND u.id = #{userId}
  4665. </if>
  4666. <if test="isPlacefile != null and isPlacefile != ''">
  4667. and a.is_placefile = #{isPlacefile}
  4668. </if>
  4669. <![CDATA[AND a.qc_type_id <>0 ]]>
  4670. <if test="hospitalId != null and hospitalId != ''">
  4671. AND a.hospital_id = #{hospitalId}
  4672. </if>
  4673. <if test="diagnose != null and diagnose != ''">
  4674. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4675. </if>
  4676. <if test="behosDateStart != null">
  4677. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4678. </if>
  4679. <if test="behosDateEnd != null">
  4680. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4681. </if>
  4682. <if test="leaveHosDateStart != null ">
  4683. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4684. </if>
  4685. <if test="leaveHosDateEnd != null ">
  4686. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4687. </if>
  4688. <if test="behospitalCode != null and behospitalCode != ''">
  4689. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4690. </if>
  4691. <if test="level != null and level != ''">
  4692. AND b.level = #{level}
  4693. </if>
  4694. <if test="doctorName != null and doctorName != ''">
  4695. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4696. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4697. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4698. </if>
  4699. <if test="doctorCode != null and doctorCode != ''">
  4700. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4701. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4702. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4703. </if>
  4704. <if test="deptId != null and deptId != ''">
  4705. AND a.beh_dept_id = #{deptId}
  4706. </if>
  4707. <if test="deptName != null and deptName != ''">
  4708. and a.beh_dept_name = #{deptName}
  4709. </if>
  4710. <if test="name != null and name != ''">
  4711. AND a.name like CONCAT('%',#{name},'%')
  4712. </if>
  4713. ) t1 LEFT JOIN med_qcresult_cases e
  4714. on t1.behospitalCode = e.behospital_code
  4715. and t1.hospitalId = e.hospital_id
  4716. AND e.is_deleted = 'N'
  4717. and e.cases_id = 243,
  4718. (
  4719. SELECT
  4720. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4721. a.beh_dept_id AS behDeptId,
  4722. a.beh_dept_name AS behDeptName
  4723. FROM
  4724. med_behospital_info a,
  4725. med_qcresult_info b,
  4726. sys_user u,
  4727. sys_user_hospital uh
  4728. WHERE
  4729. a.is_deleted = 'N'
  4730. AND b.is_deleted = 'N'
  4731. AND u.is_deleted = 'N'
  4732. AND uh.is_deleted = 'N'
  4733. AND a.hospital_id = b.hospital_id
  4734. AND a.behospital_code = b.behospital_code
  4735. AND u.id = uh.user_id
  4736. AND a.hospital_id = uh.hospital_id
  4737. and (a.doctor_name = u.linkman
  4738. or a.beh_doctor_name = u.linkman
  4739. or a.director_doctor_name = u.linkman)
  4740. <if test="userId != null and userId != ''">
  4741. AND u.id = #{userId}
  4742. </if>
  4743. <if test="diagnose != null and diagnose != ''">
  4744. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4745. </if>
  4746. <if test="isPlacefile != null and isPlacefile != ''">
  4747. and a.is_placefile = #{isPlacefile}
  4748. </if>
  4749. <![CDATA[AND a.qc_type_id <>0 ]]>
  4750. <if test="hospitalId != null and hospitalId != ''">
  4751. AND a.hospital_id = #{hospitalId}
  4752. </if>
  4753. <if test="behosDateStart != null">
  4754. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4755. </if>
  4756. <if test="behosDateEnd != null">
  4757. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4758. </if>
  4759. <if test="leaveHosDateStart != null ">
  4760. <![CDATA[ and a.leave_hospital_date >= #{leaveHosDateStart}]]>
  4761. </if>
  4762. <if test="leaveHosDateEnd != null ">
  4763. <![CDATA[AND a.leave_hospital_date < #{leaveHosDateEnd}]]>
  4764. </if>
  4765. <if test="behospitalCode != null and behospitalCode != ''">
  4766. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4767. </if>
  4768. <if test="level != null and level != ''">
  4769. AND b.level = #{level}
  4770. </if>
  4771. <if test="doctorName != null and doctorName != ''">
  4772. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4773. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4774. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4775. </if>
  4776. <if test="doctorCode != null and doctorCode != ''">
  4777. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4778. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4779. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4780. </if>
  4781. <if test="deptId != null and deptId != ''">
  4782. AND a.beh_dept_id = #{deptId}
  4783. </if>
  4784. <if test="deptName != null and deptName != ''">
  4785. and a.beh_dept_name = #{deptName}
  4786. </if>
  4787. <if test="name != null and name != ''">
  4788. AND a.name like CONCAT('%',#{name},'%')
  4789. </if>
  4790. ) t2
  4791. WHERE
  4792. t1.behDeptId = t2.behDeptId
  4793. AND t1.behDeptName = t2.behDeptName
  4794. ORDER BY
  4795. t1.behDeptName,
  4796. t1.doctorName,
  4797. t1.patName,
  4798. <if test="radioCheck !=null and radioCheck == 1">
  4799. t1.caseName,
  4800. </if>
  4801. t1.behospitalCode
  4802. )tp
  4803. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  4804. ON tp.behospitalCode = g.behospital_code
  4805. AND tp.hospitalId = g.hospital_id
  4806. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  4807. ON tp.behospitalCode = h.behospital_code
  4808. AND tp.hospitalId = h.hospital_id
  4809. ) tu
  4810. WHERE tu.behospitalCode IS NOT NULL
  4811. <if test="checkStatus != null ">
  4812. and tu.check_status = #{checkStatus}
  4813. </if>
  4814. <if test="mrStatus != null ">
  4815. AND tu.mr_status = #{mrStatus}
  4816. </if>
  4817. <if test="chName != null and chName !=''">
  4818. AND tu.ch_name like CONCAT('%',#{chName},'%')
  4819. </if>
  4820. <if test="mrName != null and mrName !=''">
  4821. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  4822. </if>
  4823. <if test="chTimeStart != null">
  4824. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  4825. </if>
  4826. <if test="chTimeEnd != null">
  4827. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  4828. </if>
  4829. <if test="mrTimeStart != null">
  4830. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  4831. </if>
  4832. <if test="mrTimeEnd != null">
  4833. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  4834. </if>
  4835. </select>
  4836. <!-- 医疗组质控评分导出到excel-->
  4837. <select id="exportQcresultByGroup" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  4838. SELECT * FROM (
  4839. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  4840. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  4841. g.check_type AS ch_type,
  4842. h.check_type AS mr_type,
  4843. g.check_name AS ch_name,
  4844. h.check_name AS mr_name,
  4845. g.check_time AS ch_time,
  4846. h.check_time AS mr_time
  4847. FROM (
  4848. SELECT
  4849. t1.behDeptId,
  4850. t1.behDeptName,
  4851. t1.doctorName,
  4852. t1.patName,
  4853. t1.behospitalCode,
  4854. t1.hospitalId,
  4855. t1.behospitalDate,
  4856. t1.leaveHospitalDate,
  4857. t1.score,
  4858. t2.avgScore,
  4859. <if test="radioCheck !=null and radioCheck == 1">
  4860. t1.msg,
  4861. t1.caseName,
  4862. </if>
  4863. e.score_res as scoreBn
  4864. FROM
  4865. (
  4866. SELECT
  4867. a.doctor_name AS doctorName,
  4868. a.`name` AS patName,
  4869. a.behospital_code AS behospitalCode,
  4870. a.behospital_date AS behospitalDate,
  4871. a.leave_hospital_date AS leaveHospitalDate,
  4872. b.score_res AS score,
  4873. <if test="radioCheck !=null and radioCheck == 1">
  4874. c.msg AS msg,
  4875. d.NAME AS caseName,
  4876. </if>
  4877. a.beh_dept_id AS behDeptId,
  4878. a.beh_dept_name AS behDeptName,
  4879. a.hospital_id AS hospitalId
  4880. FROM
  4881. med_behospital_info a,
  4882. med_qcresult_info b,
  4883. med_qcresult_detail c,
  4884. qc_cases d
  4885. WHERE
  4886. a.is_deleted = 'N'
  4887. AND b.is_deleted = 'N'
  4888. AND c.is_deleted = 'N'
  4889. AND d.is_deleted = 'N'
  4890. AND a.hospital_id = b.hospital_id
  4891. AND a.hospital_id = c.hospital_id
  4892. AND a.behospital_code = b.behospital_code
  4893. AND a.behospital_code = c.behospital_code
  4894. AND c.cases_id = d.id
  4895. <if test="isPlacefile != null and isPlacefile != ''">
  4896. and a.is_placefile = #{isPlacefile}
  4897. </if>
  4898. AND a.doctor_id in
  4899. (SELECT doctor_id FROM `bas_doctor_info`
  4900. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  4901. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  4902. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  4903. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  4904. and c1.username = c3.doctor_id
  4905. and c2.hospital_id = #{hospitalId}
  4906. and c1.id = #{userId}
  4907. ))
  4908. <![CDATA[AND a.qc_type_id <>0 ]]>
  4909. <if test="hospitalId != null and hospitalId != ''">
  4910. AND a.hospital_id = #{hospitalId}
  4911. </if>
  4912. <if test="diagnose != null and diagnose != ''">
  4913. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4914. </if>
  4915. <if test="behosDateStart != null">
  4916. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4917. </if>
  4918. <if test="behosDateEnd != null">
  4919. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4920. </if>
  4921. <if test="leaveHosDateStart != null ">
  4922. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4923. </if>
  4924. <if test="leaveHosDateEnd != null ">
  4925. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4926. </if>
  4927. <if test="behospitalCode != null and behospitalCode != ''">
  4928. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  4929. </if>
  4930. <if test="level != null and level != ''">
  4931. AND b.level = #{level}
  4932. </if>
  4933. <if test="doctorName != null and doctorName != ''">
  4934. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  4935. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  4936. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  4937. </if>
  4938. <if test="doctorCode != null and doctorCode != ''">
  4939. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  4940. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  4941. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  4942. </if>
  4943. <if test="deptId != null and deptId != ''">
  4944. AND a.beh_dept_id = #{deptId}
  4945. </if>
  4946. <if test="name != null and name != ''">
  4947. AND a.name like CONCAT('%',#{name},'%')
  4948. </if>
  4949. ) t1 LEFT JOIN med_qcresult_cases e
  4950. on t1.behospitalCode = e.behospital_code
  4951. and t1.hospitalId = e.hospital_id
  4952. AND e.is_deleted = 'N'
  4953. and e.cases_id = 243,
  4954. (
  4955. SELECT
  4956. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  4957. a.beh_dept_id AS behDeptId,
  4958. a.beh_dept_name AS behDeptName
  4959. FROM
  4960. med_behospital_info a,
  4961. med_qcresult_info b
  4962. WHERE
  4963. a.is_deleted = 'N'
  4964. AND a.doctor_id in
  4965. (SELECT doctor_id FROM `bas_doctor_info`
  4966. where is_deleted = 'N' and hospital_id = #{hospitalId} and group_id in (
  4967. select c3.group_id from sys_user c1, sys_user_hospital c2, bas_doctor_info c3
  4968. where c1.is_deleted = 'N' and c2.is_deleted = 'N' and c3.is_deleted = 'N'
  4969. and c1.id = c2.user_id and c2.hospital_id = c3.hospital_id
  4970. and c1.username = c3.doctor_id
  4971. and c2.hospital_id = #{hospitalId}
  4972. and c1.id = #{userId}
  4973. ))
  4974. AND b.is_deleted = 'N'
  4975. AND a.hospital_id = b.hospital_id
  4976. AND a.behospital_code = b.behospital_code
  4977. <if test="diagnose != null and diagnose != ''">
  4978. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  4979. </if>
  4980. <if test="isPlacefile != null and isPlacefile != ''">
  4981. and a.is_placefile = #{isPlacefile}
  4982. </if>
  4983. <![CDATA[AND a.qc_type_id <>0 ]]>
  4984. <if test="hospitalId != null and hospitalId != ''">
  4985. AND a.hospital_id = #{hospitalId}
  4986. </if>
  4987. <if test="behosDateStart != null">
  4988. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  4989. </if>
  4990. <if test="behosDateEnd != null">
  4991. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  4992. </if>
  4993. <if test="leaveHosDateStart != null ">
  4994. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  4995. </if>
  4996. <if test="leaveHosDateEnd != null ">
  4997. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  4998. </if>
  4999. <if test="behospitalCode != null and behospitalCode != ''">
  5000. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  5001. </if>
  5002. <if test="level != null and level != ''">
  5003. AND b.level = #{level}
  5004. </if>
  5005. <if test="doctorName != null and doctorName != ''">
  5006. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  5007. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  5008. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  5009. </if>
  5010. <if test="doctorCode != null and doctorCode != ''">
  5011. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  5012. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  5013. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  5014. </if>
  5015. <if test="deptId != null and deptId != ''">
  5016. AND a.beh_dept_id = #{deptId}
  5017. </if>
  5018. <if test="name != null and name != ''">
  5019. AND a.name like CONCAT('%',#{name},'%')
  5020. </if>
  5021. GROUP BY
  5022. a.beh_dept_id,
  5023. a.beh_dept_name
  5024. ) t2
  5025. WHERE
  5026. t1.behDeptId = t2.behDeptId
  5027. AND t1.behDeptName = t2.behDeptName
  5028. ORDER BY
  5029. t1.behDeptName,
  5030. t1.doctorName,
  5031. t1.patName,
  5032. <if test="radioCheck !=null and radioCheck == 1">
  5033. t1.caseName,
  5034. </if>
  5035. t1.behospitalCode
  5036. )tp
  5037. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  5038. ON tp.behospitalCode = g.behospital_code
  5039. AND tp.hospitalId = g.hospital_id
  5040. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  5041. ON tp.behospitalCode = h.behospital_code
  5042. AND tp.hospitalId = h.hospital_id
  5043. ) tu
  5044. WHERE tu.behospitalCode IS NOT NULL
  5045. <if test="checkStatus != null ">
  5046. and tu.check_status = #{checkStatus}
  5047. </if>
  5048. <if test="mrStatus != null ">
  5049. AND tu.mr_status = #{mrStatus}
  5050. </if>
  5051. <if test="chName != null and chName !=''">
  5052. AND tu.ch_name like CONCAT('%',#{chName},'%')
  5053. </if>
  5054. <if test="mrName != null and mrName !=''">
  5055. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  5056. </if>
  5057. <if test="chTimeStart != null">
  5058. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  5059. </if>
  5060. <if test="chTimeEnd != null">
  5061. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  5062. </if>
  5063. <if test="mrTimeStart != null">
  5064. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  5065. </if>
  5066. <if test="mrTimeEnd != null">
  5067. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  5068. </if>
  5069. </select>
  5070. <!-- 条目缺陷质控评分页(内页)-->
  5071. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5072. SELECT t.*
  5073. FROM
  5074. (SELECT DISTINCT
  5075. t1.hospital_id AS hospitalId,
  5076. t1.behospital_code AS behospitalCode,
  5077. t1.bed_code AS bedCode,
  5078. t1.LEVEL AS LEVEL,
  5079. t1.grade_type AS gradeType,
  5080. t1.score_res AS scoreRes,
  5081. t1.scoreBn,
  5082. t1.NAME AS NAME,
  5083. t1.sex AS sex,
  5084. t1.beh_dept_id AS behDeptId,
  5085. t1.beh_dept_name AS behDeptName,
  5086. t1.doctor_id AS doctorId,
  5087. t1.doctor_name AS doctorName,
  5088. t1.beh_doctor_id AS behDoctorId,
  5089. t1.beh_doctor_name AS behDoctorName,
  5090. t1.director_doctor_id AS directorDoctorId,
  5091. t1.director_doctor_name AS directorDoctorName,
  5092. t1.birthday AS birthday,
  5093. t1.behospital_date AS behospitalDate,
  5094. t1.leave_hospital_date AS leaveHospitalDate,
  5095. t1.placefile_date AS placefileDate,
  5096. t1.gmt_create AS gradeTime,
  5097. t1.diagnose,
  5098. t1.ward_name AS wardName,
  5099. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5100. t1.file_code AS fileCode,
  5101. t1.checkStatus,
  5102. t1.mrStatus,
  5103. t1.chName,
  5104. t1.mrName,
  5105. t1.chTime,
  5106. t1.mrTime
  5107. FROM
  5108. (
  5109. SELECT DISTINCT
  5110. tt1.*
  5111. FROM
  5112. (SELECT
  5113. be.*,
  5114. ifnull(mci.status,0) AS checkStatus,
  5115. ifnull(hm_mci.status,0) AS mrStatus,
  5116. mci.check_name as chName,
  5117. e.score_res as scoreBn,
  5118. hm_mci.check_name as mrName,
  5119. mci.gmt_create as chTime,
  5120. hm_mci.gmt_create as mrTime
  5121. FROM
  5122. (
  5123. SELECT DISTINCT
  5124. a.hospital_id,
  5125. a.behospital_code,
  5126. a.bed_code,
  5127. a.file_code,
  5128. b.LEVEL,
  5129. b.grade_type,
  5130. b.score_res,
  5131. a.NAME,
  5132. a.sex,
  5133. a.beh_dept_id,
  5134. a.beh_dept_name,
  5135. a.birthday,
  5136. a.behospital_date,
  5137. a.leave_hospital_date,
  5138. a.doctor_id,
  5139. a.doctor_name,
  5140. a.beh_doctor_id,
  5141. a.beh_doctor_name,
  5142. a.director_doctor_id,
  5143. a.director_doctor_name,
  5144. a.diagnose,
  5145. a.placefile_date,
  5146. a.ward_name,
  5147. b.gmt_create
  5148. FROM
  5149. med_behospital_info a,
  5150. med_qcresult_info b,
  5151. med_qcresult_detail c,
  5152. qc_cases_entry d
  5153. WHERE
  5154. a.is_deleted = 'N'
  5155. AND b.is_deleted = 'N'
  5156. AND c.is_deleted = 'N'
  5157. AND d.is_deleted = 'N'
  5158. AND a.hospital_id = b.hospital_id
  5159. AND a.hospital_id = c.hospital_id
  5160. AND a.behospital_code = b.behospital_code
  5161. AND a.behospital_code = c.behospital_code
  5162. AND c.cases_id = d.cases_id
  5163. AND c.cases_entry_id = d.id
  5164. AND a.qc_type_id != 0
  5165. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5166. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5167. </if>
  5168. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5169. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5170. </if>
  5171. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5172. <if test="qcResultShortPageVO.startDate != null ">
  5173. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5174. </if>
  5175. <if test="qcResultShortPageVO.endDate != null ">
  5176. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5177. </if>
  5178. </if>
  5179. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5180. <if test="qcResultShortPageVO.startDate != null ">
  5181. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5182. </if>
  5183. <if test="qcResultShortPageVO.endDate != null">
  5184. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5185. </if>
  5186. </if>
  5187. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5188. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5189. </if>
  5190. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5191. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5192. </if>
  5193. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5194. AND b.`level` = #{qcResultShortPageVO.level}
  5195. </if>
  5196. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5197. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5198. </if>
  5199. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5200. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5201. </if>
  5202. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5203. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5204. </if>
  5205. <if test="qcResultShortPageVO.casesEntryId != null ">
  5206. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5207. </if>
  5208. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5209. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5210. </if>
  5211. <if test="qcResultShortPageVO.casesId != null">
  5212. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5213. </if>
  5214. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5215. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5216. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5217. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5218. </if>
  5219. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5220. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5221. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5222. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5223. </if>
  5224. <if test="qcResultShortPageVO.isReject != null">
  5225. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5226. </if>
  5227. <if test="qcResultShortPageVO.ruleType != null">
  5228. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5229. </if>
  5230. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5231. AND TIMESTAMPDIFF(
  5232. DAY,
  5233. DATE( a.behospital_date ),
  5234. DATE( a.leave_hospital_date ))> 30
  5235. </if>
  5236. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5237. AND TIMESTAMPDIFF(
  5238. DAY,
  5239. DATE( a.behospital_date ),
  5240. DATE( a.leave_hospital_date ))> 31
  5241. </if>
  5242. )be
  5243. left join med_check_info mci
  5244. on mci.is_deleted = 'N'
  5245. and mci.check_type = 0
  5246. and be.hospital_id = mci.hospital_id
  5247. and be.behospital_code = mci.behospital_code
  5248. left join med_check_info hm_mci
  5249. on hm_mci.is_deleted = 'N'
  5250. and hm_mci.check_type = 1
  5251. and be.hospital_id = hm_mci.hospital_id
  5252. and be.behospital_code = hm_mci.behospital_code
  5253. LEFT JOIN med_qcresult_cases e
  5254. on be.behospital_code = e.behospital_code
  5255. and be.hospital_id = e.hospital_id
  5256. AND e.is_deleted = 'N'
  5257. and e.cases_id = 243
  5258. )tt1
  5259. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5260. ,med_medical_record tt2
  5261. WHERE
  5262. tt2.is_deleted = 'N'
  5263. AND tt1.hospital_id = tt2.hospital_id
  5264. AND tt1.behospital_code = tt2.behospital_code
  5265. AND tt2.mode_id = 30
  5266. </if>
  5267. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5268. ,med_crisis_info tt2
  5269. WHERE
  5270. tt2.is_deleted = 'N'
  5271. AND tt1.hospital_id = tt2.hospital_id
  5272. AND tt1.behospital_code = tt2.behospital_code
  5273. </if>
  5274. ) t1
  5275. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5276. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5277. AND t1.behospital_code = t2.behospital_code
  5278. AND t2.is_deleted = 'N'
  5279. </if>
  5280. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5281. , med_home_page t2
  5282. , med_home_operation_info t3
  5283. WHERE t1.hospital_id = t2.hospital_id
  5284. AND t1.behospital_code = t2.behospital_code
  5285. AND t2.home_page_id = t3.home_page_id
  5286. AND t2.is_deleted = 'N'
  5287. AND t3.is_deleted = 'N'
  5288. </if>
  5289. ) t
  5290. where 1=1
  5291. <if test="qcResultShortPageVO.checkStatus != null">
  5292. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5293. </if>
  5294. <if test="qcResultShortPageVO.mrStatus != null">
  5295. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5296. </if>
  5297. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5298. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5299. </if>
  5300. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5301. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5302. </if>
  5303. <if test="qcResultShortPageVO.chTimeStart != null ">
  5304. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5305. </if>
  5306. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5307. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5308. </if>
  5309. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5310. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5311. </if>
  5312. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5313. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5314. </if>
  5315. </select>
  5316. <!-- 条目缺陷质控评分页-科室(内页)-->
  5317. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5318. SELECT t.*
  5319. FROM
  5320. (SELECT DISTINCT
  5321. t1.hospital_id AS hospitalId,
  5322. t1.behospital_code AS behospitalCode,
  5323. t1.bed_code AS bedCode,
  5324. t1.LEVEL AS LEVEL,
  5325. t1.grade_type AS gradeType,
  5326. t1.score_res AS scoreRes,
  5327. t1.scoreBn,
  5328. t1.NAME AS NAME,
  5329. t1.sex AS sex,
  5330. t1.beh_dept_id AS behDeptId,
  5331. t1.beh_dept_name AS behDeptName,
  5332. t1.doctor_id AS doctorId,
  5333. t1.doctor_name AS doctorName,
  5334. t1.beh_doctor_id AS behDoctorId,
  5335. t1.beh_doctor_name AS behDoctorName,
  5336. t1.director_doctor_id AS directorDoctorId,
  5337. t1.director_doctor_name AS directorDoctorName,
  5338. t1.birthday AS birthday,
  5339. t1.behospital_date AS behospitalDate,
  5340. t1.leave_hospital_date AS leaveHospitalDate,
  5341. t1.placefile_date AS placefileDate,
  5342. t1.gmt_create AS gradeTime,
  5343. t1.diagnose,
  5344. t1.ward_name AS wardName,
  5345. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  5346. t1.file_code AS fileCode,
  5347. t1.checkStatus,
  5348. t1.mrStatus,
  5349. t1.chName,
  5350. t1.mrName,
  5351. t1.chTime,
  5352. t1.mrTime
  5353. FROM
  5354. (
  5355. SELECT DISTINCT
  5356. tt1.*
  5357. FROM
  5358. (SELECT
  5359. be.*,
  5360. ifnull(mci.status,0) AS checkStatus,
  5361. ifnull(hm_mci.status,0) AS mrStatus,
  5362. mci.check_name as chName,
  5363. e.score_res as scoreBn,
  5364. hm_mci.check_name as mrName,
  5365. mci.gmt_create as chTime,
  5366. hm_mci.gmt_create as mrTime
  5367. FROM
  5368. (
  5369. SELECT DISTINCT
  5370. a.hospital_id,
  5371. a.behospital_code,
  5372. a.bed_code,
  5373. a.file_code,
  5374. b.LEVEL,
  5375. b.grade_type,
  5376. b.score_res,
  5377. a.NAME,
  5378. a.sex,
  5379. a.beh_dept_id,
  5380. a.beh_dept_name,
  5381. a.birthday,
  5382. a.behospital_date,
  5383. a.leave_hospital_date,
  5384. a.doctor_id,
  5385. a.doctor_name,
  5386. a.beh_doctor_id,
  5387. a.beh_doctor_name,
  5388. a.director_doctor_id,
  5389. a.director_doctor_name,
  5390. a.diagnose,
  5391. a.placefile_date,
  5392. a.ward_name,
  5393. b.gmt_create
  5394. FROM
  5395. med_behospital_info a,
  5396. med_qcresult_info b,
  5397. med_qcresult_detail c,
  5398. qc_cases_entry d,
  5399. sys_user_dept e
  5400. WHERE
  5401. a.is_deleted = 'N'
  5402. AND b.is_deleted = 'N'
  5403. AND c.is_deleted = 'N'
  5404. AND d.is_deleted = 'N'
  5405. AND e.is_deleted = 'N'
  5406. AND a.hospital_id = b.hospital_id
  5407. AND a.hospital_id = c.hospital_id
  5408. AND a.hospital_id = e.hospital_id
  5409. AND a.behospital_code = b.behospital_code
  5410. AND a.behospital_code = c.behospital_code
  5411. AND a.beh_dept_id = e.dept_id
  5412. AND c.cases_id = d.cases_id
  5413. AND c.cases_entry_id = d.id
  5414. AND a.qc_type_id != 0
  5415. <if test="qcResultShortPageVO.userId!=null">
  5416. AND e.user_id = #{qcResultShortPageVO.userId}
  5417. </if>
  5418. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5419. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5420. </if>
  5421. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5422. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5423. </if>
  5424. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5425. <if test="qcResultShortPageVO.startDate != null ">
  5426. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5427. </if>
  5428. <if test="qcResultShortPageVO.endDate != null ">
  5429. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5430. </if>
  5431. </if>
  5432. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5433. <if test="qcResultShortPageVO.startDate != null ">
  5434. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5435. </if>
  5436. <if test="qcResultShortPageVO.endDate != null">
  5437. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5438. </if>
  5439. </if>
  5440. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5441. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5442. </if>
  5443. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5444. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5445. </if>
  5446. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5447. AND b.`level` = #{qcResultShortPageVO.level}
  5448. </if>
  5449. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5450. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5451. </if>
  5452. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5453. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5454. </if>
  5455. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  5456. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  5457. </if>
  5458. <if test="qcResultShortPageVO.casesEntryId != null ">
  5459. AND d.id = #{qcResultShortPageVO.casesEntryId}
  5460. </if>
  5461. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  5462. AND d.cases_name = #{qcResultShortPageVO.casesName}
  5463. </if>
  5464. <if test="qcResultShortPageVO.casesId != null">
  5465. AND d.cases_id = #{qcResultShortPageVO.casesId}
  5466. </if>
  5467. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5468. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5469. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5470. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5471. </if>
  5472. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5473. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5474. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5475. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5476. </if>
  5477. <if test="qcResultShortPageVO.isReject != null">
  5478. AND c.is_reject = #{qcResultShortPageVO.isReject}
  5479. </if>
  5480. <if test="qcResultShortPageVO.ruleType != null">
  5481. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  5482. </if>
  5483. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  5484. AND TIMESTAMPDIFF(
  5485. DAY,
  5486. DATE( a.behospital_date ),
  5487. DATE( a.leave_hospital_date ))> 30
  5488. </if>
  5489. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  5490. AND TIMESTAMPDIFF(
  5491. DAY,
  5492. DATE( a.behospital_date ),
  5493. DATE( a.leave_hospital_date ))> 31
  5494. </if>
  5495. )be
  5496. left join med_check_info mci
  5497. on mci.is_deleted = 'N'
  5498. and mci.check_type = 0
  5499. and be.hospital_id = mci.hospital_id
  5500. and be.behospital_code = mci.behospital_code
  5501. left join med_check_info hm_mci
  5502. on hm_mci.is_deleted = 'N'
  5503. and hm_mci.check_type = 1
  5504. and be.hospital_id = hm_mci.hospital_id
  5505. and be.behospital_code = hm_mci.behospital_code
  5506. LEFT JOIN med_qcresult_cases e
  5507. on be.behospital_code = e.behospital_code
  5508. and be.hospital_id = e.hospital_id
  5509. AND e.is_deleted = 'N'
  5510. and e.cases_id = 243
  5511. )tt1
  5512. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  5513. ,med_medical_record tt2
  5514. WHERE
  5515. tt2.is_deleted = 'N'
  5516. AND tt1.hospital_id = tt2.hospital_id
  5517. AND tt1.behospital_code = tt2.behospital_code
  5518. AND tt2.mode_id = 30
  5519. </if>
  5520. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  5521. ,med_crisis_info tt2
  5522. WHERE
  5523. tt2.is_deleted = 'N'
  5524. AND tt1.hospital_id = tt2.hospital_id
  5525. AND tt1.behospital_code = tt2.behospital_code
  5526. </if>
  5527. ) t1
  5528. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  5529. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  5530. AND t1.behospital_code = t2.behospital_code
  5531. AND t2.is_deleted = 'N'
  5532. </if>
  5533. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  5534. , med_home_page t2
  5535. , med_home_operation_info t3
  5536. WHERE t1.hospital_id = t2.hospital_id
  5537. AND t1.behospital_code = t2.behospital_code
  5538. AND t2.home_page_id = t3.home_page_id
  5539. AND t2.is_deleted = 'N'
  5540. AND t3.is_deleted = 'N'
  5541. </if>
  5542. ) t
  5543. where 1=1
  5544. <if test="qcResultShortPageVO.checkStatus != null">
  5545. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5546. </if>
  5547. <if test="qcResultShortPageVO.mrStatus != null">
  5548. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5549. </if>
  5550. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5551. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5552. </if>
  5553. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5554. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5555. </if>
  5556. <if test="qcResultShortPageVO.chTimeStart != null ">
  5557. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5558. </if>
  5559. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5560. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5561. </if>
  5562. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5563. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5564. </if>
  5565. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5566. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5567. </if>
  5568. </select>
  5569. <update id="updateBatchByKey">
  5570. <foreach collection="list" item="item" separator=";">
  5571. update med_behospital_info
  5572. <set>
  5573. <if test="item.name != null">
  5574. name = #{item.name},
  5575. </if>
  5576. <if test="item.sex != null">
  5577. sex = #{item.sex},
  5578. </if>
  5579. <if test="item.birthday != null">
  5580. birthday = #{item.birthday},
  5581. </if>
  5582. <if test="item.fileCode != null">
  5583. file_code = #{item.fileCode},
  5584. </if>
  5585. <if test="item.qcTypeId != null">
  5586. qc_type_id = #{item.qcTypeId},
  5587. </if>
  5588. <if test="item.wardCode != null">
  5589. ward_code = #{item.wardCode},
  5590. </if>
  5591. <if test="item.wardName != null">
  5592. ward_name = #{item.wardName},
  5593. </if>
  5594. <if test="item.behDeptId != null">
  5595. beh_dept_id = #{item.behDeptId},
  5596. </if>
  5597. <if test="item.behDeptName != null">
  5598. beh_dept_name = #{item.behDeptName},
  5599. </if>
  5600. <if test="item.bedCode != null">
  5601. bed_code = #{item.bedCode},
  5602. </if>
  5603. <if test="item.bedName != null">
  5604. bed_name = #{item.bedName},
  5605. </if>
  5606. <if test="item.insuranceName != null">
  5607. insurance_name = #{item.insuranceName},
  5608. </if>
  5609. <if test="item.jobType != null">
  5610. job_type = #{item.jobType},
  5611. </if>
  5612. <if test="item.behospitalDate != null">
  5613. behospital_date = #{item.behospitalDate},
  5614. </if>
  5615. <if test="item.leaveHospitalDate != null">
  5616. leave_hospital_date = #{item.leaveHospitalDate},
  5617. </if>
  5618. <if test="item.diagnoseIcd != null">
  5619. diagnose_icd = #{item.diagnoseIcd},
  5620. </if>
  5621. <if test="item.diagnose != null">
  5622. diagnose = #{item.diagnose},
  5623. </if>
  5624. <if test="item.behDoctorId != null">
  5625. beh_doctor_id = #{item.behDoctorId},
  5626. </if>
  5627. <if test="item.behDoctorName != null">
  5628. beh_doctor_name = #{item.behDoctorName},
  5629. </if>
  5630. <if test="item.doctorId != null">
  5631. doctor_id = #{item.doctorId},
  5632. </if>
  5633. <if test="item.doctorName != null">
  5634. doctor_name = #{item.doctorName},
  5635. </if>
  5636. <if test="item.directorDoctorId != null">
  5637. director_doctor_id = #{item.directorDoctorId},
  5638. </if>
  5639. <if test="item.directorDoctorName != null">
  5640. director_doctor_name = #{item.directorDoctorName},
  5641. </if>
  5642. <if test="item.placefileDate != null">
  5643. placefile_date = #{item.placefileDate},
  5644. </if>
  5645. <if test="item.isPlacefile != null">
  5646. is_placefile = #{item.isPlacefile},
  5647. </if>
  5648. <if test="item.gmtModified != null">
  5649. gmt_modified = #{item.gmtModified},
  5650. </if>
  5651. <if test="item.modifier != null">
  5652. modifier = #{item.modifier},
  5653. </if>
  5654. </set>
  5655. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  5656. </foreach>
  5657. </update>
  5658. <!-- 关键条目缺陷统计报表-->
  5659. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  5660. SELECT
  5661. deptId,
  5662. deptName,
  5663. consultationMRNum,
  5664. consultationNum,
  5665. 2511 AS consultationEntryId,
  5666. '普通会诊未在24小时内完成' AS consultationEntryName,
  5667. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  5668. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  5669. operationMRNum,
  5670. 2594 AS operationNameEntryId,
  5671. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  5672. operationNameNum,
  5673. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  5674. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  5675. 2973 AS operationTimeEntryId,
  5676. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  5677. operationTimeNum,
  5678. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  5679. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  5680. 2930 AS operation15MinuteEntryId,
  5681. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  5682. operation15MinuteNum,
  5683. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  5684. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  5685. 2419 AS crisisEntryId,
  5686. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  5687. crisisMRNum,
  5688. crisisNum,
  5689. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  5690. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  5691. 2495 AS stageSummaryEntryId,
  5692. '无阶段小结' AS stageSummaryEntryName,
  5693. stageSummaryMRNum,
  5694. stageSummaryNum,
  5695. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  5696. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  5697. beHosGT31DaysMRNum
  5698. FROM
  5699. (
  5700. SELECT
  5701. tt.deptId,
  5702. tt.deptName,
  5703. sum( tt.consultationNum ) AS consultationNum,
  5704. sum( tt.consultationMRNum ) AS consultationMRNum,
  5705. sum( tt.operationNameNum ) AS operationNameNum,
  5706. sum( tt.operationTimeNum ) AS operationTimeNum,
  5707. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  5708. sum( tt.operationMRNum ) AS operationMRNum,
  5709. sum( tt.crisisNum ) AS crisisNum,
  5710. sum( tt.crisisMRNum ) AS crisisMRNum,
  5711. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  5712. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  5713. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  5714. FROM
  5715. (
  5716. (
  5717. SELECT
  5718. c.beh_dept_id AS deptId,
  5719. c.beh_dept_name AS deptName,
  5720. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  5721. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  5722. 0 AS operationNameNum,
  5723. 0 AS operationTimeNum,
  5724. 0 AS operation15MinuteNum,
  5725. 0 AS operationMRNum,
  5726. 0 AS crisisNum,
  5727. 0 AS crisisMRNum,
  5728. 0 AS stageSummaryNum,
  5729. 0 AS stageSummaryMRNum,
  5730. 0 AS beHosGT31DaysMRNum
  5731. FROM
  5732. (
  5733. SELECT DISTINCT
  5734. a.hospital_id,
  5735. a.behospital_code,
  5736. a.beh_dept_name,
  5737. a.beh_dept_id
  5738. FROM
  5739. med_behospital_info a,
  5740. med_medical_record b
  5741. WHERE
  5742. a.is_deleted = 'N'
  5743. AND b.is_deleted = 'N'
  5744. AND a.hospital_id = b.hospital_id
  5745. AND a.behospital_code = b.behospital_code
  5746. AND b.mode_id = 30
  5747. <if test="isPlacefile != null and isPlacefile != ''">
  5748. and a.is_placefile = #{isPlacefile}
  5749. </if>
  5750. AND a.qc_type_id != 0
  5751. <if test="hospitalId != null and hospitalId != ''">
  5752. AND a.hospital_id = #{hospitalId}
  5753. </if>
  5754. <if test="isPlacefile != null and isPlacefile == 0">
  5755. <if test="startDate != null ">
  5756. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5757. </if>
  5758. <if test="endDate != null ">
  5759. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5760. </if>
  5761. </if>
  5762. <if test="isPlacefile != null and isPlacefile == 1">
  5763. <if test="startDate != null ">
  5764. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5765. </if>
  5766. <if test="endDate != null ">
  5767. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5768. </if>
  5769. </if>
  5770. <if test="deptName != null and deptName != ''">
  5771. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5772. </if>
  5773. ) c
  5774. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5775. AND c.hospital_id = d.hospital_id
  5776. AND c.behospital_code = d.behospital_code
  5777. GROUP BY
  5778. c.beh_dept_id,
  5779. c.beh_dept_name
  5780. ) UNION
  5781. (
  5782. SELECT
  5783. d.beh_dept_id AS deptId,
  5784. d.beh_dept_name AS deptName,
  5785. 0 AS consultationNum,
  5786. 0 AS consultationMRNum,
  5787. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  5788. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  5789. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  5790. count( DISTINCT d.behospital_code ) AS operationMRNum,
  5791. 0 AS crisisNum,
  5792. 0 AS crisisMRNum,
  5793. 0 AS stageSummaryNum,
  5794. 0 AS stageSummaryMRNum,
  5795. 0 AS beHosGT31DaysMRNum
  5796. FROM
  5797. (
  5798. SELECT DISTINCT
  5799. a.hospital_id,
  5800. a.behospital_code,
  5801. a.beh_dept_name,
  5802. a.beh_dept_id
  5803. FROM
  5804. med_behospital_info a,
  5805. med_home_page b,
  5806. med_home_operation_info c
  5807. WHERE
  5808. a.is_deleted = 'N'
  5809. AND b.is_deleted = 'N'
  5810. AND c.is_deleted = 'N'
  5811. AND a.hospital_id = b.hospital_id
  5812. AND a.hospital_id = c.hospital_id
  5813. AND a.behospital_code = b.behospital_code
  5814. AND b.home_page_id = c.home_page_id
  5815. <if test="isPlacefile != null and isPlacefile != ''">
  5816. and a.is_placefile = #{isPlacefile}
  5817. </if>
  5818. AND a.qc_type_id != 0
  5819. <if test="hospitalId != null and hospitalId != ''">
  5820. AND a.hospital_id = #{hospitalId}
  5821. </if>
  5822. <if test="isPlacefile != null and isPlacefile == 0">
  5823. <if test="startDate != null ">
  5824. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5825. </if>
  5826. <if test="endDate != null ">
  5827. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5828. </if>
  5829. </if>
  5830. <if test="isPlacefile != null and isPlacefile == 1">
  5831. <if test="startDate != null ">
  5832. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5833. </if>
  5834. <if test="endDate != null ">
  5835. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5836. </if>
  5837. </if>
  5838. <if test="deptName != null and deptName != ''">
  5839. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5840. </if>
  5841. ) d
  5842. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  5843. AND d.hospital_id = e.hospital_id
  5844. AND d.behospital_code = e.behospital_code
  5845. GROUP BY
  5846. d.beh_dept_id,
  5847. d.beh_dept_name
  5848. ) UNION
  5849. (
  5850. SELECT
  5851. c.beh_dept_id AS deptId,
  5852. c.beh_dept_name AS deptName,
  5853. 0 AS consultationNum,
  5854. 0 AS consultationMRNum,
  5855. 0 AS operationNameNum,
  5856. 0 AS operationTimeNum,
  5857. 0 AS operation15MinuteNum,
  5858. 0 AS operationMRNum,
  5859. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  5860. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  5861. 0 AS stageSummaryNum,
  5862. 0 AS stageSummaryMRNum,
  5863. 0 AS beHosGT31DaysMRNum
  5864. FROM
  5865. (
  5866. SELECT DISTINCT
  5867. a.hospital_id,
  5868. a.behospital_code,
  5869. a.beh_dept_name,
  5870. a.beh_dept_id
  5871. FROM
  5872. med_behospital_info a,
  5873. med_crisis_info b
  5874. WHERE
  5875. a.is_deleted = 'N'
  5876. AND b.is_deleted = 'N'
  5877. AND a.hospital_id = b.hospital_id
  5878. AND a.behospital_code = b.behospital_code
  5879. <if test="isPlacefile != null and isPlacefile != ''">
  5880. and a.is_placefile = #{isPlacefile}
  5881. </if>
  5882. AND a.qc_type_id != 0
  5883. <if test="hospitalId != null and hospitalId != ''">
  5884. AND a.hospital_id = #{hospitalId}
  5885. </if>
  5886. <if test="isPlacefile != null and isPlacefile == 0">
  5887. <if test="startDate != null ">
  5888. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5889. </if>
  5890. <if test="endDate != null ">
  5891. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5892. </if>
  5893. </if>
  5894. <if test="isPlacefile != null and isPlacefile == 1">
  5895. <if test="startDate != null ">
  5896. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5897. </if>
  5898. <if test="endDate != null ">
  5899. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5900. </if>
  5901. </if>
  5902. <if test="deptName != null and deptName != ''">
  5903. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5904. </if>
  5905. ) c
  5906. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  5907. AND c.hospital_id = d.hospital_id
  5908. AND c.behospital_code = d.behospital_code
  5909. GROUP BY
  5910. c.beh_dept_id,
  5911. c.beh_dept_name
  5912. ) UNION
  5913. (
  5914. SELECT
  5915. b.beh_dept_id AS deptId,
  5916. b.beh_dept_name AS deptName,
  5917. 0 AS consultationNum,
  5918. 0 AS consultationMRNum,
  5919. 0 AS operationNameNum,
  5920. 0 AS operationTimeNum,
  5921. 0 AS operation15MinuteNum,
  5922. 0 AS operationMRNum,
  5923. 0 AS crisisNum,
  5924. 0 AS crisisMRNum,
  5925. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  5926. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  5927. 0 AS beHosGT31DaysMRNum
  5928. FROM
  5929. (
  5930. SELECT DISTINCT
  5931. a.hospital_id,
  5932. a.behospital_code,
  5933. a.beh_dept_name,
  5934. a.beh_dept_id
  5935. FROM
  5936. med_behospital_info a
  5937. WHERE
  5938. a.is_deleted = 'N'
  5939. AND TIMESTAMPDIFF(
  5940. DAY,
  5941. DATE( behospital_date ),
  5942. DATE( leave_hospital_date ))> 30
  5943. <if test="isPlacefile != null and isPlacefile != ''">
  5944. and a.is_placefile = #{isPlacefile}
  5945. </if>
  5946. AND a.qc_type_id != 0
  5947. <if test="hospitalId != null and hospitalId != ''">
  5948. AND a.hospital_id = #{hospitalId}
  5949. </if>
  5950. <if test="isPlacefile != null and isPlacefile == 0">
  5951. <if test="startDate != null ">
  5952. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5953. </if>
  5954. <if test="endDate != null ">
  5955. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5956. </if>
  5957. </if>
  5958. <if test="isPlacefile != null and isPlacefile == 1">
  5959. <if test="startDate != null ">
  5960. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5961. </if>
  5962. <if test="endDate != null ">
  5963. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5964. </if>
  5965. </if>
  5966. <if test="deptName != null and deptName != ''">
  5967. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5968. </if>
  5969. ) b
  5970. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  5971. AND b.hospital_id = c.hospital_id
  5972. AND b.behospital_code = c.behospital_code
  5973. GROUP BY
  5974. b.beh_dept_id,
  5975. b.beh_dept_name
  5976. ) UNION
  5977. (
  5978. SELECT
  5979. b.beh_dept_id AS deptId,
  5980. b.beh_dept_name AS deptName,
  5981. 0 AS consultationNum,
  5982. 0 AS consultationMRNum,
  5983. 0 AS operationNameNum,
  5984. 0 AS operationTimeNum,
  5985. 0 AS operation15MinuteNum,
  5986. 0 AS operationMRNum,
  5987. 0 AS crisisNum,
  5988. 0 AS crisisMRNum,
  5989. 0 AS stageSummaryNum,
  5990. 0 AS stageSummaryMRNum,
  5991. count(*) AS beHosGT31DaysMRNum
  5992. FROM
  5993. (
  5994. SELECT DISTINCT
  5995. a.hospital_id,
  5996. a.behospital_code,
  5997. a.beh_dept_name,
  5998. a.beh_dept_id
  5999. FROM
  6000. med_behospital_info a
  6001. WHERE
  6002. a.is_deleted = 'N'
  6003. AND TIMESTAMPDIFF(
  6004. DAY,
  6005. DATE( behospital_date ),
  6006. DATE( leave_hospital_date ))> 31
  6007. <if test="isPlacefile != null and isPlacefile != ''">
  6008. and a.is_placefile = #{isPlacefile}
  6009. </if>
  6010. AND a.qc_type_id != 0
  6011. <if test="hospitalId != null and hospitalId != ''">
  6012. AND a.hospital_id = #{hospitalId}
  6013. </if>
  6014. <if test="isPlacefile != null and isPlacefile == 0">
  6015. <if test="startDate != null ">
  6016. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6017. </if>
  6018. <if test="endDate != null ">
  6019. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6020. </if>
  6021. </if>
  6022. <if test="isPlacefile != null and isPlacefile == 1">
  6023. <if test="startDate != null ">
  6024. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6025. </if>
  6026. <if test="endDate != null ">
  6027. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6028. </if>
  6029. </if>
  6030. <if test="deptName != null and deptName != ''">
  6031. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6032. </if>
  6033. ) b
  6034. GROUP BY
  6035. b.beh_dept_id,
  6036. b.beh_dept_name
  6037. )
  6038. ) tt
  6039. GROUP BY
  6040. tt.deptId,
  6041. tt.deptName
  6042. ) t
  6043. <if test="asc != null and asc !=''">
  6044. order by
  6045. <choose>
  6046. <when test='asc=="deptId"'>deptId asc</when>
  6047. <when test='asc=="deptName"'>deptName asc</when>
  6048. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6049. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6050. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6051. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6052. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6053. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6054. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6055. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6056. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6057. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6058. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6059. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6060. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6061. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6062. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6063. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6064. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6065. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6066. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6067. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6068. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6069. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6070. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6071. <otherwise>deptName asc</otherwise>
  6072. </choose>
  6073. </if>
  6074. <if test="desc != null and desc!=''">
  6075. order by
  6076. <choose>
  6077. <when test='desc=="deptId"'>deptId desc</when>
  6078. <when test='desc=="deptName"'>deptName desc</when>
  6079. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6080. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6081. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6082. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6083. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6084. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6085. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6086. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6087. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6088. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6089. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6090. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6091. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6092. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6093. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6094. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6095. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6096. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6097. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6098. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6099. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6100. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6101. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6102. <otherwise>deptName desc</otherwise>
  6103. </choose>
  6104. </if>
  6105. </select>
  6106. <!-- 关键条目缺陷统计报表-科室-->
  6107. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  6108. SELECT
  6109. deptId,
  6110. deptName,
  6111. doctorName,
  6112. consultationMRNum,
  6113. consultationNum,
  6114. 2511 AS consultationEntryId,
  6115. '普通会诊未在24小时内完成' AS consultationEntryName,
  6116. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  6117. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  6118. operationMRNum,
  6119. 2594 AS operationNameEntryId,
  6120. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  6121. operationNameNum,
  6122. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  6123. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  6124. 2973 AS operationTimeEntryId,
  6125. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  6126. operationTimeNum,
  6127. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  6128. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  6129. 2930 AS operation15MinuteEntryId,
  6130. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  6131. operation15MinuteNum,
  6132. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  6133. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  6134. 2419 AS crisisEntryId,
  6135. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  6136. crisisMRNum,
  6137. crisisNum,
  6138. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  6139. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  6140. 2495 AS stageSummaryEntryId,
  6141. '无阶段小结' AS stageSummaryEntryName,
  6142. stageSummaryMRNum,
  6143. stageSummaryNum,
  6144. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  6145. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  6146. beHosGT31DaysMRNum
  6147. FROM
  6148. (
  6149. SELECT
  6150. tt.deptId,
  6151. tt.deptName,
  6152. tt.doctorId,
  6153. tt.doctorName,
  6154. sum( tt.consultationNum ) AS consultationNum,
  6155. sum( tt.consultationMRNum ) AS consultationMRNum,
  6156. sum( tt.operationNameNum ) AS operationNameNum,
  6157. sum( tt.operationTimeNum ) AS operationTimeNum,
  6158. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  6159. sum( tt.operationMRNum ) AS operationMRNum,
  6160. sum( tt.crisisNum ) AS crisisNum,
  6161. sum( tt.crisisMRNum ) AS crisisMRNum,
  6162. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  6163. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  6164. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  6165. FROM
  6166. (
  6167. (
  6168. SELECT
  6169. c.beh_dept_id AS deptId,
  6170. c.beh_dept_name AS deptName,
  6171. c.doctorId,
  6172. c.doctorName,
  6173. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  6174. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  6175. 0 AS operationNameNum,
  6176. 0 AS operationTimeNum,
  6177. 0 AS operation15MinuteNum,
  6178. 0 AS operationMRNum,
  6179. 0 AS crisisNum,
  6180. 0 AS crisisMRNum,
  6181. 0 AS stageSummaryNum,
  6182. 0 AS stageSummaryMRNum,
  6183. 0 AS beHosGT31DaysMRNum
  6184. FROM
  6185. (
  6186. SELECT DISTINCT
  6187. a.hospital_id,
  6188. a.behospital_code,
  6189. a.beh_dept_name,
  6190. a.beh_dept_id,
  6191. a.doctor_id as doctorId,
  6192. a.doctor_name as doctorName
  6193. FROM
  6194. med_behospital_info a,
  6195. med_medical_record b,
  6196. sys_user_dept c
  6197. WHERE
  6198. a.is_deleted = 'N'
  6199. AND b.is_deleted = 'N'
  6200. AND c.is_deleted = 'N'
  6201. AND a.hospital_id = b.hospital_id
  6202. AND a.hospital_id = c.hospital_id
  6203. AND a.behospital_code = b.behospital_code
  6204. AND a.beh_dept_id = c.dept_id
  6205. AND b.mode_id = 30
  6206. <if test="userId!=null">
  6207. AND c.user_id = #{userId}
  6208. </if>
  6209. <if test="isPlacefile != null and isPlacefile != ''">
  6210. and a.is_placefile = #{isPlacefile}
  6211. </if>
  6212. AND a.qc_type_id != 0
  6213. <if test="hospitalId != null and hospitalId != ''">
  6214. AND a.hospital_id = #{hospitalId}
  6215. </if>
  6216. <if test="isPlacefile != null and isPlacefile == 0">
  6217. <if test="startDate != null ">
  6218. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6219. </if>
  6220. <if test="endDate != null ">
  6221. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6222. </if>
  6223. </if>
  6224. <if test="isPlacefile != null and isPlacefile == 1">
  6225. <if test="startDate != null ">
  6226. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6227. </if>
  6228. <if test="endDate != null ">
  6229. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6230. </if>
  6231. </if>
  6232. <if test="doctorName != null and doctorName != ''">
  6233. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6234. </if>
  6235. <if test="deptName != null and deptName != ''">
  6236. AND a.beh_dept_name = #{deptName}
  6237. </if>
  6238. ) c
  6239. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6240. AND c.hospital_id = d.hospital_id
  6241. AND c.behospital_code = d.behospital_code
  6242. GROUP BY
  6243. c.doctorId,
  6244. c.doctorName
  6245. ) UNION
  6246. (
  6247. SELECT
  6248. d.beh_dept_id AS deptId,
  6249. d.beh_dept_name AS deptName,
  6250. d.doctor_id as doctorId,
  6251. d.doctor_name as doctorName,
  6252. 0 AS consultationNum,
  6253. 0 AS consultationMRNum,
  6254. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  6255. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  6256. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  6257. count( DISTINCT d.behospital_code ) AS operationMRNum,
  6258. 0 AS crisisNum,
  6259. 0 AS crisisMRNum,
  6260. 0 AS stageSummaryNum,
  6261. 0 AS stageSummaryMRNum,
  6262. 0 AS beHosGT31DaysMRNum
  6263. FROM
  6264. (
  6265. SELECT DISTINCT
  6266. a.hospital_id,
  6267. a.behospital_code,
  6268. a.beh_dept_name,
  6269. a.beh_dept_id,
  6270. a.doctor_id,
  6271. a.doctor_name
  6272. FROM
  6273. med_behospital_info a,
  6274. med_home_page b,
  6275. med_home_operation_info c,
  6276. sys_user_dept d
  6277. WHERE
  6278. a.is_deleted = 'N'
  6279. AND b.is_deleted = 'N'
  6280. AND c.is_deleted = 'N'
  6281. AND d.is_deleted = 'N'
  6282. AND a.hospital_id = b.hospital_id
  6283. AND a.hospital_id = c.hospital_id
  6284. AND a.hospital_id = d.hospital_id
  6285. AND a.behospital_code = b.behospital_code
  6286. AND b.home_page_id = c.home_page_id
  6287. AND a.beh_dept_id = d.dept_id
  6288. <if test="userId!=null">
  6289. AND d.user_id = #{userId}
  6290. </if>
  6291. <if test="isPlacefile != null and isPlacefile != ''">
  6292. and a.is_placefile = #{isPlacefile}
  6293. </if>
  6294. AND a.qc_type_id != 0
  6295. <if test="hospitalId != null and hospitalId != ''">
  6296. AND a.hospital_id = #{hospitalId}
  6297. </if>
  6298. <if test="isPlacefile != null and isPlacefile == 0">
  6299. <if test="startDate != null ">
  6300. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6301. </if>
  6302. <if test="endDate != null ">
  6303. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6304. </if>
  6305. </if>
  6306. <if test="isPlacefile != null and isPlacefile == 1">
  6307. <if test="startDate != null ">
  6308. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6309. </if>
  6310. <if test="endDate != null ">
  6311. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6312. </if>
  6313. </if>
  6314. <if test="doctorName != null and doctorName != ''">
  6315. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6316. </if>
  6317. <if test="deptName != null and deptName != ''">
  6318. AND a.beh_dept_name = #{deptName}
  6319. </if>
  6320. ) d
  6321. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  6322. AND d.hospital_id = e.hospital_id
  6323. AND d.behospital_code = e.behospital_code
  6324. GROUP BY
  6325. d.doctor_id,
  6326. d.doctor_name
  6327. ) UNION
  6328. (
  6329. SELECT
  6330. c.beh_dept_id AS deptId,
  6331. c.beh_dept_name AS deptName,
  6332. c.doctor_id as doctorId,
  6333. c.doctor_name as doctorName,
  6334. 0 AS consultationNum,
  6335. 0 AS consultationMRNum,
  6336. 0 AS operationNameNum,
  6337. 0 AS operationTimeNum,
  6338. 0 AS operation15MinuteNum,
  6339. 0 AS operationMRNum,
  6340. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  6341. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  6342. 0 AS stageSummaryNum,
  6343. 0 AS stageSummaryMRNum,
  6344. 0 AS beHosGT31DaysMRNum
  6345. FROM
  6346. (
  6347. SELECT DISTINCT
  6348. a.hospital_id,
  6349. a.behospital_code,
  6350. a.beh_dept_name,
  6351. a.beh_dept_id,
  6352. a.doctor_id,
  6353. a.doctor_name
  6354. FROM
  6355. med_behospital_info a,
  6356. med_crisis_info b,
  6357. sys_user_dept c
  6358. WHERE
  6359. a.is_deleted = 'N'
  6360. AND b.is_deleted = 'N'
  6361. AND c.is_deleted = 'N'
  6362. AND a.hospital_id = b.hospital_id
  6363. AND a.hospital_id = c.hospital_id
  6364. AND a.behospital_code = b.behospital_code
  6365. AND a.beh_dept_id = c.dept_id
  6366. <if test="userId!=null">
  6367. AND c.user_id = #{userId}
  6368. </if>
  6369. <if test="isPlacefile != null and isPlacefile != ''">
  6370. and a.is_placefile = #{isPlacefile}
  6371. </if>
  6372. AND a.qc_type_id != 0
  6373. <if test="hospitalId != null and hospitalId != ''">
  6374. AND a.hospital_id = #{hospitalId}
  6375. </if>
  6376. <if test="isPlacefile != null and isPlacefile == 0">
  6377. <if test="startDate != null ">
  6378. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6379. </if>
  6380. <if test="endDate != null ">
  6381. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6382. </if>
  6383. </if>
  6384. <if test="isPlacefile != null and isPlacefile == 1">
  6385. <if test="startDate != null ">
  6386. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6387. </if>
  6388. <if test="endDate != null ">
  6389. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6390. </if>
  6391. </if>
  6392. <if test="doctorName != null and doctorName != ''">
  6393. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6394. </if>
  6395. <if test="deptName != null and deptName != ''">
  6396. AND a.beh_dept_name = #{deptName}
  6397. </if>
  6398. ) c
  6399. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  6400. AND c.hospital_id = d.hospital_id
  6401. AND c.behospital_code = d.behospital_code
  6402. GROUP BY
  6403. c.doctor_id,
  6404. c.doctor_name
  6405. ) UNION
  6406. (
  6407. SELECT
  6408. b.beh_dept_id AS deptId,
  6409. b.beh_dept_name AS deptName,
  6410. b.doctor_id as doctorId,
  6411. b.doctor_name as doctorName,
  6412. 0 AS consultationNum,
  6413. 0 AS consultationMRNum,
  6414. 0 AS operationNameNum,
  6415. 0 AS operationTimeNum,
  6416. 0 AS operation15MinuteNum,
  6417. 0 AS operationMRNum,
  6418. 0 AS crisisNum,
  6419. 0 AS crisisMRNum,
  6420. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  6421. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  6422. 0 AS beHosGT31DaysMRNum
  6423. FROM
  6424. (
  6425. SELECT DISTINCT
  6426. a.hospital_id,
  6427. a.behospital_code,
  6428. a.beh_dept_name,
  6429. a.beh_dept_id,
  6430. a.doctor_id,
  6431. a.doctor_name
  6432. FROM
  6433. med_behospital_info a,
  6434. sys_user_dept b
  6435. WHERE
  6436. a.is_deleted = 'N'
  6437. AND b.is_deleted = 'N'
  6438. AND a.hospital_id = b.hospital_id
  6439. AND a.beh_dept_id = b.dept_id
  6440. AND TIMESTAMPDIFF(
  6441. DAY,
  6442. DATE( behospital_date ),
  6443. DATE( leave_hospital_date ))> 30
  6444. <if test="userId!=null">
  6445. AND b.user_id = #{userId}
  6446. </if>
  6447. <if test="isPlacefile != null and isPlacefile != ''">
  6448. and a.is_placefile = #{isPlacefile}
  6449. </if>
  6450. AND a.qc_type_id != 0
  6451. <if test="hospitalId != null and hospitalId != ''">
  6452. AND a.hospital_id = #{hospitalId}
  6453. </if>
  6454. <if test="isPlacefile != null and isPlacefile == 0">
  6455. <if test="startDate != null ">
  6456. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6457. </if>
  6458. <if test="endDate != null ">
  6459. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6460. </if>
  6461. </if>
  6462. <if test="isPlacefile != null and isPlacefile == 1">
  6463. <if test="startDate != null ">
  6464. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6465. </if>
  6466. <if test="endDate != null ">
  6467. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6468. </if>
  6469. </if>
  6470. <if test="doctorName != null and doctorName != ''">
  6471. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6472. </if>
  6473. <if test="deptName != null and deptName != ''">
  6474. AND a.beh_dept_name = #{deptName}
  6475. </if>
  6476. ) b
  6477. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  6478. AND b.hospital_id = c.hospital_id
  6479. AND b.behospital_code = c.behospital_code
  6480. GROUP BY
  6481. b.doctor_id,
  6482. b.doctor_name
  6483. ) UNION
  6484. (
  6485. SELECT
  6486. b.beh_dept_id AS deptId,
  6487. b.beh_dept_name AS deptName,
  6488. b.doctor_id as doctorId,
  6489. b.doctor_name as doctorName,
  6490. 0 AS consultationNum,
  6491. 0 AS consultationMRNum,
  6492. 0 AS operationNameNum,
  6493. 0 AS operationTimeNum,
  6494. 0 AS operation15MinuteNum,
  6495. 0 AS operationMRNum,
  6496. 0 AS crisisNum,
  6497. 0 AS crisisMRNum,
  6498. 0 AS stageSummaryNum,
  6499. 0 AS stageSummaryMRNum,
  6500. count(*) AS beHosGT31DaysMRNum
  6501. FROM
  6502. (
  6503. SELECT DISTINCT
  6504. a.hospital_id,
  6505. a.behospital_code,
  6506. a.beh_dept_name,
  6507. a.beh_dept_id,
  6508. a.doctor_id,
  6509. a.doctor_name
  6510. FROM
  6511. med_behospital_info a,
  6512. sys_user_dept b
  6513. WHERE
  6514. a.is_deleted = 'N'
  6515. AND b.is_deleted = 'N'
  6516. AND a.hospital_id = b.hospital_id
  6517. AND a.beh_dept_id = b.dept_id
  6518. AND TIMESTAMPDIFF(
  6519. DAY,
  6520. DATE( behospital_date ),
  6521. DATE( leave_hospital_date ))> 31
  6522. <if test="userId!=null">
  6523. AND b.user_id = #{userId}
  6524. </if>
  6525. <if test="isPlacefile != null and isPlacefile != ''">
  6526. and a.is_placefile = #{isPlacefile}
  6527. </if>
  6528. AND a.qc_type_id != 0
  6529. <if test="hospitalId != null and hospitalId != ''">
  6530. AND a.hospital_id = #{hospitalId}
  6531. </if>
  6532. <if test="isPlacefile != null and isPlacefile == 0">
  6533. <if test="startDate != null ">
  6534. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6535. </if>
  6536. <if test="endDate != null ">
  6537. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6538. </if>
  6539. </if>
  6540. <if test="isPlacefile != null and isPlacefile == 1">
  6541. <if test="startDate != null ">
  6542. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6543. </if>
  6544. <if test="endDate != null ">
  6545. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6546. </if>
  6547. </if>
  6548. <if test="doctorName != null and doctorName != ''">
  6549. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  6550. </if>
  6551. <if test="deptName != null and deptName != ''">
  6552. AND a.beh_dept_name = #{deptName}
  6553. </if>
  6554. ) b
  6555. GROUP BY
  6556. b.doctor_id,
  6557. b.doctor_name
  6558. )
  6559. ) tt
  6560. GROUP BY
  6561. tt.doctorName
  6562. ) t
  6563. <if test="asc != null and asc !=''">
  6564. order by
  6565. <choose>
  6566. <when test='asc=="deptId"'>deptId asc</when>
  6567. <when test='asc=="deptName"'>deptName asc</when>
  6568. <when test='asc=="doctorName"'>doctorName asc</when>
  6569. <when test='asc=="consultationNum"'>consultationNum asc</when>
  6570. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  6571. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  6572. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  6573. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  6574. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  6575. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  6576. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  6577. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  6578. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  6579. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  6580. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  6581. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  6582. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  6583. <when test='asc=="crisisNum"'>crisisNum asc</when>
  6584. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  6585. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  6586. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  6587. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  6588. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  6589. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  6590. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  6591. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  6592. <otherwise>doctorName asc</otherwise>
  6593. </choose>
  6594. </if>
  6595. <if test="desc != null and desc!=''">
  6596. order by
  6597. <choose>
  6598. <when test='desc=="deptId"'>deptId desc</when>
  6599. <when test='desc=="doctorName"'>doctorName desc</when>
  6600. <when test='desc=="deptName"'>deptName desc</when>
  6601. <when test='desc=="consultationNum"'>consultationNum desc</when>
  6602. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  6603. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  6604. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  6605. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  6606. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  6607. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  6608. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  6609. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  6610. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  6611. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  6612. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  6613. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  6614. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  6615. <when test='desc=="crisisNum"'>crisisNum desc</when>
  6616. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  6617. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  6618. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  6619. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  6620. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  6621. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  6622. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  6623. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  6624. <otherwise>doctorName desc</otherwise>
  6625. </choose>
  6626. </if>
  6627. </select>
  6628. <!-- 非医嘱离院病人记录-->
  6629. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  6630. SELECT
  6631. count(*)
  6632. FROM
  6633. med_behospital_info a,
  6634. med_home_page b
  6635. WHERE
  6636. a.is_deleted = 'N'
  6637. AND b.is_deleted = 'N'
  6638. AND a.hospital_id = b.hospital_id
  6639. AND a.behospital_code = b.behospital_code
  6640. AND b.leave_hospital_type = '非医嘱离院'
  6641. <if test="isPlacefile != null and isPlacefile != ''">
  6642. and a.is_placefile = #{isPlacefile}
  6643. </if>
  6644. AND a.qc_type_id != 0
  6645. <if test="hospitalId != null and hospitalId != ''">
  6646. AND a.hospital_id = #{hospitalId}
  6647. </if>
  6648. <if test="isPlacefile != null and isPlacefile == 0">
  6649. <if test="startDate != null and startDate != ''">
  6650. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6651. </if>
  6652. <if test="endDate != null and endDate != ''">
  6653. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6654. </if>
  6655. </if>
  6656. <if test="isPlacefile != null and isPlacefile == 1">
  6657. <if test="startDate != null and startDate != ''">
  6658. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6659. </if>
  6660. <if test="endDate != null and endDate != ''">
  6661. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6662. </if>
  6663. </if>
  6664. </select>
  6665. <!-- 31天内再入院记录-->
  6666. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  6667. SELECT
  6668. count(*)
  6669. FROM
  6670. (
  6671. SELECT
  6672. r1.file_code,
  6673. r1.diagnose,
  6674. r1.behospital_code AS behospitalCode,
  6675. r1.behospital_date AS behospitalDate,
  6676. r1.leave_hospital_date AS leaveHospitalDate,
  6677. r2.behospital_code AS lastBehospitalCode,
  6678. r2.behospital_date AS lastBehospitalDate,
  6679. r2.leave_hospital_date AS lastLeaveHospitalDate,
  6680. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  6681. FROM
  6682. (
  6683. SELECT
  6684. ( @rownum := @rownum + 1 ) AS rownum,
  6685. t1.file_code,
  6686. t1.diagnose,
  6687. t1.behospital_code,
  6688. t1.behospital_date,
  6689. t1.leave_hospital_date
  6690. FROM
  6691. (
  6692. SELECT
  6693. tt1.file_code,
  6694. tt1.diagnose,
  6695. tt2.behospital_code,
  6696. tt2.behospital_date,
  6697. tt2.leave_hospital_date
  6698. FROM
  6699. (
  6700. SELECT
  6701. a.file_code,
  6702. a.diagnose
  6703. FROM
  6704. med_behospital_info a
  6705. WHERE
  6706. a.is_deleted = 'N'
  6707. <if test="isPlacefile != null and isPlacefile != ''">
  6708. and a.is_placefile = #{isPlacefile}
  6709. </if>
  6710. AND a.qc_type_id != 0
  6711. AND IFNULL( a.diagnose, '' )!= ''
  6712. AND IFNULL( a.file_code, '' )!= ''
  6713. <if test="hospitalId != null and hospitalId != ''">
  6714. AND a.hospital_id = #{hospitalId}
  6715. </if>
  6716. <if test="isPlacefile != null and isPlacefile == 0">
  6717. <if test="startDate != null and startDate != ''">
  6718. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6719. </if>
  6720. <if test="endDate != null and endDate != ''">
  6721. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6722. </if>
  6723. </if>
  6724. <if test="isPlacefile != null and isPlacefile == 1">
  6725. <if test="startDate != null and startDate != ''">
  6726. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6727. </if>
  6728. <if test="endDate != null and endDate != ''">
  6729. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6730. </if>
  6731. </if>
  6732. GROUP BY
  6733. a.file_code,
  6734. a.diagnose
  6735. HAVING
  6736. count(*)> 1
  6737. ) tt1,
  6738. med_behospital_info tt2
  6739. WHERE
  6740. tt2.is_deleted = 'N'
  6741. <if test="isPlacefile != null and isPlacefile != ''">
  6742. and tt2.is_placefile = #{isPlacefile}
  6743. </if>
  6744. AND tt2.qc_type_id != 0
  6745. AND tt1.file_code = tt2.file_code
  6746. AND tt1.diagnose = tt2.diagnose
  6747. <if test="hospitalId != null and hospitalId != ''">
  6748. AND tt2.hospital_id = #{hospitalId}
  6749. </if>
  6750. <if test="isPlacefile != null and isPlacefile == 0">
  6751. <if test="startDate != null and startDate != ''">
  6752. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  6753. </if>
  6754. <if test="endDate != null and endDate != ''">
  6755. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  6756. </if>
  6757. </if>
  6758. <if test="isPlacefile != null and isPlacefile == 1">
  6759. <if test="startDate != null and startDate != ''">
  6760. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  6761. </if>
  6762. <if test="endDate != null and endDate != ''">
  6763. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  6764. </if>
  6765. </if>
  6766. ORDER BY
  6767. tt1.file_code,
  6768. tt1.diagnose,
  6769. tt2.behospital_date DESC
  6770. ) t1,
  6771. ( SELECT @rownum := 0 ) r
  6772. ) r1
  6773. LEFT JOIN (
  6774. SELECT
  6775. ( @INDEX := @INDEX + 1 ) AS rownum,
  6776. t2.file_code,
  6777. t2.diagnose,
  6778. t2.behospital_code,
  6779. t2.behospital_date,
  6780. t2.leave_hospital_date
  6781. FROM
  6782. (
  6783. SELECT
  6784. tt1.file_code,
  6785. tt1.diagnose,
  6786. tt2.behospital_code,
  6787. tt2.behospital_date,
  6788. tt2.leave_hospital_date
  6789. FROM
  6790. (
  6791. SELECT
  6792. a.file_code,
  6793. a.diagnose
  6794. FROM
  6795. med_behospital_info a
  6796. WHERE
  6797. a.is_deleted = 'N'
  6798. <if test="isPlacefile != null and isPlacefile != ''">
  6799. and a.is_placefile = #{isPlacefile}
  6800. </if>
  6801. AND a.qc_type_id != 0
  6802. AND IFNULL( a.diagnose, '' )!= ''
  6803. AND IFNULL( a.file_code, '' )!= ''
  6804. <if test="hospitalId != null and hospitalId != ''">
  6805. AND a.hospital_id = #{hospitalId}
  6806. </if>
  6807. <if test="isPlacefile != null and isPlacefile == 0">
  6808. <if test="startDate != null and startDate != ''">
  6809. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6810. </if>
  6811. <if test="endDate != null and endDate != ''">
  6812. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6813. </if>
  6814. </if>
  6815. <if test="isPlacefile != null and isPlacefile == 1">
  6816. <if test="startDate != null and startDate != ''">
  6817. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6818. </if>
  6819. <if test="endDate != null and endDate != ''">
  6820. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6821. </if>
  6822. </if>
  6823. GROUP BY
  6824. a.file_code,
  6825. a.diagnose
  6826. HAVING
  6827. count(*)> 1
  6828. ) tt1,
  6829. med_behospital_info tt2
  6830. WHERE
  6831. tt2.is_deleted = 'N'
  6832. <if test="isPlacefile != null and isPlacefile != ''">
  6833. and tt2.is_placefile = #{isPlacefile}
  6834. </if>
  6835. AND tt2.qc_type_id != 0
  6836. AND tt1.file_code = tt2.file_code
  6837. AND tt1.diagnose = tt2.diagnose
  6838. <if test="hospitalId != null and hospitalId != ''">
  6839. AND tt2.hospital_id = #{hospitalId}
  6840. </if>
  6841. <if test="isPlacefile != null and isPlacefile == 0">
  6842. <if test="startDate != null and startDate != ''">
  6843. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  6844. </if>
  6845. <if test="endDate != null and endDate != ''">
  6846. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  6847. </if>
  6848. </if>
  6849. <if test="isPlacefile != null and isPlacefile == 1">
  6850. <if test="startDate != null and startDate != ''">
  6851. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  6852. </if>
  6853. <if test="endDate != null and endDate != ''">
  6854. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  6855. </if>
  6856. </if>
  6857. ORDER BY
  6858. tt1.file_code,
  6859. tt1.diagnose,
  6860. tt2.behospital_date DESC
  6861. ) t2,(
  6862. SELECT
  6863. @INDEX := 0
  6864. ) r
  6865. ) r2 ON r1.file_code = r2.file_code
  6866. AND r1.rownum = r2.rownum - 1
  6867. ) t
  6868. WHERE
  6869. t.diffDays IS NOT NULL
  6870. AND t.diffDays BETWEEN 0
  6871. AND 31
  6872. </select>
  6873. <!-- 病案首页质控病历数统计-全院(首页)-->
  6874. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  6875. SELECT
  6876. count( * ) AS mrNum,
  6877. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  6878. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  6879. SUM( c.`level` = '合格' ) AS firstLevelNum,
  6880. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  6881. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  6882. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  6883. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  6884. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  6885. FROM
  6886. med_behospital_info a,
  6887. med_qcresult_cases c
  6888. WHERE
  6889. a.is_deleted = 'N'
  6890. AND c.is_deleted = 'N'
  6891. AND a.hospital_id = c.hospital_id
  6892. AND a.behospital_code = c.behospital_code
  6893. AND c.cases_id = 243
  6894. <if test="isPlacefile != null and isPlacefile != ''">
  6895. and a.is_placefile = #{isPlacefile}
  6896. </if>
  6897. AND a.qc_type_id != 0
  6898. <if test="hospitalId != null and hospitalId != ''">
  6899. AND a.hospital_id = #{hospitalId}
  6900. </if>
  6901. <if test="isPlacefile != null and isPlacefile == 0">
  6902. <if test="startDate != null and startDate != ''">
  6903. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6904. </if>
  6905. <if test="endDate != null and endDate != ''">
  6906. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6907. </if>
  6908. </if>
  6909. <if test="isPlacefile != null and isPlacefile == 1">
  6910. <if test="startDate != null and startDate != ''">
  6911. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6912. </if>
  6913. <if test="endDate != null and endDate != ''">
  6914. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6915. </if>
  6916. </if>
  6917. </select>
  6918. <!-- 病案首页完整率统计-全院(首页)-->
  6919. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  6920. SELECT
  6921. h1.emptyNum,
  6922. h1.mrNum,
  6923. h2.entryNum,
  6924. h1.mrNum * h2.entryNum AS entryTotleNum,
  6925. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  6926. CONCAT(
  6927. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  6928. '%'
  6929. ) AS emptyPercentStr
  6930. FROM
  6931. (
  6932. SELECT
  6933. sum( d.rule_type = 1 ) AS emptyNum,
  6934. count( DISTINCT a.behospital_code ) AS mrNum
  6935. FROM
  6936. med_behospital_info a,
  6937. med_qcresult_cases b,
  6938. med_qcresult_detail c,
  6939. qc_cases_entry d
  6940. WHERE
  6941. a.is_deleted = 'N'
  6942. AND b.is_deleted = 'N'
  6943. AND c.is_deleted = 'N'
  6944. AND d.is_deleted = 'N'
  6945. AND a.hospital_id = b.hospital_id
  6946. AND a.hospital_id = c.hospital_id
  6947. AND a.behospital_code = b.behospital_code
  6948. AND a.behospital_code = c.behospital_code
  6949. AND b.cases_id = c.cases_id
  6950. AND c.cases_id = d.cases_id
  6951. AND c.cases_entry_id = d.id
  6952. <if test="isPlacefile != null and isPlacefile != ''">
  6953. and a.is_placefile = #{isPlacefile}
  6954. </if>
  6955. AND d.cases_id = 243
  6956. AND a.qc_type_id != 0
  6957. <if test="hospitalId != null and hospitalId != ''">
  6958. AND a.hospital_id = #{hospitalId}
  6959. </if>
  6960. <if test="isPlacefile != null and isPlacefile == 0">
  6961. <if test="startDate != null and startDate != ''">
  6962. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6963. </if>
  6964. <if test="endDate != null and endDate != ''">
  6965. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6966. </if>
  6967. </if>
  6968. <if test="isPlacefile != null and isPlacefile == 1">
  6969. <if test="startDate != null and startDate != ''">
  6970. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6971. </if>
  6972. <if test="endDate != null and endDate != ''">
  6973. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6974. </if>
  6975. </if>
  6976. ) h1,(
  6977. SELECT
  6978. count(*) AS entryNum
  6979. FROM
  6980. qc_cases_entry
  6981. WHERE
  6982. is_deleted = 'N'
  6983. AND cases_id = 243
  6984. ) h2
  6985. </select>
  6986. <!-- 离院病人评分详情页-->
  6987. <select id="getAge" resultType="java.util.Map">
  6988. SELECT
  6989. a.behospital_code as behospitalCode,
  6990. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  6991. FROM
  6992. med_home_page a
  6993. WHERE
  6994. a.is_deleted = 'N'
  6995. AND a.hospital_id = #{hospitalId}
  6996. AND a.behospital_code IN
  6997. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  6998. '${item}'
  6999. </foreach>
  7000. </select>
  7001. <!-- 离院病人评分详情页-->
  7002. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  7003. SELECT
  7004. t.*
  7005. FROM
  7006. (SELECT DISTINCT
  7007. t1.hospital_id AS hospitalId,
  7008. t1.behospital_code AS behospitalCode,
  7009. t1.bed_code AS bedCode,
  7010. t1.LEVEL AS LEVEL,
  7011. t1.grade_type AS gradeType,
  7012. t1.score_res AS scoreRes,
  7013. t1.scoreBn,
  7014. t1.NAME AS NAME,
  7015. t1.sex AS sex,
  7016. t1.beh_dept_id AS behDeptId,
  7017. t1.beh_dept_name AS behDeptName,
  7018. t1.doctor_id AS doctorId,
  7019. t1.doctor_name AS doctorName,
  7020. t1.beh_doctor_id AS behDoctorId,
  7021. t1.beh_doctor_name AS behDoctorName,
  7022. t1.director_doctor_id AS directorDoctorId,
  7023. t1.director_doctor_name AS directorDoctorName,
  7024. t1.birthday AS birthday,
  7025. t1.behospital_date AS behospitalDate,
  7026. t1.leave_hospital_date AS leaveHospitalDate,
  7027. t1.placefile_date AS placefileDate,
  7028. t1.gmt_create AS gradeTime,
  7029. t1.diagnose,
  7030. t1.ward_name AS wardName,
  7031. t1.checkStatus,
  7032. t1.mrStatus,
  7033. t1.chName,
  7034. t1.mrName,
  7035. t1.chTime,
  7036. t1.mrTime,
  7037. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7038. t1.file_code AS fileCode
  7039. FROM
  7040. (
  7041. SELECT be.*,
  7042. ifnull(mci.status,0) AS checkStatus,
  7043. ifnull(hm_mci.status,0) AS mrStatus,
  7044. mci.check_name as chName,
  7045. e.score_res as scoreBn,
  7046. hm_mci.check_name as mrName,
  7047. mci.gmt_create as chTime,
  7048. hm_mci.gmt_create as mrTime
  7049. FROM
  7050. (
  7051. SELECT DISTINCT
  7052. tt1.*
  7053. FROM
  7054. (
  7055. SELECT
  7056. b.*,
  7057. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7058. c.grade_type,
  7059. c.score_res,
  7060. c.gmt_create
  7061. FROM
  7062. (
  7063. SELECT DISTINCT
  7064. a.hospital_id,
  7065. a.behospital_code,
  7066. a.bed_code,
  7067. a.NAME,
  7068. a.sex,
  7069. a.beh_dept_id,
  7070. a.beh_dept_name,
  7071. a.birthday,
  7072. a.behospital_date,
  7073. a.leave_hospital_date,
  7074. a.doctor_id,
  7075. a.doctor_name,
  7076. a.beh_doctor_id,
  7077. a.beh_doctor_name,
  7078. a.director_doctor_id,
  7079. a.director_doctor_name,
  7080. a.diagnose,
  7081. a.placefile_date,
  7082. a.ward_name,
  7083. a.file_code
  7084. FROM
  7085. med_behospital_info a
  7086. WHERE
  7087. a.is_deleted = 'N'
  7088. AND a.qc_type_id != 0
  7089. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7090. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7091. </if>
  7092. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7093. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7094. </if>
  7095. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7096. <if test="qcResultShortPageVO.startDate != null ">
  7097. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7098. </if>
  7099. <if test="qcResultShortPageVO.endDate != null ">
  7100. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7101. </if>
  7102. </if>
  7103. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7104. <if test="qcResultShortPageVO.startDate != null ">
  7105. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7106. </if>
  7107. <if test="qcResultShortPageVO.endDate != null">
  7108. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7109. </if>
  7110. </if>
  7111. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7112. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7113. </if>
  7114. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7115. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7116. </if>
  7117. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7118. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7119. </if>
  7120. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7121. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7122. </if>
  7123. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7124. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7125. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7126. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7127. </if>
  7128. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7129. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7130. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7131. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7132. </if>
  7133. ) b
  7134. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7135. AND b.hospital_id = c.hospital_id
  7136. AND b.behospital_code = c.behospital_code
  7137. ) tt1
  7138. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7139. ,med_medical_record tt2,
  7140. qc_mode tt3
  7141. WHERE
  7142. tt2.is_deleted = 'N'
  7143. AND tt3.is_deleted = 'N'
  7144. AND tt1.hospital_id = tt2.hospital_id
  7145. AND tt1.behospital_code = tt2.behospital_code
  7146. AND tt2.mode_id = tt3.id
  7147. AND tt3.`name` = '手术记录'
  7148. </if>
  7149. ) be
  7150. left join med_check_info mci
  7151. on mci.is_deleted = 'N'
  7152. and mci.check_type = 0
  7153. and be.hospital_id = mci.hospital_id
  7154. and be.behospital_code = mci.behospital_code
  7155. left join med_check_info hm_mci
  7156. on hm_mci.is_deleted = 'N'
  7157. and hm_mci.check_type = 1
  7158. and be.hospital_id = hm_mci.hospital_id
  7159. and be.behospital_code = hm_mci.behospital_code
  7160. LEFT JOIN med_qcresult_cases e
  7161. on be.behospital_code = e.behospital_code
  7162. and be.hospital_id = e.hospital_id
  7163. AND e.is_deleted = 'N'
  7164. and e.cases_id = 243
  7165. )t1
  7166. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7167. ,med_home_page t2
  7168. WHERE
  7169. t2.is_deleted = 'N'
  7170. AND t1.hospital_id = t2.hospital_id
  7171. AND t1.behospital_code = t2.behospital_code
  7172. AND (
  7173. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7174. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7175. )
  7176. </if>
  7177. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7178. , med_medical_record b,
  7179. med_medical_record_content c,
  7180. med_home_page t2
  7181. WHERE
  7182. b.is_deleted = 'N'
  7183. and c.is_deleted = 'N'
  7184. and t2.is_deleted = 'N'
  7185. and t1.hospital_id = b.hospital_id
  7186. and t1.hospital_id = c.hospital_id
  7187. and t1.hospital_id = t2.hospital_id
  7188. AND t1.behospital_code = b.behospital_code
  7189. AND t1.behospital_code = t2.behospital_code
  7190. AND b.rec_id = c.rec_id
  7191. and b.mode_id = '24'
  7192. </if>
  7193. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7194. ,med_home_page t2
  7195. WHERE
  7196. t2.is_deleted = 'N'
  7197. AND t1.hospital_id = t2.hospital_id
  7198. AND t1.behospital_code = t2.behospital_code
  7199. AND t2.leave_hospital_type = '非医嘱离院'
  7200. </if>
  7201. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7202. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7203. AND t1.hospital_id = t2.hospital_id
  7204. AND t1.behospital_code = t2.behospital_code
  7205. </if>
  7206. )t
  7207. where 1=1
  7208. <if test="qcResultShortPageVO.checkStatus != null">
  7209. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7210. </if>
  7211. <if test="qcResultShortPageVO.mrStatus != null">
  7212. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7213. </if>
  7214. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7215. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7216. </if>
  7217. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7218. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7219. </if>
  7220. <if test="qcResultShortPageVO.chTimeStart != null ">
  7221. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7222. </if>
  7223. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7224. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7225. </if>
  7226. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7227. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7228. </if>
  7229. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7230. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7231. </if>
  7232. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7233. AND t.`level` = #{qcResultShortPageVO.level}
  7234. </if>
  7235. </select>
  7236. <!-- 离院病人评分详情页-科室-->
  7237. <select id="leaveHosMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  7238. SELECT
  7239. t.*
  7240. FROM
  7241. (SELECT DISTINCT
  7242. t1.hospital_id AS hospitalId,
  7243. t1.behospital_code AS behospitalCode,
  7244. t1.bed_code AS bedCode,
  7245. t1.LEVEL AS LEVEL,
  7246. t1.grade_type AS gradeType,
  7247. t1.score_res AS scoreRes,
  7248. t1.scoreBn,
  7249. t1.NAME AS NAME,
  7250. t1.sex AS sex,
  7251. t1.beh_dept_id AS behDeptId,
  7252. t1.beh_dept_name AS behDeptName,
  7253. t1.doctor_id AS doctorId,
  7254. t1.doctor_name AS doctorName,
  7255. t1.beh_doctor_id AS behDoctorId,
  7256. t1.beh_doctor_name AS behDoctorName,
  7257. t1.director_doctor_id AS directorDoctorId,
  7258. t1.director_doctor_name AS directorDoctorName,
  7259. t1.birthday AS birthday,
  7260. t1.behospital_date AS behospitalDate,
  7261. t1.leave_hospital_date AS leaveHospitalDate,
  7262. t1.placefile_date AS placefileDate,
  7263. t1.gmt_create AS gradeTime,
  7264. t1.diagnose,
  7265. t1.ward_name AS wardName,
  7266. t1.checkStatus,
  7267. t1.mrStatus,
  7268. t1.chName,
  7269. t1.mrName,
  7270. t1.chTime,
  7271. t1.mrTime,
  7272. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  7273. t1.file_code AS fileCode
  7274. FROM
  7275. (
  7276. SELECT be.*,
  7277. ifnull(mci.status,0) AS checkStatus,
  7278. ifnull(hm_mci.status,0) AS mrStatus,
  7279. mci.check_name as chName,
  7280. e.score_res as scoreBn,
  7281. hm_mci.check_name as mrName,
  7282. mci.gmt_create as chTime,
  7283. hm_mci.gmt_create as mrTime
  7284. FROM
  7285. (
  7286. SELECT DISTINCT
  7287. tt1.*
  7288. FROM
  7289. (
  7290. SELECT
  7291. b.*,
  7292. ifnull(c.LEVEL,'未评分') as LEVEL ,
  7293. c.grade_type,
  7294. c.score_res,
  7295. c.gmt_create
  7296. FROM
  7297. (
  7298. SELECT DISTINCT
  7299. a.hospital_id,
  7300. a.behospital_code,
  7301. a.bed_code,
  7302. a.NAME,
  7303. a.sex,
  7304. a.beh_dept_id,
  7305. a.beh_dept_name,
  7306. a.birthday,
  7307. a.behospital_date,
  7308. a.leave_hospital_date,
  7309. a.doctor_id,
  7310. a.doctor_name,
  7311. a.beh_doctor_id,
  7312. a.beh_doctor_name,
  7313. a.director_doctor_id,
  7314. a.director_doctor_name,
  7315. a.diagnose,
  7316. a.placefile_date,
  7317. a.ward_name,
  7318. a.file_code
  7319. FROM
  7320. med_behospital_info a,
  7321. sys_user_dept b
  7322. WHERE
  7323. a.is_deleted = 'N'
  7324. AND b.is_deleted = 'N'
  7325. AND a.hospital_id = b.hospital_id
  7326. AND a.beh_dept_id = b.dept_id
  7327. AND a.qc_type_id != 0
  7328. <if test="qcResultShortPageVO.userId!=null">
  7329. AND b.user_id = #{qcResultShortPageVO.userId}
  7330. </if>
  7331. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7332. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7333. </if>
  7334. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7335. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7336. </if>
  7337. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7338. <if test="qcResultShortPageVO.startDate != null ">
  7339. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7340. </if>
  7341. <if test="qcResultShortPageVO.endDate != null ">
  7342. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7343. </if>
  7344. </if>
  7345. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7346. <if test="qcResultShortPageVO.startDate != null ">
  7347. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7348. </if>
  7349. <if test="qcResultShortPageVO.endDate != null">
  7350. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7351. </if>
  7352. </if>
  7353. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7354. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7355. </if>
  7356. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7357. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7358. </if>
  7359. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7360. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7361. </if>
  7362. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7363. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7364. </if>
  7365. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7366. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7367. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7368. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7369. </if>
  7370. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7371. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7372. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7373. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7374. </if>
  7375. ) b
  7376. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7377. AND b.hospital_id = c.hospital_id
  7378. AND b.behospital_code = c.behospital_code
  7379. ) tt1
  7380. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7381. ,med_medical_record tt2,
  7382. qc_mode tt3
  7383. WHERE
  7384. tt2.is_deleted = 'N'
  7385. AND tt3.is_deleted = 'N'
  7386. AND tt1.hospital_id = tt2.hospital_id
  7387. AND tt1.behospital_code = tt2.behospital_code
  7388. AND tt2.mode_id = tt3.id
  7389. AND tt3.`name` = '手术记录'
  7390. </if>
  7391. ) be
  7392. left join med_check_info mci
  7393. on mci.is_deleted = 'N'
  7394. and mci.check_type = 0
  7395. and be.hospital_id = mci.hospital_id
  7396. and be.behospital_code = mci.behospital_code
  7397. left join med_check_info hm_mci
  7398. on hm_mci.is_deleted = 'N'
  7399. and hm_mci.check_type = 1
  7400. and be.hospital_id = hm_mci.hospital_id
  7401. and be.behospital_code = hm_mci.behospital_code
  7402. LEFT JOIN med_qcresult_cases e
  7403. on be.behospital_code = e.behospital_code
  7404. and be.hospital_id = e.hospital_id
  7405. AND e.is_deleted = 'N'
  7406. and e.cases_id = 243
  7407. )t1
  7408. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7409. ,med_home_page t2
  7410. WHERE
  7411. t2.is_deleted = 'N'
  7412. AND t1.hospital_id = t2.hospital_id
  7413. AND t1.behospital_code = t2.behospital_code
  7414. AND (
  7415. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  7416. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7417. )
  7418. </if>
  7419. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7420. , med_medical_record b,
  7421. med_medical_record_content c,
  7422. med_home_page t2
  7423. WHERE
  7424. b.is_deleted = 'N'
  7425. and c.is_deleted = 'N'
  7426. and t2.is_deleted = 'N'
  7427. and t1.hospital_id = b.hospital_id
  7428. and t1.hospital_id = c.hospital_id
  7429. and t1.hospital_id = t2.hospital_id
  7430. AND t1.behospital_code = b.behospital_code
  7431. AND t1.behospital_code = t2.behospital_code
  7432. AND b.rec_id = c.rec_id
  7433. and b.mode_id = '24'
  7434. </if>
  7435. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7436. ,med_home_page t2
  7437. WHERE
  7438. t2.is_deleted = 'N'
  7439. AND t1.hospital_id = t2.hospital_id
  7440. AND t1.behospital_code = t2.behospital_code
  7441. AND t2.leave_hospital_type = '非医嘱离院'
  7442. </if>
  7443. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7444. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7445. AND t1.hospital_id = t2.hospital_id
  7446. AND t1.behospital_code = t2.behospital_code
  7447. </if>
  7448. )t
  7449. where 1=1
  7450. <if test="qcResultShortPageVO.checkStatus != null">
  7451. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7452. </if>
  7453. <if test="qcResultShortPageVO.mrStatus != null">
  7454. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7455. </if>
  7456. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7457. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7458. </if>
  7459. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7460. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7461. </if>
  7462. <if test="qcResultShortPageVO.chTimeStart != null ">
  7463. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7464. </if>
  7465. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7466. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7467. </if>
  7468. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7469. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7470. </if>
  7471. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7472. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7473. </if>
  7474. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7475. AND t.`level` = #{qcResultShortPageVO.level}
  7476. </if>
  7477. </select>
  7478. <!-- 病案首页改善率统计(首页)-->
  7479. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7480. SELECT
  7481. t2.homePageMRNum,
  7482. t1.improveNum,
  7483. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  7484. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7485. t1.improveToPassNum,
  7486. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  7487. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7488. t1.improveToFullNum,
  7489. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  7490. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7491. FROM
  7492. (
  7493. SELECT
  7494. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7495. sum( d.score_res = 20 ) AS improveToFullNum,
  7496. count(*) AS improveNum
  7497. FROM
  7498. med_behospital_info a,
  7499. med_home_page b,
  7500. med_qcresult_info c,
  7501. med_qcresult_cases d,
  7502. (
  7503. SELECT
  7504. m4.*
  7505. FROM
  7506. med_behospital_info m1,
  7507. med_home_page m2,
  7508. med_qcresult_info m3,
  7509. med_qcresult_cases m4
  7510. WHERE
  7511. m1.is_deleted = 'N'
  7512. AND m2.is_deleted = 'N'
  7513. AND m3.is_deleted = 'Y'
  7514. AND m4.is_deleted = 'Y'
  7515. AND m1.hospital_id = m2.hospital_id
  7516. AND m1.hospital_id = m3.hospital_id
  7517. AND m1.hospital_id = m4.hospital_id
  7518. AND m1.behospital_code = m2.behospital_code
  7519. AND m1.behospital_code = m3.behospital_code
  7520. AND m1.behospital_code = m4.behospital_code
  7521. AND m3.gmt_create = m4.gmt_create
  7522. AND m3.have_home_page = 1
  7523. AND m4.cases_id = 243
  7524. <if test="isPlacefile != null and isPlacefile != ''">
  7525. and m1.is_placefile = #{isPlacefile}
  7526. </if>
  7527. AND m1.qc_type_id != 0
  7528. <if test="hospitalId != null and hospitalId != ''">
  7529. AND m1.hospital_id = #{hospitalId}
  7530. </if>
  7531. <if test="isPlacefile != null and isPlacefile == 0">
  7532. <if test="startDate != null and startDate != ''">
  7533. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7534. </if>
  7535. <if test="endDate != null and endDate != ''">
  7536. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7537. </if>
  7538. </if>
  7539. <if test="isPlacefile != null and isPlacefile == 1">
  7540. <if test="startDate != null and startDate != ''">
  7541. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7542. </if>
  7543. <if test="endDate != null and endDate != ''">
  7544. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7545. </if>
  7546. </if>
  7547. GROUP BY
  7548. m1.behospital_code
  7549. ORDER BY
  7550. m1.behospital_code,
  7551. m4.gmt_create
  7552. ) e
  7553. WHERE
  7554. a.is_deleted = 'N'
  7555. AND b.is_deleted = 'N'
  7556. AND c.is_deleted = 'N'
  7557. AND d.is_deleted = 'N'
  7558. AND a.hospital_id = b.hospital_id
  7559. AND a.hospital_id = c.hospital_id
  7560. AND a.hospital_id = d.hospital_id
  7561. AND a.hospital_id = e.hospital_id
  7562. AND a.behospital_code = b.behospital_code
  7563. AND a.behospital_code = c.behospital_code
  7564. AND a.behospital_code = d.behospital_code
  7565. AND a.behospital_code = e.behospital_code
  7566. AND d.cases_id = 243
  7567. AND d.score_res > e.score_res
  7568. <if test="isPlacefile != null and isPlacefile != ''">
  7569. and a.is_placefile = #{isPlacefile}
  7570. </if>
  7571. AND a.qc_type_id != 0
  7572. <if test="hospitalId != null and hospitalId != ''">
  7573. AND a.hospital_id = #{hospitalId}
  7574. </if>
  7575. <if test="isPlacefile != null and isPlacefile == 0">
  7576. <if test="startDate != null and startDate != ''">
  7577. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7578. </if>
  7579. <if test="endDate != null and endDate != ''">
  7580. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7581. </if>
  7582. </if>
  7583. <if test="isPlacefile != null and isPlacefile == 1">
  7584. <if test="startDate != null and startDate != ''">
  7585. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7586. </if>
  7587. <if test="endDate != null and endDate != ''">
  7588. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7589. </if>
  7590. </if>
  7591. ) t1,
  7592. (
  7593. SELECT
  7594. count( DISTINCT a.behospital_code ) AS homePageMRNum
  7595. FROM
  7596. med_behospital_info a,
  7597. med_home_page b,
  7598. med_qcresult_info c
  7599. WHERE
  7600. a.is_deleted = 'N'
  7601. AND b.is_deleted = 'N'
  7602. AND a.hospital_id = b.hospital_id
  7603. AND a.hospital_id = c.hospital_id
  7604. AND a.behospital_code = b.behospital_code
  7605. AND a.behospital_code = c.behospital_code
  7606. AND a.qc_type_id != 0
  7607. <if test="isPlacefile != null and isPlacefile != ''">
  7608. and a.is_placefile = #{isPlacefile}
  7609. </if>
  7610. <if test="hospitalId != null and hospitalId != ''">
  7611. AND a.hospital_id = #{hospitalId}
  7612. </if>
  7613. <if test="isPlacefile != null and isPlacefile == 0">
  7614. <if test="startDate != null and startDate != ''">
  7615. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7616. </if>
  7617. <if test="endDate != null and endDate != ''">
  7618. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7619. </if>
  7620. </if>
  7621. <if test="isPlacefile != null and isPlacefile == 1">
  7622. <if test="startDate != null and startDate != ''">
  7623. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7624. </if>
  7625. <if test="endDate != null and endDate != ''">
  7626. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7627. </if>
  7628. </if>
  7629. ) t2
  7630. </select>
  7631. <!-- 质控核查统计(内页)-->
  7632. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  7633. SELECT
  7634. t.*
  7635. FROM
  7636. (SELECT
  7637. mr.beh_dept_id AS deptId,
  7638. mr.beh_dept_name AS deptName,
  7639. IFNULL( mr.mrNum, 0 ) AS mrNum,
  7640. ck.checkedNum AS checkedNum,
  7641. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  7642. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  7643. hmmr_t.homePageMRNum,
  7644. improve_t.improveNum,
  7645. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  7646. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7647. improve_t.improveToPassNum,
  7648. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  7649. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7650. improve_t.improveToFullNum,
  7651. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  7652. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7653. FROM
  7654. (
  7655. SELECT
  7656. a.beh_dept_id,
  7657. a.beh_dept_name,
  7658. count(*) AS mrNum
  7659. FROM
  7660. med_behospital_info a,
  7661. med_qcresult_info b
  7662. WHERE
  7663. a.is_deleted = 'N'
  7664. AND b.is_deleted = 'N'
  7665. AND a.hospital_id = b.hospital_id
  7666. AND a.behospital_code = b.behospital_code
  7667. AND a.qc_type_id != 0
  7668. <if test="isPlacefile != null and isPlacefile != ''">
  7669. and a.is_placefile = #{isPlacefile}
  7670. </if>
  7671. <if test="hospitalId != null and hospitalId != ''">
  7672. AND a.hospital_id = #{hospitalId}
  7673. </if>
  7674. <if test="isPlacefile != null and isPlacefile == 0">
  7675. <if test="startDate != null and startDate != ''">
  7676. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7677. </if>
  7678. <if test="endDate != null and endDate != ''">
  7679. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7680. </if>
  7681. </if>
  7682. <if test="isPlacefile != null and isPlacefile == 1">
  7683. <if test="startDate != null and startDate != ''">
  7684. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7685. </if>
  7686. <if test="endDate != null and endDate != ''">
  7687. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7688. </if>
  7689. </if>
  7690. <if test="deptName != null and deptName != ''">
  7691. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7692. </if>
  7693. GROUP BY
  7694. a.beh_dept_id,
  7695. a.beh_dept_name
  7696. ) mr
  7697. LEFT JOIN (
  7698. SELECT
  7699. a.beh_dept_id,
  7700. a.beh_dept_name,
  7701. count(*) AS checkedNum
  7702. FROM
  7703. med_behospital_info a,
  7704. med_qcresult_info b,
  7705. med_check_info c
  7706. WHERE
  7707. a.is_deleted = 'N'
  7708. AND b.is_deleted = 'N'
  7709. AND c.is_deleted = 'N'
  7710. AND a.hospital_id = b.hospital_id
  7711. AND a.hospital_id = c.hospital_id
  7712. AND a.behospital_code = b.behospital_code
  7713. AND a.behospital_code = c.behospital_code
  7714. AND a.qc_type_id != 0
  7715. AND ifnull(c.`status`,0) = 1
  7716. AND c.check_type in (0,2)
  7717. <if test="isPlacefile != null and isPlacefile != ''">
  7718. and a.is_placefile = #{isPlacefile}
  7719. </if>
  7720. <if test="hospitalId != null and hospitalId != ''">
  7721. AND a.hospital_id = #{hospitalId}
  7722. </if>
  7723. <if test="isPlacefile != null and isPlacefile == 0">
  7724. <if test="startDate != null and startDate != ''">
  7725. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7726. </if>
  7727. <if test="endDate != null and endDate != ''">
  7728. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7729. </if>
  7730. </if>
  7731. <if test="isPlacefile != null and isPlacefile == 1">
  7732. <if test="startDate != null and startDate != ''">
  7733. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7734. </if>
  7735. <if test="endDate != null and endDate != ''">
  7736. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7737. </if>
  7738. </if>
  7739. <if test="deptName != null and deptName != ''">
  7740. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7741. </if>
  7742. GROUP BY
  7743. a.beh_dept_id,
  7744. a.beh_dept_name
  7745. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  7746. AND mr.beh_dept_name = ck.beh_dept_name
  7747. LEFT JOIN (
  7748. SELECT
  7749. a.beh_dept_id,
  7750. a.beh_dept_name,
  7751. count( DISTINCT a.behospital_code ) AS homePageMRNum
  7752. FROM
  7753. med_behospital_info a,
  7754. med_home_page b,
  7755. med_qcresult_info c
  7756. WHERE
  7757. a.is_deleted = 'N'
  7758. AND b.is_deleted = 'N'
  7759. AND a.hospital_id = b.hospital_id
  7760. AND a.hospital_id = c.hospital_id
  7761. AND a.behospital_code = b.behospital_code
  7762. AND a.behospital_code = c.behospital_code
  7763. AND a.qc_type_id != 0
  7764. <if test="isPlacefile != null and isPlacefile != ''">
  7765. and a.is_placefile = #{isPlacefile}
  7766. </if>
  7767. <if test="hospitalId != null and hospitalId != ''">
  7768. AND a.hospital_id = #{hospitalId}
  7769. </if>
  7770. <if test="isPlacefile != null and isPlacefile == 0">
  7771. <if test="startDate != null and startDate != ''">
  7772. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7773. </if>
  7774. <if test="endDate != null and endDate != ''">
  7775. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7776. </if>
  7777. </if>
  7778. <if test="isPlacefile != null and isPlacefile == 1">
  7779. <if test="startDate != null and startDate != ''">
  7780. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7781. </if>
  7782. <if test="endDate != null and endDate != ''">
  7783. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7784. </if>
  7785. </if>
  7786. <if test="deptName != null and deptName != ''">
  7787. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7788. </if>
  7789. GROUP BY
  7790. a.beh_dept_id,
  7791. a.beh_dept_name
  7792. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  7793. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  7794. LEFT JOIN (
  7795. SELECT
  7796. a.beh_dept_id,
  7797. a.beh_dept_name,
  7798. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  7799. sum( d.score_res = 20 ) AS improveToFullNum,
  7800. count(*) AS improveNum
  7801. FROM
  7802. med_behospital_info a,
  7803. med_home_page b,
  7804. med_qcresult_info c,
  7805. med_qcresult_cases d,
  7806. (
  7807. SELECT
  7808. m4.*
  7809. FROM
  7810. med_behospital_info m1,
  7811. med_home_page m2,
  7812. med_qcresult_info m3,
  7813. med_qcresult_cases m4
  7814. WHERE
  7815. m1.is_deleted = 'N'
  7816. AND m2.is_deleted = 'N'
  7817. AND m3.is_deleted = 'Y'
  7818. AND m4.is_deleted = 'Y'
  7819. AND m1.hospital_id = m2.hospital_id
  7820. AND m1.hospital_id = m3.hospital_id
  7821. AND m1.hospital_id = m4.hospital_id
  7822. AND m1.behospital_code = m2.behospital_code
  7823. AND m1.behospital_code = m3.behospital_code
  7824. AND m1.behospital_code = m4.behospital_code
  7825. AND m3.gmt_create = m4.gmt_create
  7826. AND m3.have_home_page = 1
  7827. AND m4.cases_id = 243
  7828. <if test="isPlacefile != null and isPlacefile != ''">
  7829. and m1.is_placefile = #{isPlacefile}
  7830. </if>
  7831. AND m1.qc_type_id != 0
  7832. <if test="hospitalId != null and hospitalId != ''">
  7833. AND m1.hospital_id = #{hospitalId}
  7834. </if>
  7835. <if test="isPlacefile != null and isPlacefile == 0">
  7836. <if test="startDate != null and startDate != ''">
  7837. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  7838. </if>
  7839. <if test="endDate != null and endDate != ''">
  7840. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  7841. </if>
  7842. </if>
  7843. <if test="isPlacefile != null and isPlacefile == 1">
  7844. <if test="startDate != null and startDate != ''">
  7845. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  7846. </if>
  7847. <if test="endDate != null and endDate != ''">
  7848. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  7849. </if>
  7850. </if>
  7851. <if test="deptName != null and deptName != ''">
  7852. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7853. </if>
  7854. GROUP BY
  7855. m1.behospital_code
  7856. ORDER BY
  7857. m1.behospital_code,
  7858. m4.gmt_create
  7859. ) e
  7860. WHERE
  7861. a.is_deleted = 'N'
  7862. AND b.is_deleted = 'N'
  7863. AND c.is_deleted = 'N'
  7864. AND d.is_deleted = 'N'
  7865. AND a.hospital_id = b.hospital_id
  7866. AND a.hospital_id = c.hospital_id
  7867. AND a.hospital_id = d.hospital_id
  7868. AND a.hospital_id = e.hospital_id
  7869. AND a.behospital_code = b.behospital_code
  7870. AND a.behospital_code = c.behospital_code
  7871. AND a.behospital_code = d.behospital_code
  7872. AND a.behospital_code = e.behospital_code
  7873. AND d.cases_id = 243
  7874. AND d.score_res > e.score_res
  7875. <if test="hospitalId != null and hospitalId != ''">
  7876. AND a.hospital_id = #{hospitalId}
  7877. </if>
  7878. <if test="isPlacefile != null and isPlacefile == 0">
  7879. <if test="startDate != null and startDate != ''">
  7880. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  7881. </if>
  7882. <if test="endDate != null and endDate != ''">
  7883. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  7884. </if>
  7885. </if>
  7886. <if test="isPlacefile != null and isPlacefile == 1">
  7887. <if test="startDate != null and startDate != ''">
  7888. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  7889. </if>
  7890. <if test="endDate != null and endDate != ''">
  7891. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  7892. </if>
  7893. </if>
  7894. <if test="deptName != null and deptName != ''">
  7895. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  7896. </if>
  7897. GROUP BY
  7898. a.beh_dept_id,
  7899. a.beh_dept_name
  7900. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  7901. AND mr.beh_dept_name = improve_t.beh_dept_name
  7902. ) t
  7903. <if test="asc != null and asc !=''">
  7904. order by
  7905. <choose>
  7906. <when test='asc=="deptId"'>deptId asc</when>
  7907. <when test='asc=="deptName"'>deptName asc</when>
  7908. <when test='asc=="mrNum"'>mrNum asc</when>
  7909. <when test='asc=="checkedNum"'>checkedNum asc</when>
  7910. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  7911. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  7912. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  7913. <when test='asc=="improveNum"'>improveNum asc</when>
  7914. <when test='asc=="improvePercent"'>improvePercent asc</when>
  7915. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  7916. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  7917. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  7918. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  7919. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  7920. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  7921. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  7922. <otherwise>deptName asc</otherwise>
  7923. </choose>
  7924. </if>
  7925. <if test="desc != null and desc!=''">
  7926. order by
  7927. <choose>
  7928. <when test='desc=="deptId"'>deptId desc</when>
  7929. <when test='desc=="deptName"'>deptName desc</when>
  7930. <when test='desc=="mrNum"'>mrNum desc</when>
  7931. <when test='desc=="checkedNum"'>checkedNum desc</when>
  7932. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  7933. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  7934. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  7935. <when test='desc=="improveNum"'>improveNum desc</when>
  7936. <when test='desc=="improvePercent"'>improvePercent desc</when>
  7937. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  7938. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  7939. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  7940. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  7941. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  7942. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  7943. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  7944. <otherwise>deptName desc</otherwise>
  7945. </choose>
  7946. </if>
  7947. </select>
  7948. <!-- 质控核查统计-科室(内页)-->
  7949. <select id="qcCheckStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.ImproveByDeptDTO">
  7950. SELECT
  7951. t.*
  7952. FROM
  7953. (SELECT
  7954. mr.beh_dept_id AS deptId,
  7955. mr.beh_dept_name AS deptName,
  7956. mr.doctorId,
  7957. mr.doctorName,
  7958. IFNULL( mr.mrNum, 0 ) AS mrNum,
  7959. ck.checkedNum AS checkedNum,
  7960. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  7961. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  7962. hmmr_t.homePageMRNum,
  7963. improve_t.improveNum,
  7964. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  7965. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  7966. improve_t.improveToPassNum,
  7967. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  7968. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  7969. improve_t.improveToFullNum,
  7970. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  7971. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  7972. FROM
  7973. (
  7974. SELECT
  7975. a.beh_dept_id,
  7976. a.beh_dept_name,
  7977. a.doctor_id as doctorId,
  7978. a.doctor_name as doctorName,
  7979. count(*) AS mrNum
  7980. FROM
  7981. med_behospital_info a,
  7982. med_qcresult_info b,
  7983. sys_user_dept c
  7984. WHERE
  7985. a.is_deleted = 'N'
  7986. AND b.is_deleted = 'N'
  7987. AND c.is_deleted = 'N'
  7988. AND a.hospital_id = b.hospital_id
  7989. AND a.hospital_id = c.hospital_id
  7990. AND a.beh_dept_id = c.dept_id
  7991. AND a.behospital_code = b.behospital_code
  7992. AND a.qc_type_id != 0
  7993. <if test="userId!=null">
  7994. AND c.user_id = #{userId}
  7995. </if>
  7996. <if test="isPlacefile != null and isPlacefile != ''">
  7997. and a.is_placefile = #{isPlacefile}
  7998. </if>
  7999. <if test="hospitalId != null and hospitalId != ''">
  8000. AND a.hospital_id = #{hospitalId}
  8001. </if>
  8002. <if test="isPlacefile != null and isPlacefile == 0">
  8003. <if test="startDate != null and startDate != ''">
  8004. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8005. </if>
  8006. <if test="endDate != null and endDate != ''">
  8007. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8008. </if>
  8009. </if>
  8010. <if test="isPlacefile != null and isPlacefile == 1">
  8011. <if test="startDate != null and startDate != ''">
  8012. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8013. </if>
  8014. <if test="endDate != null and endDate != ''">
  8015. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8016. </if>
  8017. </if>
  8018. <if test="deptName != null and deptName != ''">
  8019. and a.beh_dept_name = #{deptName}
  8020. </if>
  8021. <if test="doctorName != null and doctorName != ''">
  8022. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8023. </if>
  8024. GROUP BY
  8025. a.doctor_id,
  8026. a.doctor_name
  8027. ) mr
  8028. LEFT JOIN (
  8029. SELECT
  8030. a.beh_dept_id,
  8031. a.beh_dept_name,
  8032. a.doctor_id as doctorId,
  8033. a.doctor_name as doctorName,
  8034. count(*) AS checkedNum
  8035. FROM
  8036. med_behospital_info a,
  8037. med_qcresult_info b,
  8038. med_check_info c,
  8039. sys_user_dept d
  8040. WHERE
  8041. a.is_deleted = 'N'
  8042. AND b.is_deleted = 'N'
  8043. AND c.is_deleted = 'N'
  8044. AND d.is_deleted = 'N'
  8045. AND a.hospital_id = b.hospital_id
  8046. AND a.hospital_id = c.hospital_id
  8047. AND a.hospital_id = d.hospital_id
  8048. AND a.behospital_code = b.behospital_code
  8049. AND a.behospital_code = c.behospital_code
  8050. AND a.beh_dept_id = d.dept_id
  8051. AND a.qc_type_id != 0
  8052. AND ifnull(c.`status`,0) = 1
  8053. AND c.check_type = 0
  8054. <if test="userId!=null">
  8055. AND d.user_id = #{userId}
  8056. </if>
  8057. <if test="isPlacefile != null and isPlacefile != ''">
  8058. and a.is_placefile = #{isPlacefile}
  8059. </if>
  8060. <if test="hospitalId != null and hospitalId != ''">
  8061. AND a.hospital_id = #{hospitalId}
  8062. </if>
  8063. <if test="isPlacefile != null and isPlacefile == 0">
  8064. <if test="startDate != null and startDate != ''">
  8065. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8066. </if>
  8067. <if test="endDate != null and endDate != ''">
  8068. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8069. </if>
  8070. </if>
  8071. <if test="isPlacefile != null and isPlacefile == 1">
  8072. <if test="startDate != null and startDate != ''">
  8073. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8074. </if>
  8075. <if test="endDate != null and endDate != ''">
  8076. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8077. </if>
  8078. </if>
  8079. <if test="deptName != null and deptName != ''">
  8080. and a.beh_dept_name = #{deptName}
  8081. </if>
  8082. <if test="doctorName != null and doctorName != ''">
  8083. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8084. </if>
  8085. GROUP BY
  8086. a.doctor_id,
  8087. a.doctor_name
  8088. ) ck ON mr.doctorId = ck.doctorId
  8089. AND mr.doctorName = ck.doctorName
  8090. LEFT JOIN (
  8091. SELECT
  8092. a.beh_dept_id,
  8093. a.beh_dept_name,
  8094. a.doctor_id as doctorId,
  8095. a.doctor_name as doctorName,
  8096. count( DISTINCT a.behospital_code ) AS homePageMRNum
  8097. FROM
  8098. med_behospital_info a,
  8099. med_home_page b,
  8100. med_qcresult_info c,
  8101. sys_user_dept d
  8102. WHERE
  8103. a.is_deleted = 'N'
  8104. AND b.is_deleted = 'N'
  8105. AND c.is_deleted = 'N'
  8106. AND d.is_deleted = 'N'
  8107. AND a.hospital_id = b.hospital_id
  8108. AND a.hospital_id = c.hospital_id
  8109. AND a.hospital_id = d.hospital_id
  8110. AND a.behospital_code = b.behospital_code
  8111. AND a.behospital_code = c.behospital_code
  8112. AND a.beh_dept_id = d.dept_id
  8113. AND a.qc_type_id != 0
  8114. <if test="userId!=null">
  8115. AND d.user_id = #{userId}
  8116. </if>
  8117. <if test="isPlacefile != null and isPlacefile != ''">
  8118. and a.is_placefile = #{isPlacefile}
  8119. </if>
  8120. <if test="hospitalId != null and hospitalId != ''">
  8121. AND a.hospital_id = #{hospitalId}
  8122. </if>
  8123. <if test="isPlacefile != null and isPlacefile == 0">
  8124. <if test="startDate != null and startDate != ''">
  8125. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8126. </if>
  8127. <if test="endDate != null and endDate != ''">
  8128. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8129. </if>
  8130. </if>
  8131. <if test="isPlacefile != null and isPlacefile == 1">
  8132. <if test="startDate != null and startDate != ''">
  8133. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8134. </if>
  8135. <if test="endDate != null and endDate != ''">
  8136. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8137. </if>
  8138. </if>
  8139. <if test="deptName != null and deptName != ''">
  8140. and a.beh_dept_name = #{deptName}
  8141. </if>
  8142. <if test="doctorName != null and doctorName != ''">
  8143. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8144. </if>
  8145. GROUP BY
  8146. a.doctor_id,
  8147. a.doctor_name
  8148. ) hmmr_t ON mr.doctorId = hmmr_t.doctorId
  8149. AND mr.doctorName = hmmr_t.doctorName
  8150. LEFT JOIN (
  8151. SELECT
  8152. a.beh_dept_id,
  8153. a.beh_dept_name,
  8154. a.doctor_id as doctorId,
  8155. a.doctor_name as doctorName,
  8156. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  8157. sum( d.score_res = 20 ) AS improveToFullNum,
  8158. count(*) AS improveNum
  8159. FROM
  8160. med_behospital_info a,
  8161. med_home_page b,
  8162. med_qcresult_info c,
  8163. med_qcresult_cases d,
  8164. sys_user_dept f,
  8165. (
  8166. SELECT
  8167. m4.*
  8168. FROM
  8169. med_behospital_info m1,
  8170. med_home_page m2,
  8171. med_qcresult_info m3,
  8172. med_qcresult_cases m4
  8173. WHERE
  8174. m1.is_deleted = 'N'
  8175. AND m2.is_deleted = 'N'
  8176. AND m3.is_deleted = 'Y'
  8177. AND m4.is_deleted = 'Y'
  8178. AND m1.hospital_id = m2.hospital_id
  8179. AND m1.hospital_id = m3.hospital_id
  8180. AND m1.hospital_id = m4.hospital_id
  8181. AND m1.behospital_code = m2.behospital_code
  8182. AND m1.behospital_code = m3.behospital_code
  8183. AND m1.behospital_code = m4.behospital_code
  8184. AND m3.gmt_create = m4.gmt_create
  8185. AND m3.have_home_page = 1
  8186. AND m4.cases_id = 243
  8187. <if test="isPlacefile != null and isPlacefile != ''">
  8188. and m1.is_placefile = #{isPlacefile}
  8189. </if>
  8190. AND m1.qc_type_id != 0
  8191. <if test="hospitalId != null and hospitalId != ''">
  8192. AND m1.hospital_id = #{hospitalId}
  8193. </if>
  8194. <if test="isPlacefile != null and isPlacefile == 0">
  8195. <if test="startDate != null and startDate != ''">
  8196. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  8197. </if>
  8198. <if test="endDate != null and endDate != ''">
  8199. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  8200. </if>
  8201. </if>
  8202. <if test="isPlacefile != null and isPlacefile == 1">
  8203. <if test="startDate != null and startDate != ''">
  8204. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  8205. </if>
  8206. <if test="endDate != null and endDate != ''">
  8207. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  8208. </if>
  8209. </if>
  8210. <if test="deptName != null and deptName != ''">
  8211. and m1.beh_dept_name = #{deptName}
  8212. </if>
  8213. GROUP BY
  8214. m1.behospital_code
  8215. ORDER BY
  8216. m1.behospital_code,
  8217. m4.gmt_create
  8218. ) e
  8219. WHERE
  8220. a.is_deleted = 'N'
  8221. AND b.is_deleted = 'N'
  8222. AND c.is_deleted = 'N'
  8223. AND d.is_deleted = 'N'
  8224. AND f.is_deleted = 'N'
  8225. AND a.hospital_id = b.hospital_id
  8226. AND a.hospital_id = c.hospital_id
  8227. AND a.hospital_id = d.hospital_id
  8228. AND a.hospital_id = e.hospital_id
  8229. AND a.hospital_id = f.hospital_id
  8230. AND a.behospital_code = b.behospital_code
  8231. AND a.behospital_code = c.behospital_code
  8232. AND a.behospital_code = d.behospital_code
  8233. AND a.behospital_code = e.behospital_code
  8234. AND a.beh_dept_id = f.dept_id
  8235. <if test="userId!=null">
  8236. AND f.user_id = #{userId}
  8237. </if>
  8238. AND d.cases_id = 243
  8239. AND d.score_res > e.score_res
  8240. <if test="hospitalId != null and hospitalId != ''">
  8241. AND a.hospital_id = #{hospitalId}
  8242. </if>
  8243. <if test="isPlacefile != null and isPlacefile == 0">
  8244. <if test="startDate != null and startDate != ''">
  8245. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8246. </if>
  8247. <if test="endDate != null and endDate != ''">
  8248. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8249. </if>
  8250. </if>
  8251. <if test="isPlacefile != null and isPlacefile == 1">
  8252. <if test="startDate != null and startDate != ''">
  8253. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8254. </if>
  8255. <if test="endDate != null and endDate != ''">
  8256. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8257. </if>
  8258. </if>
  8259. <if test="doctorName != null and doctorName != ''">
  8260. and a.doctor_name LIKE CONCAT( '%', #{doctorName}, '%' )
  8261. </if>
  8262. <if test="deptName != null and deptName != ''">
  8263. and a.beh_dept_name = #{deptName}
  8264. </if>
  8265. GROUP BY
  8266. a.doctor_id,
  8267. a.doctor_name
  8268. ) improve_t ON mr.doctorId = improve_t.doctorId
  8269. AND mr.doctorName = improve_t.doctorName
  8270. ) t
  8271. <if test="asc != null and asc !=''">
  8272. order by
  8273. <choose>
  8274. <when test='asc=="deptId"'>deptId asc</when>
  8275. <when test='asc=="deptName"'>deptName asc</when>
  8276. <when test='asc=="doctorName"'>doctorName asc</when>
  8277. <when test='asc=="mrNum"'>mrNum asc</when>
  8278. <when test='asc=="checkedNum"'>checkedNum asc</when>
  8279. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  8280. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  8281. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  8282. <when test='asc=="improveNum"'>improveNum asc</when>
  8283. <when test='asc=="improvePercent"'>improvePercent asc</when>
  8284. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  8285. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  8286. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  8287. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  8288. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  8289. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  8290. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  8291. <otherwise>doctorName asc</otherwise>
  8292. </choose>
  8293. </if>
  8294. <if test="desc != null and desc!=''">
  8295. order by
  8296. <choose>
  8297. <when test='desc=="deptId"'>deptId desc</when>
  8298. <when test='desc=="deptName"'>deptName desc</when>
  8299. <when test='desc=="doctorName"'>doctorName desc</when>
  8300. <when test='desc=="mrNum"'>mrNum desc</when>
  8301. <when test='desc=="checkedNum"'>checkedNum desc</when>
  8302. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  8303. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  8304. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  8305. <when test='desc=="improveNum"'>improveNum desc</when>
  8306. <when test='desc=="improvePercent"'>improvePercent desc</when>
  8307. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  8308. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  8309. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  8310. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  8311. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  8312. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  8313. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  8314. <otherwise>deptName desc</otherwise>
  8315. </choose>
  8316. </if>
  8317. </select>
  8318. <!-- 离院病人评分详情页导出-->
  8319. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  8320. SELECT
  8321. f1.behDeptId,
  8322. f1.behDeptName,
  8323. f1.doctorName,
  8324. f1.patName,
  8325. f1.behospitalCode,
  8326. f1.hospitalId,
  8327. f1.behospitalDate,
  8328. f1.leaveHospitalDate,
  8329. f1.score,
  8330. f2.avgScore,
  8331. f1.scoreBn,
  8332. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8333. f1.msg,
  8334. f1.caseName,
  8335. </if>
  8336. f1.checkStatus,
  8337. f1.mrStatus,
  8338. f1.chName,
  8339. f1.mrName,
  8340. f1.chTime,
  8341. f1.mrTime
  8342. FROM
  8343. (SELECT
  8344. t.doctorName,
  8345. t.`name` AS patName,
  8346. t.behospitalCode AS behospitalCode,
  8347. t.behospitalDate AS behospitalDate,
  8348. t.leaveHospitalDate AS leaveHospitalDate,
  8349. qi.score_res AS score,
  8350. t.scoreBn,
  8351. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8352. qd.msg AS msg,
  8353. qc.NAME AS caseName,
  8354. </if>
  8355. t.behDeptId,
  8356. t.behDeptName,
  8357. t.hospitalId,
  8358. t.checkStatus,
  8359. t.mrStatus,
  8360. t.chName,
  8361. t.mrName,
  8362. t.chTime,
  8363. t.mrTime
  8364. FROM
  8365. (SELECT DISTINCT
  8366. t1.hospital_id AS hospitalId,
  8367. t1.behospital_code AS behospitalCode,
  8368. t1.bed_code AS bedCode,
  8369. t1.LEVEL AS LEVEL,
  8370. t1.grade_type AS gradeType,
  8371. t1.score_res AS scoreRes,
  8372. t1.scoreBn,
  8373. t1.NAME AS NAME,
  8374. t1.sex AS sex,
  8375. t1.beh_dept_id AS behDeptId,
  8376. t1.beh_dept_name AS behDeptName,
  8377. t1.doctor_id AS doctorId,
  8378. t1.doctor_name AS doctorName,
  8379. t1.beh_doctor_id AS behDoctorId,
  8380. t1.beh_doctor_name AS behDoctorName,
  8381. t1.director_doctor_id AS directorDoctorId,
  8382. t1.director_doctor_name AS directorDoctorName,
  8383. t1.birthday AS birthday,
  8384. t1.behospital_date AS behospitalDate,
  8385. t1.leave_hospital_date AS leaveHospitalDate,
  8386. t1.placefile_date AS placefileDate,
  8387. t1.gmt_create AS gradeTime,
  8388. t1.diagnose,
  8389. t1.ward_name AS wardName,
  8390. t1.checkStatus,
  8391. t1.mrStatus,
  8392. t1.chName,
  8393. t1.mrName,
  8394. t1.chTime,
  8395. t1.mrTime,
  8396. t2.age,
  8397. t1.file_code AS fileCode
  8398. FROM
  8399. (
  8400. SELECT be.*,
  8401. ifnull(mci.status,0) AS checkStatus,
  8402. ifnull(hm_mci.status,0) AS mrStatus,
  8403. mci.check_name as chName,
  8404. e.score_res as scoreBn,
  8405. hm_mci.check_name as mrName,
  8406. mci.gmt_create as chTime,
  8407. hm_mci.gmt_create as mrTime
  8408. FROM
  8409. (
  8410. SELECT DISTINCT
  8411. tt1.*
  8412. FROM
  8413. (
  8414. SELECT
  8415. b.*,
  8416. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8417. c.grade_type,
  8418. c.score_res,
  8419. c.gmt_create
  8420. FROM
  8421. (
  8422. SELECT DISTINCT
  8423. a.hospital_id,
  8424. a.behospital_code,
  8425. a.bed_code,
  8426. a.NAME,
  8427. a.sex,
  8428. a.beh_dept_id,
  8429. a.beh_dept_name,
  8430. a.birthday,
  8431. a.behospital_date,
  8432. a.leave_hospital_date,
  8433. a.doctor_id,
  8434. a.doctor_name,
  8435. a.beh_doctor_id,
  8436. a.beh_doctor_name,
  8437. a.director_doctor_id,
  8438. a.director_doctor_name,
  8439. a.diagnose,
  8440. a.placefile_date,
  8441. a.ward_name,
  8442. a.file_code
  8443. FROM
  8444. med_behospital_info a
  8445. WHERE
  8446. a.is_deleted = 'N'
  8447. AND a.qc_type_id != 0
  8448. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8449. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8450. </if>
  8451. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8452. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8453. </if>
  8454. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8455. <if test="qcResultShortPageVO.startDate != null ">
  8456. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8457. </if>
  8458. <if test="qcResultShortPageVO.endDate != null ">
  8459. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8460. </if>
  8461. </if>
  8462. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8463. <if test="qcResultShortPageVO.startDate != null ">
  8464. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8465. </if>
  8466. <if test="qcResultShortPageVO.endDate != null">
  8467. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8468. </if>
  8469. </if>
  8470. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8471. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8472. </if>
  8473. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8474. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8475. </if>
  8476. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8477. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8478. </if>
  8479. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8480. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8481. </if>
  8482. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8483. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8484. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8485. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8486. </if>
  8487. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8488. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8489. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8490. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8491. </if>
  8492. ) b
  8493. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8494. AND b.hospital_id = c.hospital_id
  8495. AND b.behospital_code = c.behospital_code
  8496. ) tt1
  8497. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8498. ,med_medical_record tt2,
  8499. qc_mode tt3
  8500. WHERE
  8501. tt2.is_deleted = 'N'
  8502. AND tt3.is_deleted = 'N'
  8503. AND tt1.hospital_id = tt2.hospital_id
  8504. AND tt1.behospital_code = tt2.behospital_code
  8505. AND tt2.mode_id = tt3.id
  8506. AND tt3.`name` = '手术记录'
  8507. </if>
  8508. ) be
  8509. left join med_check_info mci
  8510. on mci.is_deleted = 'N'
  8511. and mci.check_type = 0
  8512. and be.hospital_id = mci.hospital_id
  8513. and be.behospital_code = mci.behospital_code
  8514. left join med_check_info hm_mci
  8515. on hm_mci.is_deleted = 'N'
  8516. and hm_mci.check_type = 1
  8517. and be.hospital_id = hm_mci.hospital_id
  8518. and be.behospital_code = hm_mci.behospital_code
  8519. LEFT JOIN med_qcresult_cases e
  8520. on be.behospital_code = e.behospital_code
  8521. and be.hospital_id = e.hospital_id
  8522. AND e.is_deleted = 'N'
  8523. and e.cases_id = 243
  8524. )t1
  8525. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8526. ,med_home_page t2
  8527. WHERE
  8528. t2.is_deleted = 'N'
  8529. AND t1.hospital_id = t2.hospital_id
  8530. AND t1.behospital_code = t2.behospital_code
  8531. AND (
  8532. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  8533. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  8534. )
  8535. </if>
  8536. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8537. ,med_home_page t2
  8538. WHERE
  8539. t2.is_deleted = 'N'
  8540. AND t1.hospital_id = t2.hospital_id
  8541. AND t1.behospital_code = t2.behospital_code
  8542. AND t2.return_to_type = '死亡'
  8543. </if>
  8544. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8545. ,med_home_page t2
  8546. WHERE
  8547. t2.is_deleted = 'N'
  8548. AND t1.hospital_id = t2.hospital_id
  8549. AND t1.behospital_code = t2.behospital_code
  8550. AND t2.leave_hospital_type = '非医嘱离院'
  8551. </if>
  8552. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8553. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8554. AND t1.hospital_id = t2.hospital_id
  8555. AND t1.behospital_code = t2.behospital_code
  8556. </if>
  8557. )t
  8558. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8559. AND t.hospitalId = qi.hospital_id
  8560. AND t.behospitalCode = qi.behospital_code
  8561. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8562. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  8563. AND t.hospitalId = qd.hospital_id
  8564. AND t.behospitalCode = qd.behospital_code
  8565. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  8566. AND qd.cases_id = qc.id
  8567. </if>
  8568. where 1=1
  8569. <if test="qcResultShortPageVO.checkStatus != null">
  8570. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8571. </if>
  8572. <if test="qcResultShortPageVO.mrStatus != null">
  8573. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8574. </if>
  8575. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8576. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8577. </if>
  8578. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8579. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8580. </if>
  8581. <if test="qcResultShortPageVO.chTimeStart != null ">
  8582. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8583. </if>
  8584. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8585. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8586. </if>
  8587. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8588. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8589. </if>
  8590. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8591. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8592. </if>
  8593. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8594. AND t.`level` = #{qcResultShortPageVO.level}
  8595. </if>)f1,(SELECT
  8596. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  8597. t.behDeptId,
  8598. t.behDeptName
  8599. FROM
  8600. (SELECT DISTINCT
  8601. t1.hospital_id AS hospitalId,
  8602. t1.behospital_code AS behospitalCode,
  8603. t1.bed_code AS bedCode,
  8604. t1.LEVEL AS LEVEL,
  8605. t1.grade_type AS gradeType,
  8606. t1.score_res AS scoreRes,
  8607. t1.NAME AS NAME,
  8608. t1.sex AS sex,
  8609. t1.beh_dept_id AS behDeptId,
  8610. t1.beh_dept_name AS behDeptName,
  8611. t1.doctor_id AS doctorId,
  8612. t1.doctor_name AS doctorName,
  8613. t1.beh_doctor_id AS behDoctorId,
  8614. t1.beh_doctor_name AS behDoctorName,
  8615. t1.director_doctor_id AS directorDoctorId,
  8616. t1.director_doctor_name AS directorDoctorName,
  8617. t1.birthday AS birthday,
  8618. t1.behospital_date AS behospitalDate,
  8619. t1.leave_hospital_date AS leaveHospitalDate,
  8620. t1.placefile_date AS placefileDate,
  8621. t1.gmt_create AS gradeTime,
  8622. t1.diagnose,
  8623. t1.ward_name AS wardName,
  8624. t1.checkStatus,
  8625. t1.mrStatus,
  8626. t1.chName,
  8627. t1.mrName,
  8628. t1.chTime,
  8629. t1.mrTime,
  8630. t2.age,
  8631. t1.file_code AS fileCode
  8632. FROM
  8633. (
  8634. SELECT be.*,
  8635. ifnull(mci.status,0) AS checkStatus,
  8636. ifnull(hm_mci.status,0) AS mrStatus,
  8637. mci.check_name as chName,
  8638. hm_mci.check_name as mrName,
  8639. mci.gmt_create as chTime,
  8640. hm_mci.gmt_create as mrTime
  8641. FROM
  8642. (
  8643. SELECT DISTINCT
  8644. tt1.*
  8645. FROM
  8646. (
  8647. SELECT
  8648. b.*,
  8649. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8650. c.grade_type,
  8651. c.score_res,
  8652. c.gmt_create
  8653. FROM
  8654. (
  8655. SELECT DISTINCT
  8656. a.hospital_id,
  8657. a.behospital_code,
  8658. a.bed_code,
  8659. a.NAME,
  8660. a.sex,
  8661. a.beh_dept_id,
  8662. a.beh_dept_name,
  8663. a.birthday,
  8664. a.behospital_date,
  8665. a.leave_hospital_date,
  8666. a.doctor_id,
  8667. a.doctor_name,
  8668. a.beh_doctor_id,
  8669. a.beh_doctor_name,
  8670. a.director_doctor_id,
  8671. a.director_doctor_name,
  8672. a.diagnose,
  8673. a.placefile_date,
  8674. a.ward_name,
  8675. a.file_code
  8676. FROM
  8677. med_behospital_info a
  8678. WHERE
  8679. a.is_deleted = 'N'
  8680. AND a.qc_type_id != 0
  8681. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8682. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8683. </if>
  8684. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8685. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8686. </if>
  8687. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8688. <if test="qcResultShortPageVO.startDate != null ">
  8689. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8690. </if>
  8691. <if test="qcResultShortPageVO.endDate != null ">
  8692. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8693. </if>
  8694. </if>
  8695. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8696. <if test="qcResultShortPageVO.startDate != null ">
  8697. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8698. </if>
  8699. <if test="qcResultShortPageVO.endDate != null">
  8700. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8701. </if>
  8702. </if>
  8703. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8704. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8705. </if>
  8706. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8707. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8708. </if>
  8709. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8710. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8711. </if>
  8712. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8713. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8714. </if>
  8715. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8716. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8717. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8718. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8719. </if>
  8720. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8721. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8722. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8723. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8724. </if>
  8725. ) b
  8726. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  8727. AND b.hospital_id = c.hospital_id
  8728. AND b.behospital_code = c.behospital_code
  8729. ) tt1
  8730. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  8731. ,med_medical_record tt2,
  8732. qc_mode tt3
  8733. WHERE
  8734. tt2.is_deleted = 'N'
  8735. AND tt3.is_deleted = 'N'
  8736. AND tt1.hospital_id = tt2.hospital_id
  8737. AND tt1.behospital_code = tt2.behospital_code
  8738. AND tt2.mode_id = tt3.id
  8739. AND tt3.`name` = '手术记录'
  8740. </if>
  8741. ) be
  8742. left join med_check_info mci
  8743. on mci.is_deleted = 'N'
  8744. and mci.check_type = 0
  8745. and be.hospital_id = mci.hospital_id
  8746. and be.behospital_code = mci.behospital_code
  8747. left join med_check_info hm_mci
  8748. on hm_mci.is_deleted = 'N'
  8749. and hm_mci.check_type = 1
  8750. and be.hospital_id = hm_mci.hospital_id
  8751. and be.behospital_code = hm_mci.behospital_code
  8752. )t1
  8753. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  8754. ,med_home_page t2
  8755. WHERE
  8756. t2.is_deleted = 'N'
  8757. AND t1.hospital_id = t2.hospital_id
  8758. AND t1.behospital_code = t2.behospital_code
  8759. AND (
  8760. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  8761. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  8762. )
  8763. </if>
  8764. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  8765. ,med_home_page t2
  8766. WHERE
  8767. t2.is_deleted = 'N'
  8768. AND t1.hospital_id = t2.hospital_id
  8769. AND t1.behospital_code = t2.behospital_code
  8770. AND t2.return_to_type = '死亡'
  8771. </if>
  8772. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  8773. ,med_home_page t2
  8774. WHERE
  8775. t2.is_deleted = 'N'
  8776. AND t1.hospital_id = t2.hospital_id
  8777. AND t1.behospital_code = t2.behospital_code
  8778. AND t2.leave_hospital_type = '非医嘱离院'
  8779. </if>
  8780. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  8781. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  8782. AND t1.hospital_id = t2.hospital_id
  8783. AND t1.behospital_code = t2.behospital_code
  8784. </if>
  8785. )t
  8786. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8787. AND t.hospitalId = qi.hospital_id
  8788. AND t.behospitalCode = qi.behospital_code
  8789. where 1=1
  8790. <if test="qcResultShortPageVO.checkStatus != null">
  8791. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8792. </if>
  8793. <if test="qcResultShortPageVO.mrStatus != null">
  8794. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8795. </if>
  8796. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8797. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8798. </if>
  8799. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8800. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8801. </if>
  8802. <if test="qcResultShortPageVO.chTimeStart != null ">
  8803. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8804. </if>
  8805. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8806. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8807. </if>
  8808. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8809. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8810. </if>
  8811. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8812. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8813. </if>
  8814. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8815. AND t.`level` = #{qcResultShortPageVO.level}
  8816. </if>
  8817. GROUP BY
  8818. t.behDeptId,
  8819. t.behDeptName
  8820. )f2
  8821. WHERE
  8822. f1.behDeptId = f2.behDeptId
  8823. AND f1.behDeptName = f2.behDeptName
  8824. </select>
  8825. <!-- 离院病人评分详情页导出-科室-->
  8826. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  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.doctorId,
  8853. t.`name` AS patName,
  8854. t.behospitalCode AS behospitalCode,
  8855. t.behospitalDate AS behospitalDate,
  8856. t.leaveHospitalDate AS leaveHospitalDate,
  8857. qi.score_res AS score,
  8858. t.scoreBn,
  8859. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  8860. qd.msg AS msg,
  8861. qc.NAME AS caseName,
  8862. </if>
  8863. t.behDeptId,
  8864. t.behDeptName,
  8865. t.hospitalId,
  8866. t.checkStatus,
  8867. t.mrStatus,
  8868. t.chName,
  8869. t.mrName,
  8870. t.chTime,
  8871. t.mrTime
  8872. FROM
  8873. (SELECT DISTINCT
  8874. t1.hospital_id AS hospitalId,
  8875. t1.behospital_code AS behospitalCode,
  8876. t1.bed_code AS bedCode,
  8877. t1.LEVEL AS LEVEL,
  8878. t1.grade_type AS gradeType,
  8879. t1.score_res AS scoreRes,
  8880. t1.scoreBn,
  8881. t1.NAME AS NAME,
  8882. t1.sex AS sex,
  8883. t1.beh_dept_id AS behDeptId,
  8884. t1.beh_dept_name AS behDeptName,
  8885. t1.doctor_id AS doctorId,
  8886. t1.doctor_name AS doctorName,
  8887. t1.beh_doctor_id AS behDoctorId,
  8888. t1.beh_doctor_name AS behDoctorName,
  8889. t1.director_doctor_id AS directorDoctorId,
  8890. t1.director_doctor_name AS directorDoctorName,
  8891. t1.birthday AS birthday,
  8892. t1.behospital_date AS behospitalDate,
  8893. t1.leave_hospital_date AS leaveHospitalDate,
  8894. t1.placefile_date AS placefileDate,
  8895. t1.gmt_create AS gradeTime,
  8896. t1.diagnose,
  8897. t1.ward_name AS wardName,
  8898. t1.checkStatus,
  8899. t1.mrStatus,
  8900. t1.chName,
  8901. t1.mrName,
  8902. t1.chTime,
  8903. t1.mrTime,
  8904. t2.age,
  8905. t1.file_code AS fileCode
  8906. FROM
  8907. (
  8908. SELECT be.*,
  8909. ifnull(mci.status,0) AS checkStatus,
  8910. ifnull(hm_mci.status,0) AS mrStatus,
  8911. mci.check_name as chName,
  8912. e.score_res as scoreBn,
  8913. hm_mci.check_name as mrName,
  8914. mci.gmt_create as chTime,
  8915. hm_mci.gmt_create as mrTime
  8916. FROM
  8917. (
  8918. SELECT DISTINCT
  8919. tt1.*
  8920. FROM
  8921. (
  8922. SELECT
  8923. b.*,
  8924. ifnull(c.LEVEL,'未评分') as LEVEL ,
  8925. c.grade_type,
  8926. c.score_res,
  8927. c.gmt_create
  8928. FROM
  8929. (
  8930. SELECT DISTINCT
  8931. a.hospital_id,
  8932. a.behospital_code,
  8933. a.bed_code,
  8934. a.NAME,
  8935. a.sex,
  8936. a.beh_dept_id,
  8937. a.beh_dept_name,
  8938. a.birthday,
  8939. a.behospital_date,
  8940. a.leave_hospital_date,
  8941. a.doctor_id,
  8942. a.doctor_name,
  8943. a.beh_doctor_id,
  8944. a.beh_doctor_name,
  8945. a.director_doctor_id,
  8946. a.director_doctor_name,
  8947. a.diagnose,
  8948. a.placefile_date,
  8949. a.ward_name,
  8950. a.file_code
  8951. FROM
  8952. med_behospital_info a,
  8953. sys_user_dept b
  8954. WHERE
  8955. a.is_deleted = 'N'
  8956. AND b.is_deleted = 'N'
  8957. AND a.hospital_id = b.hospital_id
  8958. AND a.beh_dept_id = b.dept_id
  8959. AND a.qc_type_id != 0
  8960. <if test="qcResultShortPageVO.userId!=null">
  8961. AND b.user_id = #{qcResultShortPageVO.userId}
  8962. </if>
  8963. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8964. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8965. </if>
  8966. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8967. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8968. </if>
  8969. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8970. <if test="qcResultShortPageVO.startDate != null ">
  8971. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8972. </if>
  8973. <if test="qcResultShortPageVO.endDate != null ">
  8974. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8975. </if>
  8976. </if>
  8977. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8978. <if test="qcResultShortPageVO.startDate != null ">
  8979. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8980. </if>
  8981. <if test="qcResultShortPageVO.endDate != null">
  8982. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8983. </if>
  8984. </if>
  8985. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8986. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8987. </if>
  8988. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8989. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8990. </if>
  8991. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8992. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8993. </if>
  8994. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8995. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8996. </if>
  8997. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8998. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8999. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9000. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9001. </if>
  9002. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9003. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9004. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9005. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9006. </if>
  9007. ) b
  9008. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9009. AND b.hospital_id = c.hospital_id
  9010. AND b.behospital_code = c.behospital_code
  9011. ) tt1
  9012. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9013. ,med_medical_record tt2,
  9014. qc_mode tt3
  9015. WHERE
  9016. tt2.is_deleted = 'N'
  9017. AND tt3.is_deleted = 'N'
  9018. AND tt1.hospital_id = tt2.hospital_id
  9019. AND tt1.behospital_code = tt2.behospital_code
  9020. AND tt2.mode_id = tt3.id
  9021. AND tt3.`name` = '手术记录'
  9022. </if>
  9023. ) be
  9024. left join med_check_info mci
  9025. on mci.is_deleted = 'N'
  9026. and mci.check_type = 0
  9027. and be.hospital_id = mci.hospital_id
  9028. and be.behospital_code = mci.behospital_code
  9029. left join med_check_info hm_mci
  9030. on hm_mci.is_deleted = 'N'
  9031. and hm_mci.check_type = 1
  9032. and be.hospital_id = hm_mci.hospital_id
  9033. and be.behospital_code = hm_mci.behospital_code
  9034. LEFT JOIN med_qcresult_cases e
  9035. on be.behospital_code = e.behospital_code
  9036. and be.hospital_id = e.hospital_id
  9037. AND e.is_deleted = 'N'
  9038. and e.cases_id = 243
  9039. )t1
  9040. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9041. ,med_home_page t2
  9042. WHERE
  9043. t2.is_deleted = 'N'
  9044. AND t1.hospital_id = t2.hospital_id
  9045. AND t1.behospital_code = t2.behospital_code
  9046. AND (
  9047. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9048. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  9049. )
  9050. </if>
  9051. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  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.return_to_type = '死亡'
  9058. </if>
  9059. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9060. ,med_home_page t2
  9061. WHERE
  9062. t2.is_deleted = 'N'
  9063. AND t1.hospital_id = t2.hospital_id
  9064. AND t1.behospital_code = t2.behospital_code
  9065. AND t2.leave_hospital_type = '非医嘱离院'
  9066. </if>
  9067. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9068. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9069. AND t1.hospital_id = t2.hospital_id
  9070. AND t1.behospital_code = t2.behospital_code
  9071. </if>
  9072. )t
  9073. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9074. AND t.hospitalId = qi.hospital_id
  9075. AND t.behospitalCode = qi.behospital_code
  9076. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9077. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9078. AND t.hospitalId = qd.hospital_id
  9079. AND t.behospitalCode = qd.behospital_code
  9080. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9081. AND qd.cases_id = qc.id
  9082. </if>
  9083. where 1=1
  9084. <if test="qcResultShortPageVO.checkStatus != null">
  9085. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9086. </if>
  9087. <if test="qcResultShortPageVO.mrStatus != null">
  9088. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9089. </if>
  9090. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9091. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9092. </if>
  9093. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9094. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9095. </if>
  9096. <if test="qcResultShortPageVO.chTimeStart != null ">
  9097. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9098. </if>
  9099. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9100. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9101. </if>
  9102. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9103. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9104. </if>
  9105. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9106. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9107. </if>
  9108. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9109. AND t.`level` = #{qcResultShortPageVO.level}
  9110. </if>)f1,(SELECT
  9111. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9112. t.behDeptId,
  9113. t.behDeptName,
  9114. t.doctorId,
  9115. t.doctorName
  9116. FROM
  9117. (SELECT DISTINCT
  9118. t1.hospital_id AS hospitalId,
  9119. t1.behospital_code AS behospitalCode,
  9120. t1.bed_code AS bedCode,
  9121. t1.LEVEL AS LEVEL,
  9122. t1.grade_type AS gradeType,
  9123. t1.score_res AS scoreRes,
  9124. t1.NAME AS NAME,
  9125. t1.sex AS sex,
  9126. t1.beh_dept_id AS behDeptId,
  9127. t1.beh_dept_name AS behDeptName,
  9128. t1.doctor_id AS doctorId,
  9129. t1.doctor_name AS doctorName,
  9130. t1.beh_doctor_id AS behDoctorId,
  9131. t1.beh_doctor_name AS behDoctorName,
  9132. t1.director_doctor_id AS directorDoctorId,
  9133. t1.director_doctor_name AS directorDoctorName,
  9134. t1.birthday AS birthday,
  9135. t1.behospital_date AS behospitalDate,
  9136. t1.leave_hospital_date AS leaveHospitalDate,
  9137. t1.placefile_date AS placefileDate,
  9138. t1.gmt_create AS gradeTime,
  9139. t1.diagnose,
  9140. t1.ward_name AS wardName,
  9141. t1.checkStatus,
  9142. t1.mrStatus,
  9143. t1.chName,
  9144. t1.mrName,
  9145. t1.chTime,
  9146. t1.mrTime,
  9147. t2.age,
  9148. t1.file_code AS fileCode
  9149. FROM
  9150. (
  9151. SELECT be.*,
  9152. ifnull(mci.status,0) AS checkStatus,
  9153. ifnull(hm_mci.status,0) AS mrStatus,
  9154. mci.check_name as chName,
  9155. hm_mci.check_name as mrName,
  9156. mci.gmt_create as chTime,
  9157. hm_mci.gmt_create as mrTime
  9158. FROM
  9159. (
  9160. SELECT DISTINCT
  9161. tt1.*
  9162. FROM
  9163. (
  9164. SELECT
  9165. b.*,
  9166. ifnull(c.LEVEL,'未评分') as LEVEL ,
  9167. c.grade_type,
  9168. c.score_res,
  9169. c.gmt_create
  9170. FROM
  9171. (
  9172. SELECT DISTINCT
  9173. a.hospital_id,
  9174. a.behospital_code,
  9175. a.bed_code,
  9176. a.NAME,
  9177. a.sex,
  9178. a.beh_dept_id,
  9179. a.beh_dept_name,
  9180. a.birthday,
  9181. a.behospital_date,
  9182. a.leave_hospital_date,
  9183. a.doctor_id,
  9184. a.doctor_name,
  9185. a.beh_doctor_id,
  9186. a.beh_doctor_name,
  9187. a.director_doctor_id,
  9188. a.director_doctor_name,
  9189. a.diagnose,
  9190. a.placefile_date,
  9191. a.ward_name,
  9192. a.file_code
  9193. FROM
  9194. med_behospital_info a,
  9195. sys_user_dept b
  9196. WHERE
  9197. a.is_deleted = 'N'
  9198. AND b.is_deleted = 'N'
  9199. AND a.hospital_id = b.hospital_id
  9200. AND a.beh_dept_id = b.dept_id
  9201. AND a.qc_type_id != 0
  9202. <if test="qcResultShortPageVO.userId!=null">
  9203. AND b.user_id = #{qcResultShortPageVO.userId}
  9204. </if>
  9205. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9206. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9207. </if>
  9208. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9209. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9210. </if>
  9211. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9212. <if test="qcResultShortPageVO.startDate != null ">
  9213. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9214. </if>
  9215. <if test="qcResultShortPageVO.endDate != null ">
  9216. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9217. </if>
  9218. </if>
  9219. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9220. <if test="qcResultShortPageVO.startDate != null ">
  9221. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9222. </if>
  9223. <if test="qcResultShortPageVO.endDate != null">
  9224. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9225. </if>
  9226. </if>
  9227. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9228. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9229. </if>
  9230. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9231. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9232. </if>
  9233. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9234. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9235. </if>
  9236. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9237. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9238. </if>
  9239. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9240. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9241. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9242. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9243. </if>
  9244. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9245. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9246. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9247. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9248. </if>
  9249. ) b
  9250. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  9251. AND b.hospital_id = c.hospital_id
  9252. AND b.behospital_code = c.behospital_code
  9253. ) tt1
  9254. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  9255. ,med_medical_record tt2,
  9256. qc_mode tt3
  9257. WHERE
  9258. tt2.is_deleted = 'N'
  9259. AND tt3.is_deleted = 'N'
  9260. AND tt1.hospital_id = tt2.hospital_id
  9261. AND tt1.behospital_code = tt2.behospital_code
  9262. AND tt2.mode_id = tt3.id
  9263. AND tt3.`name` = '手术记录'
  9264. </if>
  9265. ) be
  9266. left join med_check_info mci
  9267. on mci.is_deleted = 'N'
  9268. and mci.check_type = 0
  9269. and be.hospital_id = mci.hospital_id
  9270. and be.behospital_code = mci.behospital_code
  9271. left join med_check_info hm_mci
  9272. on hm_mci.is_deleted = 'N'
  9273. and hm_mci.check_type = 1
  9274. and be.hospital_id = hm_mci.hospital_id
  9275. and be.behospital_code = hm_mci.behospital_code
  9276. )t1
  9277. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  9278. ,med_home_page t2
  9279. WHERE
  9280. t2.is_deleted = 'N'
  9281. AND t1.hospital_id = t2.hospital_id
  9282. AND t1.behospital_code = t2.behospital_code
  9283. AND (
  9284. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  9285. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  9286. )
  9287. </if>
  9288. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  9289. ,med_home_page t2
  9290. WHERE
  9291. t2.is_deleted = 'N'
  9292. AND t1.hospital_id = t2.hospital_id
  9293. AND t1.behospital_code = t2.behospital_code
  9294. AND t2.return_to_type = '死亡'
  9295. </if>
  9296. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  9297. ,med_home_page t2
  9298. WHERE
  9299. t2.is_deleted = 'N'
  9300. AND t1.hospital_id = t2.hospital_id
  9301. AND t1.behospital_code = t2.behospital_code
  9302. AND t2.leave_hospital_type = '非医嘱离院'
  9303. </if>
  9304. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  9305. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  9306. AND t1.hospital_id = t2.hospital_id
  9307. AND t1.behospital_code = t2.behospital_code
  9308. </if>
  9309. )t
  9310. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9311. AND t.hospitalId = qi.hospital_id
  9312. AND t.behospitalCode = qi.behospital_code
  9313. where 1=1
  9314. <if test="qcResultShortPageVO.checkStatus != null">
  9315. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9316. </if>
  9317. <if test="qcResultShortPageVO.mrStatus != null">
  9318. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9319. </if>
  9320. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9321. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9322. </if>
  9323. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9324. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9325. </if>
  9326. <if test="qcResultShortPageVO.chTimeStart != null ">
  9327. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9328. </if>
  9329. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9330. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9331. </if>
  9332. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9333. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9334. </if>
  9335. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9336. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9337. </if>
  9338. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9339. AND t.`level` = #{qcResultShortPageVO.level}
  9340. </if>
  9341. GROUP BY
  9342. t.behDeptId,
  9343. t.behDeptName,
  9344. t.doctorId,
  9345. t.doctorName
  9346. )f2
  9347. WHERE
  9348. f1.doctorId = f2.doctorId
  9349. AND f1.doctorName = f2.doctorName
  9350. </select>
  9351. <!--缺陷详情质控评分页导出-科室-->
  9352. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  9353. SELECT * from(
  9354. SELECT
  9355. f1.*,
  9356. f2.avgScore
  9357. FROM
  9358. (SELECT
  9359. t.*,
  9360. qi.score_res AS score,
  9361. qd.msg AS msg,
  9362. qc.NAME AS caseName
  9363. FROM
  9364. (SELECT DISTINCT
  9365. t1.hospital_id AS hospitalId,
  9366. t1.behospital_code AS behospitalCode,
  9367. t1.bed_code AS bedCode,
  9368. t1.LEVEL AS LEVEL,
  9369. t1.grade_type AS gradeType,
  9370. t1.score_res AS scoreRes,
  9371. t1.scoreBn AS scoreBn,
  9372. t1.NAME AS patName,
  9373. t1.sex AS sex,
  9374. t1.beh_dept_id AS behDeptId,
  9375. t1.beh_dept_name AS behDeptName,
  9376. t1.doctor_id AS doctorId,
  9377. t1.doctor_name AS doctorName,
  9378. t1.beh_doctor_id AS behDoctorId,
  9379. t1.beh_doctor_name AS behDoctorName,
  9380. t1.director_doctor_id AS directorDoctorId,
  9381. t1.director_doctor_name AS directorDoctorName,
  9382. t1.birthday AS birthday,
  9383. t1.behospital_date AS behospitalDate,
  9384. t1.leave_hospital_date AS leaveHospitalDate,
  9385. t1.placefile_date AS placefileDate,
  9386. t1.gmt_create AS gradeTime,
  9387. t1.diagnose AS diagnose,
  9388. t1.ward_name AS wardName,
  9389. t1.file_code AS fileCode,
  9390. t1.checkStatus AS checkStatus,
  9391. t1.mrStatus AS mrStatus,
  9392. t1.chName AS chName,
  9393. t1.mrName AS mrName,
  9394. t1.chTime AS chTime,
  9395. t1.mrTime AS mrTime
  9396. FROM
  9397. (
  9398. SELECT DISTINCT
  9399. tt1.*
  9400. FROM
  9401. (SELECT
  9402. be.*,
  9403. ifnull(mci.status,0) AS checkStatus,
  9404. ifnull(hm_mci.status,0) AS mrStatus,
  9405. mci.check_name as chName,
  9406. hm_mci.check_name as mrName,
  9407. mci.gmt_create as chTime,
  9408. e.score_res as scoreBn,
  9409. hm_mci.gmt_create as mrTime
  9410. FROM
  9411. (
  9412. SELECT DISTINCT
  9413. a.hospital_id,
  9414. a.behospital_code,
  9415. a.bed_code,
  9416. a.file_code,
  9417. b.LEVEL,
  9418. b.grade_type,
  9419. b.score_res,
  9420. a.NAME,
  9421. a.sex,
  9422. a.beh_dept_id,
  9423. a.beh_dept_name,
  9424. a.birthday,
  9425. a.behospital_date,
  9426. a.leave_hospital_date,
  9427. a.doctor_id,
  9428. a.doctor_name,
  9429. a.beh_doctor_id,
  9430. a.beh_doctor_name,
  9431. a.director_doctor_id,
  9432. a.director_doctor_name,
  9433. a.diagnose,
  9434. a.placefile_date,
  9435. a.ward_name,
  9436. b.gmt_create
  9437. FROM
  9438. med_behospital_info a,
  9439. med_qcresult_info b,
  9440. med_qcresult_detail c,
  9441. qc_cases_entry d,
  9442. sys_user_dept e
  9443. WHERE
  9444. a.is_deleted = 'N'
  9445. AND b.is_deleted = 'N'
  9446. AND c.is_deleted = 'N'
  9447. AND d.is_deleted = 'N'
  9448. AND e.is_deleted = 'N'
  9449. AND a.hospital_id = b.hospital_id
  9450. AND a.hospital_id = c.hospital_id
  9451. AND a.hospital_id = e.hospital_id
  9452. AND a.behospital_code = b.behospital_code
  9453. AND a.behospital_code = c.behospital_code
  9454. AND a.beh_dept_id = e.dept_id
  9455. AND c.cases_id = d.cases_id
  9456. AND c.cases_entry_id = d.id
  9457. AND a.qc_type_id != 0
  9458. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9459. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9460. </if>
  9461. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  9462. AND e.user_id = #{qcResultShortPageVO.userId}
  9463. </if>
  9464. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9465. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9466. </if>
  9467. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9468. <if test="qcResultShortPageVO.startDate != null ">
  9469. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9470. </if>
  9471. <if test="qcResultShortPageVO.endDate != null ">
  9472. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9473. </if>
  9474. </if>
  9475. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9476. <if test="qcResultShortPageVO.startDate != null ">
  9477. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9478. </if>
  9479. <if test="qcResultShortPageVO.endDate != null">
  9480. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9481. </if>
  9482. </if>
  9483. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9484. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9485. </if>
  9486. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9487. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9488. </if>
  9489. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9490. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  9491. </if>
  9492. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9493. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9494. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9495. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9496. </if>
  9497. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9498. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9499. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9500. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9501. </if>
  9502. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9503. AND b.`level` = #{qcResultShortPageVO.level}
  9504. </if>
  9505. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9506. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9507. </if>
  9508. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9509. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9510. </if>
  9511. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9512. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  9513. </if>
  9514. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  9515. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9516. </if>
  9517. <if test="qcResultShortPageVO.isReject != null">
  9518. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9519. </if>
  9520. <if test="qcResultShortPageVO.ruleType != null">
  9521. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9522. </if>
  9523. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9524. AND TIMESTAMPDIFF(
  9525. DAY,
  9526. DATE( a.behospital_date ),
  9527. DATE( a.leave_hospital_date ))> 30
  9528. </if>
  9529. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9530. AND TIMESTAMPDIFF(
  9531. DAY,
  9532. DATE( a.behospital_date ),
  9533. DATE( a.leave_hospital_date ))> 31
  9534. </if>
  9535. )be
  9536. left join med_check_info mci
  9537. on mci.is_deleted = 'N'
  9538. and mci.check_type = 0
  9539. and be.hospital_id = mci.hospital_id
  9540. and be.behospital_code = mci.behospital_code
  9541. left join med_check_info hm_mci
  9542. on hm_mci.is_deleted = 'N'
  9543. and hm_mci.check_type = 1
  9544. and be.hospital_id = hm_mci.hospital_id
  9545. and be.behospital_code = hm_mci.behospital_code
  9546. LEFT JOIN med_qcresult_cases e
  9547. on be.behospital_code = e.behospital_code
  9548. and be.hospital_id = e.hospital_id
  9549. AND e.is_deleted = 'N'
  9550. and e.cases_id = 243
  9551. )tt1
  9552. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9553. ,med_medical_record tt2
  9554. WHERE
  9555. tt2.is_deleted = 'N'
  9556. AND tt1.hospital_id = tt2.hospital_id
  9557. AND tt1.behospital_code = tt2.behospital_code
  9558. AND tt2.mode_id = 30
  9559. </if>
  9560. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9561. ,med_crisis_info tt2
  9562. WHERE
  9563. tt2.is_deleted = 'N'
  9564. AND tt1.hospital_id = tt2.hospital_id
  9565. AND tt1.behospital_code = tt2.behospital_code
  9566. </if>
  9567. ) t1
  9568. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9569. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9570. AND t1.behospital_code = t2.behospital_code
  9571. AND t2.is_deleted = 'N'
  9572. </if>
  9573. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9574. , med_home_page t2
  9575. , med_home_operation_info t3
  9576. WHERE t1.hospital_id = t2.hospital_id
  9577. AND t1.behospital_code = t2.behospital_code
  9578. AND t2.home_page_id = t3.home_page_id
  9579. AND t2.is_deleted = 'N'
  9580. AND t3.is_deleted = 'N'
  9581. </if>
  9582. ) t
  9583. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9584. AND t.hospitalId = qi.hospital_id
  9585. AND t.behospitalCode = qi.behospital_code
  9586. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9587. AND t.hospitalId = qd.hospital_id
  9588. AND t.behospitalCode = qd.behospital_code
  9589. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9590. AND qd.cases_id = qc.id
  9591. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  9592. AND qd.cases_id = qce.cases_id
  9593. AND qd.cases_entry_id = qce.id
  9594. where 1=1
  9595. <if test="qcResultShortPageVO.checkStatus != null">
  9596. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9597. </if>
  9598. <if test="qcResultShortPageVO.mrStatus != null">
  9599. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9600. </if>
  9601. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9602. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9603. </if>
  9604. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9605. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9606. </if>
  9607. <if test="qcResultShortPageVO.chTimeStart != null ">
  9608. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9609. </if>
  9610. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9611. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9612. </if>
  9613. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9614. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9615. </if>
  9616. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9617. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9618. </if>
  9619. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9620. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  9621. </if>
  9622. <if test="qcResultShortPageVO.casesEntryId != null ">
  9623. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  9624. </if>
  9625. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9626. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  9627. </if>
  9628. <if test="qcResultShortPageVO.casesId != null">
  9629. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  9630. </if>
  9631. )f1,
  9632. (SELECT
  9633. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9634. t.behDeptId,
  9635. t.behDeptName,
  9636. t.doctorId,
  9637. t.doctorName
  9638. FROM
  9639. (SELECT DISTINCT
  9640. t1.hospital_id AS hospitalId,
  9641. t1.behospital_code AS behospitalCode,
  9642. t1.bed_code AS bedCode,
  9643. t1.LEVEL AS LEVEL,
  9644. t1.grade_type AS gradeType,
  9645. t1.score_res AS scoreRes,
  9646. t1.NAME AS NAME,
  9647. t1.sex AS sex,
  9648. t1.beh_dept_id AS behDeptId,
  9649. t1.beh_dept_name AS behDeptName,
  9650. t1.doctor_id AS doctorId,
  9651. t1.doctor_name AS doctorName,
  9652. t1.beh_doctor_id AS behDoctorId,
  9653. t1.beh_doctor_name AS behDoctorName,
  9654. t1.director_doctor_id AS directorDoctorId,
  9655. t1.director_doctor_name AS directorDoctorName,
  9656. t1.birthday AS birthday,
  9657. t1.behospital_date AS behospitalDate,
  9658. t1.leave_hospital_date AS leaveHospitalDate,
  9659. t1.placefile_date AS placefileDate,
  9660. t1.gmt_create AS gradeTime,
  9661. t1.diagnose,
  9662. t1.ward_name AS wardName,
  9663. t2.age,
  9664. t1.file_code AS fileCode,
  9665. t1.checkStatus,
  9666. t1.mrStatus,
  9667. t1.chName,
  9668. t1.mrName,
  9669. t1.chTime,
  9670. t1.mrTime
  9671. FROM
  9672. (
  9673. SELECT DISTINCT
  9674. tt1.*
  9675. FROM
  9676. (SELECT
  9677. be.*,
  9678. ifnull(mci.status,0) AS checkStatus,
  9679. ifnull(hm_mci.status,0) AS mrStatus,
  9680. mci.check_name as chName,
  9681. hm_mci.check_name as mrName,
  9682. mci.gmt_create as chTime,
  9683. hm_mci.gmt_create as mrTime
  9684. FROM
  9685. (
  9686. SELECT DISTINCT
  9687. a.hospital_id,
  9688. a.behospital_code,
  9689. a.bed_code,
  9690. a.file_code,
  9691. b.LEVEL,
  9692. b.grade_type,
  9693. b.score_res,
  9694. a.NAME,
  9695. a.sex,
  9696. a.beh_dept_id,
  9697. a.beh_dept_name,
  9698. a.birthday,
  9699. a.behospital_date,
  9700. a.leave_hospital_date,
  9701. a.doctor_id,
  9702. a.doctor_name,
  9703. a.beh_doctor_id,
  9704. a.beh_doctor_name,
  9705. a.director_doctor_id,
  9706. a.director_doctor_name,
  9707. a.diagnose,
  9708. a.placefile_date,
  9709. a.ward_name,
  9710. b.gmt_create
  9711. FROM
  9712. med_behospital_info a,
  9713. med_qcresult_info b,
  9714. med_qcresult_detail c,
  9715. qc_cases_entry d,
  9716. sys_user_dept e
  9717. WHERE
  9718. a.is_deleted = 'N'
  9719. AND b.is_deleted = 'N'
  9720. AND c.is_deleted = 'N'
  9721. AND d.is_deleted = 'N'
  9722. AND e.is_deleted = 'N'
  9723. AND a.hospital_id = b.hospital_id
  9724. AND a.hospital_id = c.hospital_id
  9725. AND a.hospital_id = e.hospital_id
  9726. AND a.behospital_code = b.behospital_code
  9727. AND a.behospital_code = c.behospital_code
  9728. AND a.beh_dept_id = e.dept_id
  9729. AND c.cases_id = d.cases_id
  9730. AND c.cases_entry_id = d.id
  9731. AND a.qc_type_id != 0
  9732. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9733. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9734. </if>
  9735. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9736. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9737. </if>
  9738. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9739. <if test="qcResultShortPageVO.startDate != null ">
  9740. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9741. </if>
  9742. <if test="qcResultShortPageVO.endDate != null ">
  9743. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9744. </if>
  9745. </if>
  9746. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9747. <if test="qcResultShortPageVO.startDate != null ">
  9748. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9749. </if>
  9750. <if test="qcResultShortPageVO.endDate != null">
  9751. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9752. </if>
  9753. </if>
  9754. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9755. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9756. </if>
  9757. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9758. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9759. </if>
  9760. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9761. AND b.`level` = #{qcResultShortPageVO.level}
  9762. </if>
  9763. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9764. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9765. </if>
  9766. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9767. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9768. </if>
  9769. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9770. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  9771. </if>
  9772. <if test="qcResultShortPageVO.casesEntryId != null ">
  9773. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9774. </if>
  9775. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  9776. AND d.cases_name = #{qcResultShortPageVO.casesName}
  9777. </if>
  9778. <if test="qcResultShortPageVO.casesId != null">
  9779. AND d.cases_id = #{qcResultShortPageVO.casesId}
  9780. </if>
  9781. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9782. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9783. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9784. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9785. </if>
  9786. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9787. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9788. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9789. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9790. </if>
  9791. <if test="qcResultShortPageVO.isReject != null">
  9792. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9793. </if>
  9794. <if test="qcResultShortPageVO.ruleType != null">
  9795. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9796. </if>
  9797. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  9798. AND TIMESTAMPDIFF(
  9799. DAY,
  9800. DATE( a.behospital_date ),
  9801. DATE( a.leave_hospital_date ))> 30
  9802. </if>
  9803. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  9804. AND TIMESTAMPDIFF(
  9805. DAY,
  9806. DATE( a.behospital_date ),
  9807. DATE( a.leave_hospital_date ))> 31
  9808. </if>
  9809. )be
  9810. left join med_check_info mci
  9811. on mci.is_deleted = 'N'
  9812. and mci.check_type = 0
  9813. and be.hospital_id = mci.hospital_id
  9814. and be.behospital_code = mci.behospital_code
  9815. left join med_check_info hm_mci
  9816. on hm_mci.is_deleted = 'N'
  9817. and hm_mci.check_type = 1
  9818. and be.hospital_id = hm_mci.hospital_id
  9819. and be.behospital_code = hm_mci.behospital_code
  9820. )tt1
  9821. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  9822. ,med_medical_record tt2
  9823. WHERE
  9824. tt2.is_deleted = 'N'
  9825. AND tt1.hospital_id = tt2.hospital_id
  9826. AND tt1.behospital_code = tt2.behospital_code
  9827. AND tt2.mode_id = 30
  9828. </if>
  9829. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  9830. ,med_crisis_info tt2
  9831. WHERE
  9832. tt2.is_deleted = 'N'
  9833. AND tt1.hospital_id = tt2.hospital_id
  9834. AND tt1.behospital_code = tt2.behospital_code
  9835. </if>
  9836. ) t1
  9837. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  9838. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9839. AND t1.behospital_code = t2.behospital_code
  9840. AND t2.is_deleted = 'N'
  9841. </if>
  9842. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  9843. , med_home_page t2
  9844. , med_home_operation_info t3
  9845. WHERE t1.hospital_id = t2.hospital_id
  9846. AND t1.behospital_code = t2.behospital_code
  9847. AND t2.home_page_id = t3.home_page_id
  9848. AND t2.is_deleted = 'N'
  9849. AND t3.is_deleted = 'N'
  9850. </if>
  9851. ) t
  9852. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9853. AND t.hospitalId = qi.hospital_id
  9854. AND t.behospitalCode = qi.behospital_code
  9855. where 1=1
  9856. <if test="qcResultShortPageVO.checkStatus != null">
  9857. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9858. </if>
  9859. <if test="qcResultShortPageVO.mrStatus != null">
  9860. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9861. </if>
  9862. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9863. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9864. </if>
  9865. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9866. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9867. </if>
  9868. <if test="qcResultShortPageVO.chTimeStart != null ">
  9869. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9870. </if>
  9871. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9872. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9873. </if>
  9874. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9875. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9876. </if>
  9877. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9878. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9879. </if>
  9880. GROUP BY
  9881. t.behDeptId,
  9882. t.behDeptName,
  9883. t.doctorId,
  9884. t.doctorName
  9885. )f2
  9886. WHERE
  9887. f1.doctorId = f2.doctorId
  9888. AND f1.doctorName = f2.doctorName
  9889. )m
  9890. </select>
  9891. <!-- 条目缺陷评分详情页导出-->
  9892. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  9893. SELECT * from(
  9894. SELECT
  9895. f1.*,
  9896. f2.avgScore
  9897. FROM
  9898. (SELECT
  9899. t.*,
  9900. qi.score_res AS score,
  9901. qd.msg AS msg,
  9902. qc.NAME AS caseName
  9903. FROM
  9904. (SELECT DISTINCT
  9905. t1.hospital_id AS hospitalId,
  9906. t1.behospital_code AS behospitalCode,
  9907. t1.bed_code AS bedCode,
  9908. t1.LEVEL AS LEVEL,
  9909. t1.grade_type AS gradeType,
  9910. t1.score_res AS scoreRes,
  9911. t1.scoreBn AS scoreBn,
  9912. t1.NAME AS patName,
  9913. t1.sex AS sex,
  9914. t1.beh_dept_id AS behDeptId,
  9915. t1.beh_dept_name AS behDeptName,
  9916. t1.doctor_id AS doctorId,
  9917. t1.doctor_name AS doctorName,
  9918. t1.beh_doctor_id AS behDoctorId,
  9919. t1.beh_doctor_name AS behDoctorName,
  9920. t1.director_doctor_id AS directorDoctorId,
  9921. t1.director_doctor_name AS directorDoctorName,
  9922. t1.birthday AS birthday,
  9923. t1.behospital_date AS behospitalDate,
  9924. t1.leave_hospital_date AS leaveHospitalDate,
  9925. t1.placefile_date AS placefileDate,
  9926. t1.gmt_create AS gradeTime,
  9927. t1.diagnose AS diagnose,
  9928. t1.ward_name AS wardName,
  9929. t1.file_code AS fileCode,
  9930. t1.checkStatus AS checkStatus,
  9931. t1.mrStatus AS mrStatus,
  9932. t1.chName AS chName,
  9933. t1.mrName AS mrName,
  9934. t1.chTime AS chTime,
  9935. t1.mrTime AS mrTime
  9936. FROM
  9937. (
  9938. SELECT DISTINCT
  9939. tt1.*
  9940. FROM
  9941. (SELECT
  9942. be.*,
  9943. ifnull(mci.status,0) AS checkStatus,
  9944. ifnull(hm_mci.status,0) AS mrStatus,
  9945. mci.check_name as chName,
  9946. hm_mci.check_name as mrName,
  9947. mci.gmt_create as chTime,
  9948. e.score_res as scoreBn,
  9949. hm_mci.gmt_create as mrTime
  9950. FROM
  9951. (
  9952. SELECT DISTINCT
  9953. a.hospital_id,
  9954. a.behospital_code,
  9955. a.bed_code,
  9956. a.file_code,
  9957. b.LEVEL,
  9958. b.grade_type,
  9959. b.score_res,
  9960. a.NAME,
  9961. a.sex,
  9962. a.beh_dept_id,
  9963. a.beh_dept_name,
  9964. a.birthday,
  9965. a.behospital_date,
  9966. a.leave_hospital_date,
  9967. a.doctor_id,
  9968. a.doctor_name,
  9969. a.beh_doctor_id,
  9970. a.beh_doctor_name,
  9971. a.director_doctor_id,
  9972. a.director_doctor_name,
  9973. a.diagnose,
  9974. a.placefile_date,
  9975. a.ward_name,
  9976. b.gmt_create
  9977. FROM
  9978. med_behospital_info a,
  9979. med_qcresult_info b,
  9980. med_qcresult_detail c,
  9981. qc_cases_entry d
  9982. WHERE
  9983. a.is_deleted = 'N'
  9984. AND b.is_deleted = 'N'
  9985. AND c.is_deleted = 'N'
  9986. AND d.is_deleted = 'N'
  9987. AND a.hospital_id = b.hospital_id
  9988. AND a.hospital_id = c.hospital_id
  9989. AND a.behospital_code = b.behospital_code
  9990. AND a.behospital_code = c.behospital_code
  9991. AND c.cases_id = d.cases_id
  9992. AND c.cases_entry_id = d.id
  9993. AND a.qc_type_id != 0
  9994. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9995. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9996. </if>
  9997. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9998. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9999. </if>
  10000. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10001. <if test="qcResultShortPageVO.startDate != null ">
  10002. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10003. </if>
  10004. <if test="qcResultShortPageVO.endDate != null ">
  10005. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10006. </if>
  10007. </if>
  10008. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10009. <if test="qcResultShortPageVO.startDate != null ">
  10010. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10011. </if>
  10012. <if test="qcResultShortPageVO.endDate != null">
  10013. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10014. </if>
  10015. </if>
  10016. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10017. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10018. </if>
  10019. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10020. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10021. </if>
  10022. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10023. AND b.`level` = #{qcResultShortPageVO.level}
  10024. </if>
  10025. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10026. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10027. </if>
  10028. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10029. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10030. </if>
  10031. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10032. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10033. </if>
  10034. <if test="qcResultShortPageVO.casesEntryId != null ">
  10035. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10036. </if>
  10037. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10038. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10039. </if>
  10040. <if test="qcResultShortPageVO.casesId != null">
  10041. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10042. </if>
  10043. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10044. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10045. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10046. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10047. </if>
  10048. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10049. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10050. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10051. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10052. </if>
  10053. <if test="qcResultShortPageVO.isReject != null">
  10054. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10055. </if>
  10056. <if test="qcResultShortPageVO.ruleType != null">
  10057. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10058. </if>
  10059. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10060. AND TIMESTAMPDIFF(
  10061. DAY,
  10062. DATE( a.behospital_date ),
  10063. DATE( a.leave_hospital_date ))> 30
  10064. </if>
  10065. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10066. AND TIMESTAMPDIFF(
  10067. DAY,
  10068. DATE( a.behospital_date ),
  10069. DATE( a.leave_hospital_date ))> 31
  10070. </if>
  10071. )be
  10072. left join med_check_info mci
  10073. on mci.is_deleted = 'N'
  10074. and mci.check_type = 0
  10075. and be.hospital_id = mci.hospital_id
  10076. and be.behospital_code = mci.behospital_code
  10077. left join med_check_info hm_mci
  10078. on hm_mci.is_deleted = 'N'
  10079. and hm_mci.check_type = 1
  10080. and be.hospital_id = hm_mci.hospital_id
  10081. and be.behospital_code = hm_mci.behospital_code
  10082. LEFT JOIN med_qcresult_cases e
  10083. on be.behospital_code = e.behospital_code
  10084. and be.hospital_id = e.hospital_id
  10085. AND e.is_deleted = 'N'
  10086. and e.cases_id = 243
  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.mrStatus != null">
  10135. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10136. </if>
  10137. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10138. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10139. </if>
  10140. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10141. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10142. </if>
  10143. <if test="qcResultShortPageVO.chTimeStart != null ">
  10144. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10145. </if>
  10146. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10147. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10148. </if>
  10149. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10150. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10151. </if>
  10152. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10153. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10154. </if>
  10155. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10156. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10157. </if>
  10158. <if test="qcResultShortPageVO.casesEntryId != null ">
  10159. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10160. </if>
  10161. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10162. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  10163. </if>
  10164. <if test="qcResultShortPageVO.casesId != null">
  10165. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  10166. </if>
  10167. )f1,
  10168. (SELECT
  10169. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10170. t.behDeptId,
  10171. t.behDeptName
  10172. FROM
  10173. (SELECT DISTINCT
  10174. t1.hospital_id AS hospitalId,
  10175. t1.behospital_code AS behospitalCode,
  10176. t1.bed_code AS bedCode,
  10177. t1.LEVEL AS LEVEL,
  10178. t1.grade_type AS gradeType,
  10179. t1.score_res AS scoreRes,
  10180. t1.NAME AS NAME,
  10181. t1.sex AS sex,
  10182. t1.beh_dept_id AS behDeptId,
  10183. t1.beh_dept_name AS behDeptName,
  10184. t1.doctor_id AS doctorId,
  10185. t1.doctor_name AS doctorName,
  10186. t1.beh_doctor_id AS behDoctorId,
  10187. t1.beh_doctor_name AS behDoctorName,
  10188. t1.director_doctor_id AS directorDoctorId,
  10189. t1.director_doctor_name AS directorDoctorName,
  10190. t1.birthday AS birthday,
  10191. t1.behospital_date AS behospitalDate,
  10192. t1.leave_hospital_date AS leaveHospitalDate,
  10193. t1.placefile_date AS placefileDate,
  10194. t1.gmt_create AS gradeTime,
  10195. t1.diagnose,
  10196. t1.ward_name AS wardName,
  10197. t2.age,
  10198. t1.file_code AS fileCode,
  10199. t1.checkStatus,
  10200. t1.mrStatus,
  10201. t1.chName,
  10202. t1.mrName,
  10203. t1.chTime,
  10204. t1.mrTime
  10205. FROM
  10206. (
  10207. SELECT DISTINCT
  10208. tt1.*
  10209. FROM
  10210. (SELECT
  10211. be.*,
  10212. ifnull(mci.status,0) AS checkStatus,
  10213. ifnull(hm_mci.status,0) AS mrStatus,
  10214. mci.check_name as chName,
  10215. hm_mci.check_name as mrName,
  10216. mci.gmt_create as chTime,
  10217. hm_mci.gmt_create as mrTime
  10218. FROM
  10219. (
  10220. SELECT DISTINCT
  10221. a.hospital_id,
  10222. a.behospital_code,
  10223. a.bed_code,
  10224. a.file_code,
  10225. b.LEVEL,
  10226. b.grade_type,
  10227. b.score_res,
  10228. a.NAME,
  10229. a.sex,
  10230. a.beh_dept_id,
  10231. a.beh_dept_name,
  10232. a.birthday,
  10233. a.behospital_date,
  10234. a.leave_hospital_date,
  10235. a.doctor_id,
  10236. a.doctor_name,
  10237. a.beh_doctor_id,
  10238. a.beh_doctor_name,
  10239. a.director_doctor_id,
  10240. a.director_doctor_name,
  10241. a.diagnose,
  10242. a.placefile_date,
  10243. a.ward_name,
  10244. b.gmt_create
  10245. FROM
  10246. med_behospital_info a,
  10247. med_qcresult_info b,
  10248. med_qcresult_detail c,
  10249. qc_cases_entry d
  10250. WHERE
  10251. a.is_deleted = 'N'
  10252. AND b.is_deleted = 'N'
  10253. AND c.is_deleted = 'N'
  10254. AND d.is_deleted = 'N'
  10255. AND a.hospital_id = b.hospital_id
  10256. AND a.hospital_id = c.hospital_id
  10257. AND a.behospital_code = b.behospital_code
  10258. AND a.behospital_code = c.behospital_code
  10259. AND c.cases_id = d.cases_id
  10260. AND c.cases_entry_id = d.id
  10261. AND a.qc_type_id != 0
  10262. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10263. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10264. </if>
  10265. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10266. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10267. </if>
  10268. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10269. <if test="qcResultShortPageVO.startDate != null ">
  10270. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10271. </if>
  10272. <if test="qcResultShortPageVO.endDate != null ">
  10273. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10274. </if>
  10275. </if>
  10276. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10277. <if test="qcResultShortPageVO.startDate != null ">
  10278. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10279. </if>
  10280. <if test="qcResultShortPageVO.endDate != null">
  10281. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10282. </if>
  10283. </if>
  10284. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10285. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10286. </if>
  10287. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10288. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10289. </if>
  10290. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10291. AND b.`level` = #{qcResultShortPageVO.level}
  10292. </if>
  10293. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10294. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10295. </if>
  10296. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10297. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10298. </if>
  10299. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10300. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10301. </if>
  10302. <if test="qcResultShortPageVO.casesEntryId != null ">
  10303. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10304. </if>
  10305. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  10306. AND d.cases_name = #{qcResultShortPageVO.casesName}
  10307. </if>
  10308. <if test="qcResultShortPageVO.casesId != null">
  10309. AND d.cases_id = #{qcResultShortPageVO.casesId}
  10310. </if>
  10311. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10312. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10313. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10314. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10315. </if>
  10316. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10317. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10318. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10319. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10320. </if>
  10321. <if test="qcResultShortPageVO.isReject != null">
  10322. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10323. </if>
  10324. <if test="qcResultShortPageVO.ruleType != null">
  10325. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10326. </if>
  10327. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  10328. AND TIMESTAMPDIFF(
  10329. DAY,
  10330. DATE( a.behospital_date ),
  10331. DATE( a.leave_hospital_date ))> 30
  10332. </if>
  10333. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  10334. AND TIMESTAMPDIFF(
  10335. DAY,
  10336. DATE( a.behospital_date ),
  10337. DATE( a.leave_hospital_date ))> 31
  10338. </if>
  10339. )be
  10340. left join med_check_info mci
  10341. on mci.is_deleted = 'N'
  10342. and mci.check_type = 0
  10343. and be.hospital_id = mci.hospital_id
  10344. and be.behospital_code = mci.behospital_code
  10345. left join med_check_info hm_mci
  10346. on hm_mci.is_deleted = 'N'
  10347. and hm_mci.check_type = 1
  10348. and be.hospital_id = hm_mci.hospital_id
  10349. and be.behospital_code = hm_mci.behospital_code
  10350. )tt1
  10351. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  10352. ,med_medical_record tt2
  10353. WHERE
  10354. tt2.is_deleted = 'N'
  10355. AND tt1.hospital_id = tt2.hospital_id
  10356. AND tt1.behospital_code = tt2.behospital_code
  10357. AND tt2.mode_id = 30
  10358. </if>
  10359. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  10360. ,med_crisis_info tt2
  10361. WHERE
  10362. tt2.is_deleted = 'N'
  10363. AND tt1.hospital_id = tt2.hospital_id
  10364. AND tt1.behospital_code = tt2.behospital_code
  10365. </if>
  10366. ) t1
  10367. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  10368. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10369. AND t1.behospital_code = t2.behospital_code
  10370. AND t2.is_deleted = 'N'
  10371. </if>
  10372. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  10373. , med_home_page t2
  10374. , med_home_operation_info t3
  10375. WHERE t1.hospital_id = t2.hospital_id
  10376. AND t1.behospital_code = t2.behospital_code
  10377. AND t2.home_page_id = t3.home_page_id
  10378. AND t2.is_deleted = 'N'
  10379. AND t3.is_deleted = 'N'
  10380. </if>
  10381. ) t
  10382. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10383. AND t.hospitalId = qi.hospital_id
  10384. AND t.behospitalCode = qi.behospital_code
  10385. where 1=1
  10386. <if test="qcResultShortPageVO.checkStatus != null">
  10387. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10388. </if>
  10389. <if test="qcResultShortPageVO.mrStatus != null">
  10390. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10391. </if>
  10392. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10393. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10394. </if>
  10395. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10396. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10397. </if>
  10398. <if test="qcResultShortPageVO.chTimeStart != null ">
  10399. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10400. </if>
  10401. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10402. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10403. </if>
  10404. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10405. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10406. </if>
  10407. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10408. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10409. </if>
  10410. GROUP BY
  10411. t.behDeptId,
  10412. t.behDeptName
  10413. )f2
  10414. WHERE
  10415. f1.behDeptId = f2.behDeptId
  10416. AND f1.behDeptName = f2.behDeptName
  10417. )m
  10418. </select>
  10419. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  10420. <result column="deptName" property="deptName"/>
  10421. <result column="deptId" property="deptId"/>
  10422. <result column="doctorGroup" property="doctorGroup"/>
  10423. <result column="doctorName" property="doctorName"/>
  10424. <result column="entry_2658_num" property="entry_2658_num"/>
  10425. <result column="entry_2686_num" property="entry_2686_num"/>
  10426. <result column="entry_2657_num" property="entry_2657_num"/>
  10427. <result column="entry_3010_num" property="entry_3010_num"/>
  10428. <result column="entry_2655_num" property="entry_2655_num"/>
  10429. <result column="entry_2654_num" property="entry_2654_num"/>
  10430. <result column="entry_2852_num" property="entry_2852_num"/>
  10431. <result column="entry_2287_num" property="entry_2287_num"/>
  10432. <result column="entry_3025_num" property="entry_3025_num"/>
  10433. <result column="entry_2170_num" property="entry_2170_num"/>
  10434. <result column="entry_2930_num" property="entry_2930_num"/>
  10435. <result column="entry_2900_num" property="entry_2900_num"/>
  10436. <result column="entry_2229_num" property="entry_2229_num"/>
  10437. <result column="entry_2217_num" property="entry_2217_num"/>
  10438. <result column="entry_2218_num" property="entry_2218_num"/>
  10439. <result column="entry_2220_num" property="entry_2220_num"/>
  10440. <result column="entry_2486_num" property="entry_2486_num"/>
  10441. <result column="entry_3063_num" property="entry_3063_num"/>
  10442. <result column="entry_3062_num" property="entry_3062_num"/>
  10443. <result column="entry_2495_num" property="entry_2495_num"/>
  10444. </resultMap>
  10445. <!-- 病历稽查表-->
  10446. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  10447. SELECT
  10448. a.beh_dept_id AS deptId,
  10449. a.beh_dept_name AS deptName,
  10450. a.doctor_name as doctorGroup,
  10451. a.doctor_name as doctorName,
  10452. sum(c.cases_entry_id = 2658) as entry_2658_num,
  10453. sum(c.cases_entry_id = 2686) as entry_2686_num,
  10454. sum(c.cases_entry_id = 2657) as entry_2657_num,
  10455. sum(c.cases_entry_id = 3010) as entry_3010_num,
  10456. sum(c.cases_entry_id = 2655) as entry_2655_num,
  10457. sum(c.cases_entry_id = 2654) as entry_2654_num,
  10458. sum(c.cases_entry_id = 2852) as entry_2852_num,
  10459. sum(c.cases_entry_id = 2287) as entry_2287_num,
  10460. sum(c.cases_entry_id = 3025) as entry_3025_num,
  10461. sum(c.cases_entry_id = 2170) as entry_2170_num,
  10462. sum(c.cases_entry_id = 2930) as entry_2930_num,
  10463. sum(c.cases_entry_id = 2900) as entry_2900_num,
  10464. sum(c.cases_entry_id = 2229) as entry_2229_num,
  10465. sum(c.cases_entry_id = 2217) as entry_2217_num,
  10466. sum(c.cases_entry_id = 2218) as entry_2218_num,
  10467. sum(c.cases_entry_id = 2220) as entry_2220_num,
  10468. sum(c.cases_entry_id = 2486) as entry_2486_num,
  10469. sum(c.cases_entry_id = 3063) as entry_3063_num,
  10470. sum(c.cases_entry_id = 3062) as entry_3062_num,
  10471. sum(c.cases_entry_id = 2495) as entry_2495_num
  10472. FROM
  10473. med_behospital_info a,
  10474. med_qcresult_info b,
  10475. med_qcresult_detail c,
  10476. qc_cases_entry d,
  10477. bas_doctor_info e
  10478. WHERE
  10479. a.is_deleted = 'N'
  10480. AND b.is_deleted = 'N'
  10481. AND c.is_deleted = 'N'
  10482. AND d.is_deleted = 'N'
  10483. AND e.is_deleted = 'N'
  10484. AND a.hospital_id = b.hospital_id
  10485. AND a.hospital_id = c.hospital_id
  10486. AND a.hospital_id = e.hospital_id
  10487. AND a.behospital_code = b.behospital_code
  10488. AND a.behospital_code = c.behospital_code
  10489. AND a.beh_dept_id = e.dept_id
  10490. AND c.cases_entry_id = d.id
  10491. and a.doctor_id=e.doctor_id
  10492. and e.group_id is not NULL
  10493. AND LENGTH(e.group_id)>0
  10494. AND a.qc_type_id != 0
  10495. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10496. and a.is_placefile = #{filterVO.isPlacefile}
  10497. </if>
  10498. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10499. AND a.hospital_id = #{filterVO.hospitalId}
  10500. </if>
  10501. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10502. <if test="filterVO.startDate != null ">
  10503. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10504. </if>
  10505. <if test="filterVO.endDate != null ">
  10506. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10507. </if>
  10508. </if>
  10509. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10510. <if test="filterVO.startDate != null ">
  10511. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10512. </if>
  10513. <if test="filterVO.endDate != null ">
  10514. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10515. </if>
  10516. </if>
  10517. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10518. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  10519. </if>
  10520. GROUP BY
  10521. a.beh_dept_id,
  10522. e.group_id,
  10523. a.doctor_id
  10524. </select>
  10525. <!-- 病历稽查表-科室-->
  10526. <select id="getMedicalCheckByDept" resultMap="MedicalCheckMap">
  10527. SELECT
  10528. a.beh_dept_id AS deptId,
  10529. a.beh_dept_name AS deptName,
  10530. a.doctor_name as doctorName,
  10531. a.doctor_name as doctorGroup,
  10532. sum(c.cases_entry_id = 2658) as entry_2658_num,
  10533. sum(c.cases_entry_id = 2686) as entry_2686_num,
  10534. sum(c.cases_entry_id = 2657) as entry_2657_num,
  10535. sum(c.cases_entry_id = 3010) as entry_3010_num,
  10536. sum(c.cases_entry_id = 2655) as entry_2655_num,
  10537. sum(c.cases_entry_id = 2654) as entry_2654_num,
  10538. sum(c.cases_entry_id = 2852) as entry_2852_num,
  10539. sum(c.cases_entry_id = 2287) as entry_2287_num,
  10540. sum(c.cases_entry_id = 3025) as entry_3025_num,
  10541. sum(c.cases_entry_id = 2170) as entry_2170_num,
  10542. sum(c.cases_entry_id = 2930) as entry_2930_num,
  10543. sum(c.cases_entry_id = 2900) as entry_2900_num,
  10544. sum(c.cases_entry_id = 2229) as entry_2229_num,
  10545. sum(c.cases_entry_id = 2217) as entry_2217_num,
  10546. sum(c.cases_entry_id = 2218) as entry_2218_num,
  10547. sum(c.cases_entry_id = 2220) as entry_2220_num,
  10548. sum(c.cases_entry_id = 2486) as entry_2486_num,
  10549. sum(c.cases_entry_id = 3063) as entry_3063_num,
  10550. sum(c.cases_entry_id = 3062) as entry_3062_num,
  10551. sum(c.cases_entry_id = 2495) as entry_2495_num
  10552. FROM
  10553. med_behospital_info a,
  10554. med_qcresult_info b,
  10555. med_qcresult_detail c,
  10556. qc_cases_entry d,
  10557. bas_doctor_info e,
  10558. sys_user_dept f
  10559. WHERE
  10560. a.is_deleted = 'N'
  10561. AND b.is_deleted = 'N'
  10562. AND c.is_deleted = 'N'
  10563. AND d.is_deleted = 'N'
  10564. AND e.is_deleted = 'N'
  10565. AND f.is_deleted = 'N'
  10566. AND a.hospital_id = b.hospital_id
  10567. AND a.hospital_id = c.hospital_id
  10568. AND a.hospital_id = e.hospital_id
  10569. AND a.hospital_id = f.hospital_id
  10570. AND a.behospital_code = b.behospital_code
  10571. AND a.behospital_code = c.behospital_code
  10572. AND a.beh_dept_id = f.dept_id
  10573. AND c.cases_entry_id = d.id
  10574. and a.doctor_id=e.doctor_id
  10575. and e.group_id is not NULL
  10576. AND LENGTH(e.group_id)>0
  10577. AND a.qc_type_id != 0
  10578. <if test="filterVO.userId!=null">
  10579. AND f.user_id = #{filterVO.userId}
  10580. </if>
  10581. <if test="filterVO.name != null and filterVO.name != ''">
  10582. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  10583. </if>
  10584. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10585. and a.is_placefile = #{filterVO.isPlacefile}
  10586. </if>
  10587. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10588. AND a.hospital_id = #{filterVO.hospitalId}
  10589. </if>
  10590. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10591. <if test="filterVO.startDate != null ">
  10592. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10593. </if>
  10594. <if test="filterVO.endDate != null ">
  10595. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10596. </if>
  10597. </if>
  10598. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10599. <if test="filterVO.startDate != null ">
  10600. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10601. </if>
  10602. <if test="filterVO.endDate != null ">
  10603. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10604. </if>
  10605. </if>
  10606. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10607. AND a.beh_dept_name = #{filterVO.deptName}
  10608. </if>
  10609. GROUP BY
  10610. a.beh_dept_id,
  10611. e.group_id,
  10612. a.doctor_name
  10613. </select>
  10614. <!-- 病历稽查表最新sql、id&&name-->
  10615. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  10616. SELECT
  10617. d.id,
  10618. d.name
  10619. from
  10620. qc_cases_entry d
  10621. where
  10622. 1=1
  10623. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  10624. and d.id in
  10625. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  10626. '${item}'
  10627. </foreach>
  10628. </if>
  10629. </select>
  10630. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  10631. <result column="deptName" property="deptName"/>
  10632. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  10633. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  10634. <result column="doctorName" property="doctorName"/>
  10635. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  10636. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  10637. <result column="RYJLW_24" property="ryjlw_24"/>
  10638. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  10639. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  10640. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  10641. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  10642. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  10643. <result column="QJJLW_6H" property="qjjlw_6h"/>
  10644. <result column="HZJLW_24H" property="hzjlw_24h"/>
  10645. <result column="SQTLXJW" property="sqtlxjw"/>
  10646. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  10647. <result column="XHSCW_30M" property="xhscw_30m"/>
  10648. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  10649. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  10650. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  10651. <result column="ZKJLW_24" property="zkjlw_24"/>
  10652. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  10653. <result column="SXHWJL" property="sxhwjl"/>
  10654. <result column="SXPJW_24" property="sxpjw_24"/>
  10655. <result column="WJZWJL" property="wjzwjl"/>
  10656. <result column="WYWWCXJ" property="wywwcxj"/>
  10657. </collection>
  10658. </collection>
  10659. </resultMap>
  10660. <resultMap id="MedicalCheckByDeptMap" type="com.diagbot.dto.MedicalDeptDTO">
  10661. <result column="deptName" property="deptName"/>
  10662. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  10663. ofType="com.diagbot.dto.MedicalDoDeptDTO">
  10664. <result column="doctorGroup" property="doctorGroup"/>
  10665. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  10666. ofType="com.diagbot.dto.MedicalSeeByDeptDTO">
  10667. <result column="doctorName" property="doctorName"/>
  10668. <result column="RYJLW_24" property="ryjlw_24"/>
  10669. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  10670. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  10671. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  10672. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  10673. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  10674. <result column="QJJLW_6H" property="qjjlw_6h"/>
  10675. <result column="HZJLW_24H" property="hzjlw_24h"/>
  10676. <result column="SQTLXJW" property="sqtlxjw"/>
  10677. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  10678. <result column="XHSCW_30M" property="xhscw_30m"/>
  10679. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  10680. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  10681. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  10682. <result column="ZKJLW_24" property="zkjlw_24"/>
  10683. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  10684. <result column="SXHWJL" property="sxhwjl"/>
  10685. <result column="SXPJW_24" property="sxpjw_24"/>
  10686. <result column="WJZWJL" property="wjzwjl"/>
  10687. <result column="WYWWCXJ" property="wywwcxj"/>
  10688. </collection>
  10689. </collection>
  10690. </resultMap>
  10691. <!-- 病历稽查表最新导出-->
  10692. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  10693. SELECT
  10694. a.beh_dept_id AS deptId,
  10695. a.beh_dept_name AS deptName,
  10696. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  10697. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  10698. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  10699. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  10700. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  10701. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  10702. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  10703. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  10704. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  10705. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  10706. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  10707. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  10708. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  10709. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  10710. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  10711. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  10712. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  10713. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  10714. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  10715. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  10716. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  10717. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  10718. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  10719. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  10720. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  10721. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  10722. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  10723. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  10724. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  10725. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  10726. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  10727. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  10728. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  10729. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  10730. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  10731. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  10732. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  10733. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  10734. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  10735. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  10736. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  10737. FROM
  10738. med_behospital_info a,
  10739. med_qcresult_info b,
  10740. med_qcresult_detail c,
  10741. qc_cases_entry d,
  10742. bas_doctor_info e
  10743. WHERE
  10744. a.is_deleted = 'N'
  10745. AND b.is_deleted = 'N'
  10746. AND c.is_deleted = 'N'
  10747. AND d.is_deleted = 'N'
  10748. AND e.is_deleted = 'N'
  10749. AND a.hospital_id = b.hospital_id
  10750. AND a.hospital_id = c.hospital_id
  10751. AND a.hospital_id = e.hospital_id
  10752. AND a.behospital_code = b.behospital_code
  10753. AND a.behospital_code = c.behospital_code
  10754. AND a.beh_dept_id = e.dept_id
  10755. AND c.cases_entry_id = d.id
  10756. and a.doctor_id=e.doctor_id
  10757. and e.group_id is not NULL
  10758. AND LENGTH(e.group_id)>0
  10759. AND a.qc_type_id != 0
  10760. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10761. and a.is_placefile = #{filterVO.isPlacefile}
  10762. </if>
  10763. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10764. AND a.hospital_id = #{filterVO.hospitalId}
  10765. </if>
  10766. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10767. <if test="filterVO.startDate != null ">
  10768. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10769. </if>
  10770. <if test="filterVO.endDate != null ">
  10771. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10772. </if>
  10773. </if>
  10774. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10775. <if test="filterVO.startDate != null ">
  10776. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10777. </if>
  10778. <if test="filterVO.endDate != null ">
  10779. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10780. </if>
  10781. </if>
  10782. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10783. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  10784. </if>
  10785. GROUP BY
  10786. a.beh_dept_id,
  10787. e.group_id
  10788. </select>
  10789. <!-- 病历稽查表最新导出-->
  10790. <select id="medicalCheckExportByDept" resultMap="MedicalCheckByDeptMap">
  10791. SELECT
  10792. a.beh_dept_id AS deptId,
  10793. a.beh_dept_name AS deptName,
  10794. a.doctor_name as doctorGroup,
  10795. a.doctor_name as doctorName,
  10796. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  10797. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  10798. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  10799. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  10800. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  10801. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  10802. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  10803. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  10804. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  10805. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  10806. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  10807. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  10808. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  10809. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  10810. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  10811. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  10812. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  10813. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  10814. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  10815. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  10816. FROM
  10817. med_behospital_info a,
  10818. med_qcresult_info b,
  10819. med_qcresult_detail c,
  10820. qc_cases_entry d,
  10821. bas_doctor_info e,
  10822. sys_user_dept f
  10823. WHERE
  10824. a.is_deleted = 'N'
  10825. AND b.is_deleted = 'N'
  10826. AND c.is_deleted = 'N'
  10827. AND d.is_deleted = 'N'
  10828. AND e.is_deleted = 'N'
  10829. AND f.is_deleted = 'N'
  10830. AND a.hospital_id = b.hospital_id
  10831. AND a.hospital_id = c.hospital_id
  10832. AND a.hospital_id = e.hospital_id
  10833. AND a.hospital_id = f.hospital_id
  10834. AND a.behospital_code = b.behospital_code
  10835. AND a.behospital_code = c.behospital_code
  10836. AND a.beh_dept_id = f.dept_id
  10837. AND c.cases_entry_id = d.id
  10838. and a.doctor_id=e.doctor_id
  10839. and e.group_id is not NULL
  10840. AND LENGTH(e.group_id)>0
  10841. AND a.qc_type_id != 0
  10842. <if test="filterVO.userId!=null">
  10843. AND f.user_id = #{filterVO.userId}
  10844. </if>
  10845. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  10846. and a.is_placefile = #{filterVO.isPlacefile}
  10847. </if>
  10848. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  10849. AND a.hospital_id = #{filterVO.hospitalId}
  10850. </if>
  10851. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  10852. <if test="filterVO.startDate != null ">
  10853. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  10854. </if>
  10855. <if test="filterVO.endDate != null ">
  10856. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  10857. </if>
  10858. </if>
  10859. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  10860. <if test="filterVO.startDate != null ">
  10861. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  10862. </if>
  10863. <if test="filterVO.endDate != null ">
  10864. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  10865. </if>
  10866. </if>
  10867. <if test="filterVO.name != null and filterVO.name != ''">
  10868. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  10869. </if>
  10870. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  10871. AND a.beh_dept_name = #{filterVO.deptName}
  10872. </if>
  10873. GROUP BY
  10874. a.beh_dept_id,
  10875. e.group_id,
  10876. a.doctor_name
  10877. </select>
  10878. <!-- 未整改病历统计-->
  10879. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  10880. SELECT
  10881. a.beh_dept_id AS deptId,
  10882. a.beh_dept_name AS deptName,
  10883. d.id AS casesEntryId,
  10884. d.NAME AS casesEntryName,
  10885. count(*) AS casesEntryNum
  10886. FROM
  10887. med_behospital_info a,
  10888. med_qcresult_info b,
  10889. med_qcresult_detail c,
  10890. qc_cases_entry d
  10891. WHERE
  10892. a.is_deleted = 'N'
  10893. AND b.is_deleted = 'N'
  10894. AND c.is_deleted = 'N'
  10895. AND d.is_deleted = 'N'
  10896. AND a.hospital_id = b.hospital_id
  10897. AND a.hospital_id = c.hospital_id
  10898. AND a.behospital_code = b.behospital_code
  10899. AND a.behospital_code = c.behospital_code
  10900. AND c.cases_entry_id = d.id
  10901. AND a.qc_type_id != 0
  10902. <if test="isPlacefile != null and isPlacefile != ''">
  10903. and a.is_placefile = #{isPlacefile}
  10904. </if>
  10905. <if test="hospitalId != null and hospitalId != ''">
  10906. AND a.hospital_id = #{hospitalId}
  10907. </if>
  10908. <if test="isPlacefile != null and isPlacefile == 0">
  10909. <if test="startDate != null ">
  10910. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  10911. </if>
  10912. <if test="endDate != null ">
  10913. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  10914. </if>
  10915. </if>
  10916. <if test="isPlacefile != null and isPlacefile == 1">
  10917. <if test="startDate != null ">
  10918. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  10919. </if>
  10920. <if test="endDate != null ">
  10921. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  10922. </if>
  10923. </if>
  10924. <if test="deptName != null and deptName != ''">
  10925. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  10926. </if>
  10927. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  10928. AND c.cases_entry_id IN
  10929. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  10930. #{item}
  10931. </foreach>
  10932. </if>
  10933. GROUP BY
  10934. a.beh_dept_id,
  10935. a.beh_dept_name,
  10936. c.cases_entry_id,
  10937. d.NAME
  10938. </select>
  10939. <!-- 未整改病历统计-科室-->
  10940. <select id="unModifyMRSByDept" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  10941. SELECT
  10942. a.beh_dept_id AS deptId,
  10943. a.beh_dept_name AS deptName,
  10944. a.doctor_id as doctorId,
  10945. a.doctor_name as doctorName,
  10946. d.id AS casesEntryId,
  10947. d.NAME AS casesEntryName,
  10948. count(*) AS casesEntryNum
  10949. FROM
  10950. med_behospital_info a,
  10951. med_qcresult_info b,
  10952. med_qcresult_detail c,
  10953. qc_cases_entry d,
  10954. sys_user_dept f
  10955. WHERE
  10956. a.is_deleted = 'N'
  10957. AND b.is_deleted = 'N'
  10958. AND c.is_deleted = 'N'
  10959. AND d.is_deleted = 'N'
  10960. AND f.is_deleted = 'N'
  10961. AND a.hospital_id = b.hospital_id
  10962. AND a.hospital_id = c.hospital_id
  10963. AND a.hospital_id = f.hospital_id
  10964. AND a.behospital_code = b.behospital_code
  10965. AND a.behospital_code = c.behospital_code
  10966. AND a.beh_dept_id = f.dept_id
  10967. AND c.cases_entry_id = d.id
  10968. AND a.qc_type_id != 0
  10969. <if test="userId!=null">
  10970. AND f.user_id = #{userId}
  10971. </if>
  10972. <if test="isPlacefile != null and isPlacefile != ''">
  10973. and a.is_placefile = #{isPlacefile}
  10974. </if>
  10975. <if test="hospitalId != null and hospitalId != ''">
  10976. AND a.hospital_id = #{hospitalId}
  10977. </if>
  10978. <if test="isPlacefile != null and isPlacefile == 0">
  10979. <if test="startDate != null ">
  10980. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  10981. </if>
  10982. <if test="endDate != null ">
  10983. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  10984. </if>
  10985. </if>
  10986. <if test="isPlacefile != null and isPlacefile == 1">
  10987. <if test="startDate != null ">
  10988. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  10989. </if>
  10990. <if test="endDate != null ">
  10991. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  10992. </if>
  10993. </if>
  10994. <if test="deptName != null and deptName != ''">
  10995. AND a.beh_dept_name= #{deptName}
  10996. </if>
  10997. <if test="doctorName != null and doctorName != ''">
  10998. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  10999. </if>
  11000. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  11001. AND c.cases_entry_id IN
  11002. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  11003. #{item}
  11004. </foreach>
  11005. </if>
  11006. GROUP BY
  11007. a.doctor_id,
  11008. a.doctor_name,
  11009. c.cases_entry_id,
  11010. d.NAME
  11011. </select>
  11012. <!-- 不合格/合格数病历号(内页)科室-->
  11013. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  11014. SELECT t.*
  11015. FROM
  11016. (SELECT DISTINCT
  11017. t1.hospital_id AS hospitalId,
  11018. t1.behospital_code AS behospitalCode,
  11019. t1.bed_code AS bedCode,
  11020. t1.LEVEL AS LEVEL,
  11021. t1.grade_type AS gradeType,
  11022. t1.score_res AS scoreRes,
  11023. t1.scoreBn,
  11024. t1.NAME AS NAME,
  11025. t1.sex AS sex,
  11026. t1.beh_dept_id AS behDeptId,
  11027. t1.beh_dept_name AS behDeptName,
  11028. t1.doctor_id AS doctorId,
  11029. t1.doctor_name AS doctorName,
  11030. t1.beh_doctor_id AS behDoctorId,
  11031. t1.beh_doctor_name AS behDoctorName,
  11032. t1.director_doctor_id AS directorDoctorId,
  11033. t1.director_doctor_name AS directorDoctorName,
  11034. t1.birthday AS birthday,
  11035. t1.behospital_date AS behospitalDate,
  11036. t1.leave_hospital_date AS leaveHospitalDate,
  11037. t1.placefile_date AS placefileDate,
  11038. t1.gmt_create AS gradeTime,
  11039. t1.diagnose,
  11040. t1.ward_name AS wardName,
  11041. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11042. t1.file_code AS fileCode,
  11043. t1.checkStatus,
  11044. t1.mrStatus,
  11045. t1.chName,
  11046. t1.mrName,
  11047. t1.chTime,
  11048. t1.mrTime
  11049. FROM
  11050. (SELECT
  11051. be.*,
  11052. b.LEVEL,
  11053. b.grade_type,
  11054. b.score_res,
  11055. b.gmt_create,
  11056. ifnull(mci.status,0) AS checkStatus,
  11057. ifnull(hm_mci.status,0) AS mrStatus,
  11058. mci.check_name as chName,
  11059. hm_mci.check_name as mrName,
  11060. mci.gmt_create as chTime,
  11061. hm_mci.gmt_create as mrTime
  11062. FROM
  11063. (
  11064. SELECT DISTINCT
  11065. a.hospital_id,
  11066. a.behospital_code,
  11067. a.bed_code,
  11068. a.file_code,
  11069. e.score_res as scoreBn,
  11070. a.NAME,
  11071. a.sex,
  11072. a.beh_dept_id,
  11073. a.beh_dept_name,
  11074. a.birthday,
  11075. a.behospital_date,
  11076. a.leave_hospital_date,
  11077. a.doctor_id,
  11078. a.doctor_name,
  11079. a.beh_doctor_id,
  11080. a.beh_doctor_name,
  11081. a.director_doctor_id,
  11082. a.director_doctor_name,
  11083. a.diagnose,
  11084. a.placefile_date,
  11085. a.ward_name
  11086. FROM
  11087. med_behospital_info a,
  11088. sys_user_dept c,
  11089. med_qcresult_cases e
  11090. WHERE
  11091. a.is_deleted = 'N'
  11092. AND c.is_deleted = 'N'
  11093. AND e.is_deleted = 'N'
  11094. AND a.hospital_id = c.hospital_id
  11095. AND a.hospital_id = e.hospital_id
  11096. AND a.beh_dept_id = c.dept_id
  11097. AND a.behospital_code = e.behospital_code
  11098. AND a.qc_type_id != 0
  11099. AND e.cases_id = 243
  11100. <if test="userId!=null">
  11101. AND c.user_id = #{userId}
  11102. </if>
  11103. <if test="deptName != null and deptName != ''">
  11104. and a.beh_dept_name = #{deptName}
  11105. </if>
  11106. <if test="deptClass != null and deptClass != ''">
  11107. and a.beh_dept_id = #{deptClass}
  11108. </if>
  11109. <if test="titleName != null and titleName != '' ">
  11110. <if test="titleName == '不合格数'">
  11111. AND e.`level`='不合格'
  11112. </if>
  11113. <if test="titleName == '合格数'">
  11114. AND e.`level`='合格'
  11115. </if>
  11116. </if>
  11117. <if test="isPlacefile != null and isPlacefile != ''">
  11118. and a.is_placefile = #{isPlacefile}
  11119. </if>
  11120. <if test="doctorName != null and doctorName != ''">
  11121. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11122. </if>
  11123. <if test="hospitalId != null and hospitalId != ''">
  11124. AND a.hospital_id = #{hospitalId}
  11125. </if>
  11126. <if test="isPlacefile != null and isPlacefile == 0">
  11127. <if test="startDate != null ">
  11128. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11129. </if>
  11130. <if test="endDate != null ">
  11131. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11132. </if>
  11133. </if>
  11134. <if test="isPlacefile != null and isPlacefile == 1">
  11135. <if test="startDate != null ">
  11136. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11137. </if>
  11138. <if test="endDate != null">
  11139. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11140. </if>
  11141. </if>
  11142. <if test="diagnose != null and diagnose != ''">
  11143. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11144. </if>
  11145. <if test="behospitalCode != null and behospitalCode != ''">
  11146. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11147. </if>
  11148. <if test="patName != null and patName != ''">
  11149. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11150. </if>
  11151. <if test="doctorId != null and doctorId != ''">
  11152. AND (a.doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  11153. OR a.beh_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' )
  11154. OR a.director_doctor_id LIKE CONCAT( '%', #{doctorId}, '%' ))
  11155. </if>
  11156. )be
  11157. left join med_check_info mci
  11158. on mci.is_deleted = 'N'
  11159. and mci.check_type = 0
  11160. and be.hospital_id = mci.hospital_id
  11161. and be.behospital_code = mci.behospital_code
  11162. left join med_check_info hm_mci
  11163. on hm_mci.is_deleted = 'N'
  11164. and hm_mci.check_type = 1
  11165. and be.hospital_id = hm_mci.hospital_id
  11166. and be.behospital_code = hm_mci.behospital_code
  11167. left join med_qcresult_info b
  11168. on b.is_deleted = 'N'
  11169. AND be.hospital_id = b.hospital_id
  11170. AND be.behospital_code = b.behospital_code
  11171. where
  11172. 1=1
  11173. <if test="level != null and level != ''">
  11174. AND b.`level` = #{level}
  11175. </if>
  11176. ) t1
  11177. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11178. AND t1.behospital_code = t2.behospital_code
  11179. AND t2.is_deleted = 'N'
  11180. ) t,
  11181. (
  11182. SELECT
  11183. a.doctor_id as doctorId,
  11184. a.doctor_name as doctorName
  11185. FROM
  11186. med_behospital_info a,
  11187. sys_user_dept b,
  11188. med_qcresult_cases c,
  11189. med_qcresult_detail d,
  11190. qc_cases_entry e
  11191. WHERE
  11192. a.is_deleted = 'N'
  11193. AND b.is_deleted = 'N'
  11194. AND c.is_deleted = 'N'
  11195. AND d.is_deleted = 'N'
  11196. AND e.is_deleted = 'N'
  11197. AND a.hospital_id = b.hospital_id
  11198. AND a.hospital_id = c.hospital_id
  11199. AND a.hospital_id = d.hospital_id
  11200. AND a.behospital_code = c.behospital_code
  11201. AND a.behospital_code = d.behospital_code
  11202. AND a.beh_dept_id = b.dept_id
  11203. AND c.cases_id = d.cases_id
  11204. AND d.cases_id = e.cases_id
  11205. AND d.cases_entry_id = e.id
  11206. AND d.cases_id = 243
  11207. AND a.qc_type_id != 0
  11208. <!-- <if test="titleName != null ">-->
  11209. <!-- <if test="titleName == '不合格数'">-->
  11210. <!-- AND c.`level`='不合格'-->
  11211. <!-- </if>-->
  11212. <!-- <if test="titleName == '合格数'">-->
  11213. <!-- AND c.`level`='合格'-->
  11214. <!-- </if>-->
  11215. <!-- </if>-->
  11216. <if test="userId!=null">
  11217. AND b.user_id = #{userId}
  11218. </if>
  11219. <if test="deptName != null and deptName != ''">
  11220. and a.beh_dept_name = #{deptName}
  11221. </if>
  11222. <if test="doctorName != null and doctorName != ''">
  11223. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  11224. </if>
  11225. <if test="deptClass != null and deptClass != ''">
  11226. and a.beh_dept_id = #{deptClass}
  11227. </if>
  11228. <if test="isPlacefile != null and isPlacefile != ''">
  11229. and a.is_placefile = #{isPlacefile}
  11230. </if>
  11231. <if test="hospitalId != null and hospitalId != ''">
  11232. AND a.hospital_id = #{hospitalId}
  11233. </if>
  11234. <if test="isPlacefile != null and isPlacefile == 0">
  11235. <if test="startDate != null ">
  11236. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11237. </if>
  11238. <if test="endDate != null ">
  11239. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11240. </if>
  11241. </if>
  11242. <if test="isPlacefile != null and isPlacefile == 1">
  11243. <if test="startDate != null ">
  11244. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11245. </if>
  11246. <if test="endDate != null">
  11247. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11248. </if>
  11249. </if>
  11250. <if test="diagnose != null and diagnose != ''">
  11251. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  11252. </if>
  11253. <if test="behospitalCode != null and behospitalCode != ''">
  11254. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  11255. </if>
  11256. <if test="patName != null and patName != ''">
  11257. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  11258. </if>
  11259. GROUP BY
  11260. a.doctor_id,
  11261. a.doctor_name
  11262. ) t2
  11263. where
  11264. t.doctorId = t2.doctorId
  11265. AND t.doctorName = t2.doctorName
  11266. <if test="checkStatus != null">
  11267. AND t.checkStatus = #{checkStatus}
  11268. </if>
  11269. <if test="mrStatus != null">
  11270. AND t.mrStatus = #{mrStatus}
  11271. </if>
  11272. <if test="chName != null and chName!=''">
  11273. AND t.chName like concat('%', #{chName}, '%')
  11274. </if>
  11275. <if test="mrName != null and mrName!=''">
  11276. AND t.mrName like concat('%', #{mrName}, '%')
  11277. </if>
  11278. <if test="chTimeStart != null ">
  11279. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  11280. </if>
  11281. <if test="chTimeEnd != null ">
  11282. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  11283. </if>
  11284. <if test="mrTimeStart != null ">
  11285. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  11286. </if>
  11287. <if test="mrTimeEnd != null ">
  11288. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  11289. </if>
  11290. </select>
  11291. <!-- 不合格/合格数病历号(内页)全院-->
  11292. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11293. SELECT t.*
  11294. FROM
  11295. (SELECT DISTINCT
  11296. t1.hospital_id AS hospitalId,
  11297. t1.behospital_code AS behospitalCode,
  11298. t1.bed_code AS bedCode,
  11299. t1.LEVEL AS LEVEL,
  11300. t1.grade_type AS gradeType,
  11301. t1.score_res AS scoreRes,
  11302. t1.scoreBn,
  11303. t1.NAME AS NAME,
  11304. t1.sex AS sex,
  11305. t1.beh_dept_id AS behDeptId,
  11306. t1.beh_dept_name AS behDeptName,
  11307. t1.doctor_id AS doctorId,
  11308. t1.doctor_name AS doctorName,
  11309. t1.beh_doctor_id AS behDoctorId,
  11310. t1.beh_doctor_name AS behDoctorName,
  11311. t1.director_doctor_id AS directorDoctorId,
  11312. t1.director_doctor_name AS directorDoctorName,
  11313. t1.birthday AS birthday,
  11314. t1.behospital_date AS behospitalDate,
  11315. t1.leave_hospital_date AS leaveHospitalDate,
  11316. t1.placefile_date AS placefileDate,
  11317. t1.gmt_create AS gradeTime,
  11318. t1.diagnose,
  11319. t1.ward_name AS wardName,
  11320. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11321. t1.file_code AS fileCode,
  11322. t1.checkStatus,
  11323. t1.mrStatus,
  11324. t1.chName,
  11325. t1.mrName,
  11326. t1.chTime,
  11327. t1.mrTime
  11328. FROM
  11329. (SELECT
  11330. be.*,
  11331. b.LEVEL,
  11332. b.grade_type,
  11333. b.score_res,
  11334. b.gmt_create,
  11335. ifnull(mci.status,0) AS checkStatus,
  11336. ifnull(hm_mci.status,0) AS mrStatus,
  11337. mci.check_name as chName,
  11338. hm_mci.check_name as mrName,
  11339. mci.gmt_create as chTime,
  11340. hm_mci.gmt_create as mrTime
  11341. FROM
  11342. (
  11343. SELECT DISTINCT
  11344. a.hospital_id,
  11345. a.behospital_code,
  11346. a.bed_code,
  11347. a.file_code,
  11348. e.score_res as scoreBn,
  11349. a.NAME,
  11350. a.sex,
  11351. a.beh_dept_id,
  11352. a.beh_dept_name,
  11353. a.birthday,
  11354. a.behospital_date,
  11355. a.leave_hospital_date,
  11356. a.doctor_id,
  11357. a.doctor_name,
  11358. a.beh_doctor_id,
  11359. a.beh_doctor_name,
  11360. a.director_doctor_id,
  11361. a.director_doctor_name,
  11362. a.diagnose,
  11363. a.placefile_date,
  11364. a.ward_name
  11365. FROM
  11366. med_behospital_info a,
  11367. med_qcresult_cases e
  11368. WHERE
  11369. a.is_deleted = 'N'
  11370. AND e.is_deleted = 'N'
  11371. AND a.hospital_id = e.hospital_id
  11372. AND a.behospital_code = e.behospital_code
  11373. AND a.qc_type_id != 0
  11374. AND e.cases_id = 243
  11375. <if test="qcResultPageVO.titleName != null ">
  11376. <if test="qcResultPageVO.titleName == '不合格数'">
  11377. AND e.`level`='不合格'
  11378. </if>
  11379. <if test="qcResultPageVO.titleName == '合格数'">
  11380. AND e.`level`='合格'
  11381. </if>
  11382. </if>
  11383. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11384. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11385. </if>
  11386. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11387. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11388. </if>
  11389. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11390. <if test="qcResultPageVO.startDate != null ">
  11391. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11392. </if>
  11393. <if test="qcResultPageVO.endDate != null ">
  11394. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11395. </if>
  11396. </if>
  11397. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11398. <if test="qcResultPageVO.startDate != null ">
  11399. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11400. </if>
  11401. <if test="qcResultPageVO.endDate != null">
  11402. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11403. </if>
  11404. </if>
  11405. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11406. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11407. </if>
  11408. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11409. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  11410. </if>
  11411. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11412. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11413. </if>
  11414. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11415. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11416. </if>
  11417. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11418. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11419. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11420. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11421. </if>
  11422. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11423. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11424. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11425. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11426. </if>
  11427. )be
  11428. left join med_check_info mci
  11429. on mci.is_deleted = 'N'
  11430. and mci.check_type = 0
  11431. and be.hospital_id = mci.hospital_id
  11432. and be.behospital_code = mci.behospital_code
  11433. left join med_check_info hm_mci
  11434. on hm_mci.is_deleted = 'N'
  11435. and hm_mci.check_type = 1
  11436. and be.hospital_id = hm_mci.hospital_id
  11437. and be.behospital_code = hm_mci.behospital_code
  11438. left join med_qcresult_info b
  11439. on b.is_deleted = 'N'
  11440. AND be.hospital_id = b.hospital_id
  11441. AND be.behospital_code = b.behospital_code
  11442. where
  11443. 1=1
  11444. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  11445. AND b.`level` = #{qcResultPageVO.level}
  11446. </if>
  11447. ) t1
  11448. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11449. AND t1.behospital_code = t2.behospital_code
  11450. AND t2.is_deleted = 'N'
  11451. ) t,
  11452. (
  11453. SELECT
  11454. a.beh_dept_id AS deptId,
  11455. a.beh_dept_name AS deptName
  11456. FROM
  11457. med_behospital_info a,
  11458. med_qcresult_cases c,
  11459. med_qcresult_detail d,
  11460. qc_cases_entry e
  11461. WHERE
  11462. a.is_deleted = 'N'
  11463. AND c.is_deleted = 'N'
  11464. AND d.is_deleted = 'N'
  11465. AND e.is_deleted = 'N'
  11466. AND a.hospital_id = c.hospital_id
  11467. AND a.hospital_id = d.hospital_id
  11468. AND a.behospital_code = c.behospital_code
  11469. AND a.behospital_code = d.behospital_code
  11470. AND c.cases_id = d.cases_id
  11471. AND d.cases_id = e.cases_id
  11472. AND d.cases_entry_id = e.id
  11473. AND d.cases_id = 243
  11474. AND a.qc_type_id != 0
  11475. <!-- <if test="qcResultPageVO.titleName != null ">-->
  11476. <!-- <if test="qcResultPageVO.titleName == '不合格数'">-->
  11477. <!-- AND c.`level`='不合格'-->
  11478. <!-- </if>-->
  11479. <!-- <if test="qcResultPageVO.titleName == '合格数'">-->
  11480. <!-- AND c.`level`='合格'-->
  11481. <!-- </if>-->
  11482. <!-- </if>-->
  11483. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  11484. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  11485. </if>
  11486. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  11487. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  11488. </if>
  11489. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  11490. <if test="qcResultPageVO.startDate != null ">
  11491. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  11492. </if>
  11493. <if test="qcResultPageVO.endDate != null ">
  11494. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  11495. </if>
  11496. </if>
  11497. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  11498. <if test="qcResultPageVO.startDate != null ">
  11499. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  11500. </if>
  11501. <if test="qcResultPageVO.endDate != null">
  11502. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  11503. </if>
  11504. </if>
  11505. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  11506. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  11507. </if>
  11508. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  11509. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  11510. </if>
  11511. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  11512. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  11513. </if>
  11514. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  11515. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  11516. </if>
  11517. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  11518. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11519. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  11520. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  11521. </if>
  11522. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  11523. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11524. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  11525. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  11526. </if>
  11527. GROUP BY
  11528. a.beh_dept_id,
  11529. a.beh_dept_name
  11530. ) t2
  11531. where
  11532. t.behDeptId = t2.deptId
  11533. AND t.behDeptName = t2.deptName
  11534. <if test="qcResultPageVO.checkStatus != null">
  11535. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  11536. </if>
  11537. <if test="qcResultPageVO.mrStatus != null">
  11538. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  11539. </if>
  11540. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  11541. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  11542. </if>
  11543. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  11544. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  11545. </if>
  11546. <if test="qcResultPageVO.chTimeStart != null ">
  11547. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  11548. </if>
  11549. <if test="qcResultPageVO.chTimeEnd != null ">
  11550. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  11551. </if>
  11552. <if test="qcResultPageVO.mrTimeStart != null ">
  11553. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  11554. </if>
  11555. <if test="qcResultPageVO.mrTimeEnd != null ">
  11556. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  11557. </if>
  11558. </select>
  11559. <!-- 未整改病历质控评分页(内页)-->
  11560. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  11561. SELECT t.*
  11562. FROM
  11563. (SELECT DISTINCT
  11564. t1.hospital_id AS hospitalId,
  11565. t1.behospital_code AS behospitalCode,
  11566. t1.bed_code AS bedCode,
  11567. t1.LEVEL AS LEVEL,
  11568. t1.grade_type AS gradeType,
  11569. t1.score_res AS scoreRes,
  11570. t1.scoreBn,
  11571. t1.NAME AS NAME,
  11572. t1.sex AS sex,
  11573. t1.beh_dept_id AS behDeptId,
  11574. t1.beh_dept_name AS behDeptName,
  11575. t1.doctor_id AS doctorId,
  11576. t1.doctor_name AS doctorName,
  11577. t1.beh_doctor_id AS behDoctorId,
  11578. t1.beh_doctor_name AS behDoctorName,
  11579. t1.director_doctor_id AS directorDoctorId,
  11580. t1.director_doctor_name AS directorDoctorName,
  11581. t1.birthday AS birthday,
  11582. t1.behospital_date AS behospitalDate,
  11583. t1.leave_hospital_date AS leaveHospitalDate,
  11584. t1.placefile_date AS placefileDate,
  11585. t1.gmt_create AS gradeTime,
  11586. t1.diagnose,
  11587. t1.ward_name AS wardName,
  11588. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11589. t1.file_code AS fileCode,
  11590. t1.checkStatus,
  11591. t1.mrStatus,
  11592. t1.chName,
  11593. t1.mrName,
  11594. t1.chTime,
  11595. t1.mrTime
  11596. FROM
  11597. (SELECT
  11598. be.*,
  11599. ifnull(mci.status,0) AS checkStatus,
  11600. ifnull(hm_mci.status,0) AS mrStatus,
  11601. mci.check_name as chName,
  11602. e.score_res as scoreBn,
  11603. hm_mci.check_name as mrName,
  11604. mci.gmt_create as chTime,
  11605. hm_mci.gmt_create as mrTime
  11606. FROM
  11607. (
  11608. SELECT DISTINCT
  11609. a.hospital_id,
  11610. a.behospital_code,
  11611. a.bed_code,
  11612. a.file_code,
  11613. b.LEVEL,
  11614. b.grade_type,
  11615. b.score_res,
  11616. a.NAME,
  11617. a.sex,
  11618. a.beh_dept_id,
  11619. a.beh_dept_name,
  11620. a.birthday,
  11621. a.behospital_date,
  11622. a.leave_hospital_date,
  11623. a.doctor_id,
  11624. a.doctor_name,
  11625. a.beh_doctor_id,
  11626. a.beh_doctor_name,
  11627. a.director_doctor_id,
  11628. a.director_doctor_name,
  11629. a.diagnose,
  11630. a.placefile_date,
  11631. a.ward_name,
  11632. b.gmt_create
  11633. FROM
  11634. med_behospital_info a,
  11635. med_qcresult_info b,
  11636. med_qcresult_detail c,
  11637. qc_cases_entry d
  11638. WHERE
  11639. a.is_deleted = 'N'
  11640. AND b.is_deleted = 'N'
  11641. AND c.is_deleted = 'N'
  11642. AND d.is_deleted = 'N'
  11643. AND a.hospital_id = b.hospital_id
  11644. AND a.hospital_id = c.hospital_id
  11645. AND a.behospital_code = b.behospital_code
  11646. AND a.behospital_code = c.behospital_code
  11647. AND c.cases_id = d.cases_id
  11648. AND c.cases_entry_id = d.id
  11649. AND a.qc_type_id != 0
  11650. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11651. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11652. </if>
  11653. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11654. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11655. </if>
  11656. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11657. <if test="qcResultShortPageVO.startDate != null ">
  11658. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11659. </if>
  11660. <if test="qcResultShortPageVO.endDate != null ">
  11661. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11662. </if>
  11663. </if>
  11664. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11665. <if test="qcResultShortPageVO.startDate != null ">
  11666. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11667. </if>
  11668. <if test="qcResultShortPageVO.endDate != null">
  11669. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11670. </if>
  11671. </if>
  11672. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11673. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11674. </if>
  11675. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11676. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11677. </if>
  11678. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11679. AND b.`level` = #{qcResultShortPageVO.level}
  11680. </if>
  11681. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11682. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11683. </if>
  11684. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11685. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11686. </if>
  11687. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11688. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11689. </if>
  11690. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11691. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11692. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11693. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11694. </if>
  11695. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11696. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11697. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11698. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11699. </if>
  11700. <if test="qcResultShortPageVO.casesEntryId != null ">
  11701. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11702. </if>
  11703. <if test="qcResultShortPageVO.isReject != null">
  11704. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11705. </if>
  11706. <if test="qcResultShortPageVO.ruleType != null">
  11707. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11708. </if>
  11709. )be
  11710. left join med_check_info mci
  11711. on mci.is_deleted = 'N'
  11712. and mci.check_type = 0
  11713. and be.hospital_id = mci.hospital_id
  11714. and be.behospital_code = mci.behospital_code
  11715. left join med_check_info hm_mci
  11716. on hm_mci.is_deleted = 'N'
  11717. and hm_mci.check_type = 1
  11718. and be.hospital_id = hm_mci.hospital_id
  11719. and be.behospital_code = hm_mci.behospital_code
  11720. LEFT JOIN med_qcresult_cases e
  11721. on be.behospital_code = e.behospital_code
  11722. and be.hospital_id = e.hospital_id
  11723. AND e.is_deleted = 'N'
  11724. and e.cases_id = 243
  11725. ) t1
  11726. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11727. AND t1.behospital_code = t2.behospital_code
  11728. AND t2.is_deleted = 'N'
  11729. ) t
  11730. where 1=1
  11731. <if test="qcResultShortPageVO.checkStatus != null">
  11732. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11733. </if>
  11734. <if test="qcResultShortPageVO.mrStatus != null">
  11735. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11736. </if>
  11737. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11738. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11739. </if>
  11740. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11741. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11742. </if>
  11743. <if test="qcResultShortPageVO.chTimeStart != null ">
  11744. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11745. </if>
  11746. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11747. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11748. </if>
  11749. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11750. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11751. </if>
  11752. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11753. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11754. </if>
  11755. </select>
  11756. <!-- 未整改病历质控评分页-科室(内页)-->
  11757. <select id="unModifyMRByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  11758. SELECT t.*
  11759. FROM
  11760. (SELECT DISTINCT
  11761. t1.hospital_id AS hospitalId,
  11762. t1.behospital_code AS behospitalCode,
  11763. t1.bed_code AS bedCode,
  11764. t1.LEVEL AS LEVEL,
  11765. t1.grade_type AS gradeType,
  11766. t1.score_res AS scoreRes,
  11767. t1.scoreBn,
  11768. t1.NAME AS NAME,
  11769. t1.sex AS sex,
  11770. t1.beh_dept_id AS behDeptId,
  11771. t1.beh_dept_name AS behDeptName,
  11772. t1.doctor_id AS doctorId,
  11773. t1.doctor_name AS doctorName,
  11774. t1.beh_doctor_id AS behDoctorId,
  11775. t1.beh_doctor_name AS behDoctorName,
  11776. t1.director_doctor_id AS directorDoctorId,
  11777. t1.director_doctor_name AS directorDoctorName,
  11778. t1.birthday AS birthday,
  11779. t1.behospital_date AS behospitalDate,
  11780. t1.leave_hospital_date AS leaveHospitalDate,
  11781. t1.placefile_date AS placefileDate,
  11782. t1.gmt_create AS gradeTime,
  11783. t1.diagnose,
  11784. t1.ward_name AS wardName,
  11785. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  11786. t1.file_code AS fileCode,
  11787. t1.checkStatus,
  11788. t1.mrStatus,
  11789. t1.chName,
  11790. t1.mrName,
  11791. t1.chTime,
  11792. t1.mrTime
  11793. FROM
  11794. (SELECT
  11795. be.*,
  11796. ifnull(mci.status,0) AS checkStatus,
  11797. ifnull(hm_mci.status,0) AS mrStatus,
  11798. mci.check_name as chName,
  11799. e.score_res as scoreBn,
  11800. hm_mci.check_name as mrName,
  11801. mci.gmt_create as chTime,
  11802. hm_mci.gmt_create as mrTime
  11803. FROM
  11804. (
  11805. SELECT DISTINCT
  11806. a.hospital_id,
  11807. a.behospital_code,
  11808. a.bed_code,
  11809. a.file_code,
  11810. b.LEVEL,
  11811. b.grade_type,
  11812. b.score_res,
  11813. a.NAME,
  11814. a.sex,
  11815. a.beh_dept_id,
  11816. a.beh_dept_name,
  11817. a.birthday,
  11818. a.behospital_date,
  11819. a.leave_hospital_date,
  11820. a.doctor_id,
  11821. a.doctor_name,
  11822. a.beh_doctor_id,
  11823. a.beh_doctor_name,
  11824. a.director_doctor_id,
  11825. a.director_doctor_name,
  11826. a.diagnose,
  11827. a.placefile_date,
  11828. a.ward_name,
  11829. b.gmt_create
  11830. FROM
  11831. med_behospital_info a,
  11832. med_qcresult_info b,
  11833. med_qcresult_detail c,
  11834. qc_cases_entry d,
  11835. sys_user_dept f
  11836. WHERE
  11837. a.is_deleted = 'N'
  11838. AND b.is_deleted = 'N'
  11839. AND c.is_deleted = 'N'
  11840. AND d.is_deleted = 'N'
  11841. AND f.is_deleted = 'N'
  11842. AND a.hospital_id = b.hospital_id
  11843. AND a.hospital_id = c.hospital_id
  11844. AND a.hospital_id = f.hospital_id
  11845. AND a.behospital_code = b.behospital_code
  11846. AND a.behospital_code = c.behospital_code
  11847. AND c.cases_id = d.cases_id
  11848. AND a.beh_dept_id = f.dept_id
  11849. AND c.cases_entry_id = d.id
  11850. AND a.qc_type_id != 0
  11851. <if test="qcResultShortPageVO.userId!=null">
  11852. AND f.user_id = #{qcResultShortPageVO.userId}
  11853. </if>
  11854. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11855. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11856. </if>
  11857. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11858. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11859. </if>
  11860. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11861. <if test="qcResultShortPageVO.startDate != null ">
  11862. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11863. </if>
  11864. <if test="qcResultShortPageVO.endDate != null ">
  11865. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11866. </if>
  11867. </if>
  11868. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11869. <if test="qcResultShortPageVO.startDate != null ">
  11870. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11871. </if>
  11872. <if test="qcResultShortPageVO.endDate != null">
  11873. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11874. </if>
  11875. </if>
  11876. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11877. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11878. </if>
  11879. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11880. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11881. </if>
  11882. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11883. AND b.`level` = #{qcResultShortPageVO.level}
  11884. </if>
  11885. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11886. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11887. </if>
  11888. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11889. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11890. </if>
  11891. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11892. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11893. </if>
  11894. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11895. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11896. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11897. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11898. </if>
  11899. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11900. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11901. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11902. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11903. </if>
  11904. <if test="qcResultShortPageVO.casesEntryId != null ">
  11905. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11906. </if>
  11907. <if test="qcResultShortPageVO.isReject != null">
  11908. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11909. </if>
  11910. <if test="qcResultShortPageVO.ruleType != null">
  11911. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11912. </if>
  11913. )be
  11914. left join med_check_info mci
  11915. on mci.is_deleted = 'N'
  11916. and mci.check_type = 0
  11917. and be.hospital_id = mci.hospital_id
  11918. and be.behospital_code = mci.behospital_code
  11919. left join med_check_info hm_mci
  11920. on hm_mci.is_deleted = 'N'
  11921. and hm_mci.check_type = 1
  11922. and be.hospital_id = hm_mci.hospital_id
  11923. and be.behospital_code = hm_mci.behospital_code
  11924. LEFT JOIN med_qcresult_cases e
  11925. on be.behospital_code = e.behospital_code
  11926. and be.hospital_id = e.hospital_id
  11927. AND e.is_deleted = 'N'
  11928. and e.cases_id = 243
  11929. ) t1
  11930. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11931. AND t1.behospital_code = t2.behospital_code
  11932. AND t2.is_deleted = 'N'
  11933. ) t
  11934. where 1=1
  11935. <if test="qcResultShortPageVO.checkStatus != null">
  11936. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11937. </if>
  11938. <if test="qcResultShortPageVO.mrStatus != null">
  11939. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11940. </if>
  11941. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11942. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11943. </if>
  11944. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11945. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11946. </if>
  11947. <if test="qcResultShortPageVO.chTimeStart != null ">
  11948. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11949. </if>
  11950. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11951. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11952. </if>
  11953. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11954. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11955. </if>
  11956. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11957. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11958. </if>
  11959. </select>
  11960. <!-- 病案首页不合格/合格数病历详情页导出-->
  11961. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  11962. SELECT
  11963. f1.behDeptId,
  11964. f1.behDeptName,
  11965. f1.doctorName,
  11966. f1.patName,
  11967. f1.behospitalCode,
  11968. f1.hospitalId,
  11969. f1.behospitalDate,
  11970. f1.leaveHospitalDate,
  11971. f1.score,
  11972. f1.scoreBn,
  11973. f2.avgScore,
  11974. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  11975. f1.msg,
  11976. f1.caseName,
  11977. </if>
  11978. f1.checkStatus,
  11979. f1.mrStatus,
  11980. f1.chName,
  11981. f1.mrName,
  11982. f1.chTime,
  11983. f1.mrTime
  11984. FROM
  11985. (SELECT
  11986. t.doctorName,
  11987. t.`name` AS patName,
  11988. t.behospitalCode AS behospitalCode,
  11989. t.behospitalDate AS behospitalDate,
  11990. t.leaveHospitalDate AS leaveHospitalDate,
  11991. qi.score_res AS score,
  11992. t.scoreBn,
  11993. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  11994. qd.msg AS msg,
  11995. qc.NAME AS caseName,
  11996. </if>
  11997. t.behDeptId,
  11998. t.behDeptName,
  11999. t.hospitalId,
  12000. t.checkStatus,
  12001. t.mrStatus,
  12002. t.chName,
  12003. t.mrName,
  12004. t.chTime,
  12005. t.mrTime
  12006. FROM
  12007. (SELECT DISTINCT
  12008. t1.hospital_id AS hospitalId,
  12009. t1.behospital_code AS behospitalCode,
  12010. t1.bed_code AS bedCode,
  12011. t1.LEVEL AS LEVEL,
  12012. t1.grade_type AS gradeType,
  12013. t1.score_res AS scoreRes,
  12014. t1.scoreBn,
  12015. t1.NAME AS NAME,
  12016. t1.sex AS sex,
  12017. t1.beh_dept_id AS behDeptId,
  12018. t1.beh_dept_name AS behDeptName,
  12019. t1.doctor_id AS doctorId,
  12020. t1.doctor_name AS doctorName,
  12021. t1.beh_doctor_id AS behDoctorId,
  12022. t1.beh_doctor_name AS behDoctorName,
  12023. t1.director_doctor_id AS directorDoctorId,
  12024. t1.director_doctor_name AS directorDoctorName,
  12025. t1.birthday AS birthday,
  12026. t1.behospital_date AS behospitalDate,
  12027. t1.leave_hospital_date AS leaveHospitalDate,
  12028. t1.placefile_date AS placefileDate,
  12029. t1.gmt_create AS gradeTime,
  12030. t1.diagnose,
  12031. t1.ward_name AS wardName,
  12032. t2.age,
  12033. t1.file_code AS fileCode,
  12034. t1.checkStatus,
  12035. t1.mrStatus,
  12036. t1.chName,
  12037. t1.mrName,
  12038. t1.chTime,
  12039. t1.mrTime
  12040. FROM
  12041. (SELECT
  12042. be.*,
  12043. b.LEVEL,
  12044. b.grade_type,
  12045. b.score_res,
  12046. b.gmt_create,
  12047. ifnull(mci.status,0) AS checkStatus,
  12048. ifnull(hm_mci.status,0) AS mrStatus,
  12049. mci.check_name as chName,
  12050. hm_mci.check_name as mrName,
  12051. mci.gmt_create as chTime,
  12052. hm_mci.gmt_create as mrTime
  12053. FROM
  12054. (
  12055. SELECT DISTINCT
  12056. a.hospital_id,
  12057. a.behospital_code,
  12058. a.bed_code,
  12059. a.file_code,
  12060. c.score_res as scoreBn,
  12061. c.cases_id,
  12062. a.NAME,
  12063. a.sex,
  12064. a.beh_dept_id,
  12065. a.beh_dept_name,
  12066. a.birthday,
  12067. a.behospital_date,
  12068. a.leave_hospital_date,
  12069. a.doctor_id,
  12070. a.doctor_name,
  12071. a.beh_doctor_id,
  12072. a.beh_doctor_name,
  12073. a.director_doctor_id,
  12074. a.director_doctor_name,
  12075. a.diagnose,
  12076. a.placefile_date,
  12077. a.ward_name
  12078. FROM
  12079. med_behospital_info a,
  12080. med_qcresult_cases c
  12081. WHERE
  12082. a.is_deleted = 'N'
  12083. AND c.is_deleted = 'N'
  12084. AND a.hospital_id = c.hospital_id
  12085. AND a.behospital_code = c.behospital_code
  12086. AND a.qc_type_id != 0
  12087. AND c.cases_id = 243
  12088. <if test="qcResultShortPageVO.titleName != null ">
  12089. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12090. AND c.`level`='不合格'
  12091. </if>
  12092. <if test="qcResultShortPageVO.titleName == '合格数'">
  12093. AND c.`level`='合格'
  12094. </if>
  12095. </if>
  12096. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12097. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12098. </if>
  12099. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12100. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12101. </if>
  12102. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12103. <if test="qcResultShortPageVO.startDate != null ">
  12104. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12105. </if>
  12106. <if test="qcResultShortPageVO.endDate != null ">
  12107. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12108. </if>
  12109. </if>
  12110. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12111. <if test="qcResultShortPageVO.startDate != null ">
  12112. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12113. </if>
  12114. <if test="qcResultShortPageVO.endDate != null">
  12115. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12116. </if>
  12117. </if>
  12118. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12119. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12120. </if>
  12121. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12122. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12123. </if>
  12124. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12125. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12126. </if>
  12127. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12128. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12129. </if>
  12130. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12131. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12132. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12133. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12134. </if>
  12135. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12136. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12137. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12138. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12139. </if>
  12140. )be
  12141. left join med_check_info mci
  12142. on mci.is_deleted = 'N'
  12143. and mci.check_type = 0
  12144. and be.hospital_id = mci.hospital_id
  12145. and be.behospital_code = mci.behospital_code
  12146. left join med_check_info hm_mci
  12147. on hm_mci.is_deleted = 'N'
  12148. and hm_mci.check_type = 1
  12149. and be.hospital_id = hm_mci.hospital_id
  12150. and be.behospital_code = hm_mci.behospital_code
  12151. left join med_qcresult_info b
  12152. on b.is_deleted = 'N'
  12153. AND be.hospital_id = b.hospital_id
  12154. AND be.behospital_code = b.behospital_code
  12155. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12156. AND b.`level` = #{qcResultPageVO.level}
  12157. </if>
  12158. left join qc_cases_entry d
  12159. on d.is_deleted = 'N'
  12160. AND be.cases_id = d.cases_id
  12161. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12162. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12163. </if>
  12164. <if test="qcResultShortPageVO.casesEntryId != null ">
  12165. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12166. </if>
  12167. <if test="qcResultShortPageVO.ruleType != null">
  12168. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12169. </if>
  12170. ) t1
  12171. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12172. AND t1.behospital_code = t2.behospital_code
  12173. AND t2.is_deleted = 'N'
  12174. ) t
  12175. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12176. AND t.hospitalId = qi.hospital_id
  12177. AND t.behospitalCode = qi.behospital_code
  12178. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12179. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12180. AND t.hospitalId = qd.hospital_id
  12181. AND t.behospitalCode = qd.behospital_code
  12182. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12183. AND qd.cases_id = qc.id
  12184. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12185. AND qd.cases_id = qce.cases_id
  12186. AND qd.cases_entry_id = qce.id
  12187. </if>
  12188. where 1=1
  12189. <if test="qcResultShortPageVO.checkStatus != null">
  12190. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12191. </if>
  12192. <if test="qcResultShortPageVO.mrStatus != null">
  12193. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12194. </if>
  12195. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12196. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12197. </if>
  12198. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12199. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12200. </if>
  12201. <if test="qcResultShortPageVO.chTimeStart != null ">
  12202. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12203. </if>
  12204. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12205. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12206. </if>
  12207. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12208. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12209. </if>
  12210. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12211. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12212. </if>
  12213. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12214. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12215. </if>
  12216. <if test="qcResultShortPageVO.casesEntryId != null ">
  12217. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12218. </if>
  12219. )f1,
  12220. (SELECT
  12221. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12222. t.behDeptId,
  12223. t.behDeptName
  12224. FROM
  12225. (SELECT DISTINCT
  12226. t1.hospital_id AS hospitalId,
  12227. t1.behospital_code AS behospitalCode,
  12228. t1.bed_code AS bedCode,
  12229. t1.LEVEL AS LEVEL,
  12230. t1.grade_type AS gradeType,
  12231. t1.score_res AS scoreRes,
  12232. t1.NAME AS NAME,
  12233. t1.sex AS sex,
  12234. t1.beh_dept_id AS behDeptId,
  12235. t1.beh_dept_name AS behDeptName,
  12236. t1.doctor_id AS doctorId,
  12237. t1.doctor_name AS doctorName,
  12238. t1.beh_doctor_id AS behDoctorId,
  12239. t1.beh_doctor_name AS behDoctorName,
  12240. t1.director_doctor_id AS directorDoctorId,
  12241. t1.director_doctor_name AS directorDoctorName,
  12242. t1.birthday AS birthday,
  12243. t1.behospital_date AS behospitalDate,
  12244. t1.leave_hospital_date AS leaveHospitalDate,
  12245. t1.placefile_date AS placefileDate,
  12246. t1.gmt_create AS gradeTime,
  12247. t1.diagnose,
  12248. t1.ward_name AS wardName,
  12249. t2.age,
  12250. t1.file_code AS fileCode,
  12251. t1.checkStatus,
  12252. t1.mrStatus,
  12253. t1.chName,
  12254. t1.mrName,
  12255. t1.chTime,
  12256. t1.mrTime
  12257. FROM
  12258. (SELECT
  12259. be.*,
  12260. b.grade_type,
  12261. b.score_res,
  12262. b.gmt_create,
  12263. b.LEVEL,
  12264. ifnull(mci.status,0) AS checkStatus,
  12265. ifnull(hm_mci.status,0) AS mrStatus,
  12266. mci.check_name as chName,
  12267. hm_mci.check_name as mrName,
  12268. mci.gmt_create as chTime,
  12269. hm_mci.gmt_create as mrTime
  12270. FROM
  12271. (
  12272. SELECT DISTINCT
  12273. a.hospital_id,
  12274. a.behospital_code,
  12275. a.bed_code,
  12276. a.file_code,
  12277. a.NAME,
  12278. a.sex,
  12279. a.beh_dept_id,
  12280. a.beh_dept_name,
  12281. a.birthday,
  12282. a.behospital_date,
  12283. a.leave_hospital_date,
  12284. a.doctor_id,
  12285. a.doctor_name,
  12286. a.beh_doctor_id,
  12287. a.beh_doctor_name,
  12288. a.director_doctor_id,
  12289. a.director_doctor_name,
  12290. a.diagnose,
  12291. a.placefile_date,
  12292. a.ward_name
  12293. FROM
  12294. med_behospital_info a,
  12295. med_qcresult_detail k,
  12296. med_qcresult_cases c,
  12297. qc_cases_entry d
  12298. WHERE
  12299. a.is_deleted = 'N'
  12300. AND c.is_deleted = 'N'
  12301. AND d.is_deleted = 'N'
  12302. AND a.hospital_id = c.hospital_id
  12303. AND a.behospital_code = c.behospital_code
  12304. AND c.cases_id = d.cases_id
  12305. AND a.hospital_id = k.hospital_id
  12306. AND a.behospital_code = k.behospital_code
  12307. AND c.cases_id = k.cases_id
  12308. AND k.cases_id = d.cases_id
  12309. AND k.cases_entry_id = d.id
  12310. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  12311. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  12312. <!-- AND c.`level`='不合格'-->
  12313. <!-- </if>-->
  12314. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  12315. <!-- AND c.`level`='合格'-->
  12316. <!-- </if>-->
  12317. <!-- </if>-->
  12318. AND a.qc_type_id != 0
  12319. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12320. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12321. </if>
  12322. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12323. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12324. </if>
  12325. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12326. <if test="qcResultShortPageVO.startDate != null ">
  12327. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12328. </if>
  12329. <if test="qcResultShortPageVO.endDate != null ">
  12330. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12331. </if>
  12332. </if>
  12333. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12334. <if test="qcResultShortPageVO.startDate != null ">
  12335. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12336. </if>
  12337. <if test="qcResultShortPageVO.endDate != null">
  12338. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12339. </if>
  12340. </if>
  12341. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12342. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12343. </if>
  12344. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12345. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12346. </if>
  12347. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12348. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12349. </if>
  12350. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12351. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12352. </if>
  12353. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12354. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12355. </if>
  12356. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12357. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12358. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12359. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12360. </if>
  12361. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12362. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12363. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12364. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12365. </if>
  12366. <if test="qcResultShortPageVO.casesEntryId != null ">
  12367. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12368. </if>
  12369. <if test="qcResultShortPageVO.ruleType != null">
  12370. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12371. </if>
  12372. )be
  12373. left join med_check_info mci
  12374. on mci.is_deleted = 'N'
  12375. and mci.check_type = 0
  12376. and be.hospital_id = mci.hospital_id
  12377. and be.behospital_code = mci.behospital_code
  12378. left join med_check_info hm_mci
  12379. on hm_mci.is_deleted = 'N'
  12380. and hm_mci.check_type = 1
  12381. and be.hospital_id = hm_mci.hospital_id
  12382. and be.behospital_code = hm_mci.behospital_code
  12383. left join med_qcresult_info b
  12384. on b.is_deleted = 'N'
  12385. AND be.hospital_id = b.hospital_id
  12386. AND be.behospital_code = b.behospital_code
  12387. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12388. AND b.`level` = #{qcResultPageVO.level}
  12389. </if>
  12390. ) t1
  12391. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12392. AND t1.behospital_code = t2.behospital_code
  12393. AND t2.is_deleted = 'N'
  12394. ) t
  12395. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12396. AND t.hospitalId = qi.hospital_id
  12397. AND t.behospitalCode = qi.behospital_code
  12398. where 1=1
  12399. <if test="qcResultShortPageVO.checkStatus != null">
  12400. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12401. </if>
  12402. <if test="qcResultShortPageVO.mrStatus != null">
  12403. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12404. </if>
  12405. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12406. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12407. </if>
  12408. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12409. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12410. </if>
  12411. <if test="qcResultShortPageVO.chTimeStart != null ">
  12412. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12413. </if>
  12414. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12415. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12416. </if>
  12417. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12418. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12419. </if>
  12420. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12421. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12422. </if>
  12423. GROUP BY
  12424. t.behDeptId,
  12425. t.behDeptName
  12426. )f2
  12427. WHERE
  12428. f1.behDeptId = f2.behDeptId
  12429. AND f1.behDeptName = f2.behDeptName
  12430. </select>
  12431. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  12432. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  12433. SELECT
  12434. f1.behDeptId,
  12435. f1.behDeptName,
  12436. f1.doctorName,
  12437. f1.patName,
  12438. f1.behospitalCode,
  12439. f1.hospitalId,
  12440. f1.behospitalDate,
  12441. f1.leaveHospitalDate,
  12442. f1.score,
  12443. f1.scoreBn,
  12444. f2.avgScore,
  12445. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12446. f1.msg,
  12447. f1.caseName,
  12448. </if>
  12449. f1.checkStatus,
  12450. f1.mrStatus,
  12451. f1.chName,
  12452. f1.mrName,
  12453. f1.chTime,
  12454. f1.mrTime
  12455. FROM
  12456. (SELECT
  12457. t.doctorName AS doctorName,
  12458. t.doctorId,
  12459. t.`name` AS patName,
  12460. t.behospitalCode AS behospitalCode,
  12461. t.behospitalDate AS behospitalDate,
  12462. t.leaveHospitalDate AS leaveHospitalDate,
  12463. qi.score_res AS score,
  12464. t.scoreBn,
  12465. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12466. qd.msg AS msg,
  12467. qc.NAME AS caseName,
  12468. </if>
  12469. t.behDeptId,
  12470. t.behDeptName,
  12471. t.hospitalId,
  12472. t.checkStatus,
  12473. t.mrStatus,
  12474. t.chName,
  12475. t.mrName,
  12476. t.chTime,
  12477. t.mrTime
  12478. FROM
  12479. (SELECT DISTINCT
  12480. t1.hospital_id AS hospitalId,
  12481. t1.behospital_code AS behospitalCode,
  12482. t1.bed_code AS bedCode,
  12483. t1.LEVEL AS LEVEL,
  12484. t1.grade_type AS gradeType,
  12485. t1.score_res AS scoreRes,
  12486. t1.scoreBn,
  12487. t1.NAME AS NAME,
  12488. t1.sex AS sex,
  12489. t1.beh_dept_id AS behDeptId,
  12490. t1.beh_dept_name AS behDeptName,
  12491. t1.doctor_id AS doctorId,
  12492. t1.doctor_name AS doctorName,
  12493. t1.beh_doctor_id AS behDoctorId,
  12494. t1.beh_doctor_name AS behDoctorName,
  12495. t1.director_doctor_id AS directorDoctorId,
  12496. t1.director_doctor_name AS directorDoctorName,
  12497. t1.birthday AS birthday,
  12498. t1.behospital_date AS behospitalDate,
  12499. t1.leave_hospital_date AS leaveHospitalDate,
  12500. t1.placefile_date AS placefileDate,
  12501. t1.gmt_create AS gradeTime,
  12502. t1.diagnose,
  12503. t1.ward_name AS wardName,
  12504. t2.age,
  12505. t1.file_code AS fileCode,
  12506. t1.checkStatus,
  12507. t1.mrStatus,
  12508. t1.chName,
  12509. t1.mrName,
  12510. t1.chTime,
  12511. t1.mrTime
  12512. FROM
  12513. (SELECT
  12514. be.*,
  12515. b.LEVEL,
  12516. b.grade_type,
  12517. b.score_res,
  12518. b.gmt_create,
  12519. ifnull(mci.status,0) AS checkStatus,
  12520. ifnull(hm_mci.status,0) AS mrStatus,
  12521. mci.check_name as chName,
  12522. hm_mci.check_name as mrName,
  12523. mci.gmt_create as chTime,
  12524. hm_mci.gmt_create as mrTime
  12525. FROM
  12526. (
  12527. SELECT DISTINCT
  12528. a.hospital_id,
  12529. a.behospital_code,
  12530. a.bed_code,
  12531. a.file_code,
  12532. c.score_res as scoreBn,
  12533. c.cases_id,
  12534. a.NAME,
  12535. a.sex,
  12536. a.beh_dept_id,
  12537. a.beh_dept_name,
  12538. a.birthday,
  12539. a.behospital_date,
  12540. a.leave_hospital_date,
  12541. a.doctor_id,
  12542. a.doctor_name,
  12543. a.beh_doctor_id,
  12544. a.beh_doctor_name,
  12545. a.director_doctor_id,
  12546. a.director_doctor_name,
  12547. a.diagnose,
  12548. a.placefile_date,
  12549. a.ward_name
  12550. FROM
  12551. med_behospital_info a,
  12552. sys_user_dept b,
  12553. med_qcresult_cases c
  12554. WHERE
  12555. a.is_deleted = 'N'
  12556. AND b.is_deleted = 'N'
  12557. AND c.is_deleted = 'N'
  12558. AND a.hospital_id = b.hospital_id
  12559. AND a.beh_dept_id = b.dept_id
  12560. AND a.hospital_id = c.hospital_id
  12561. AND a.behospital_code = c.behospital_code
  12562. AND a.qc_type_id != 0
  12563. AND c.cases_id = 243
  12564. <if test="qcResultShortPageVO.userId!=null">
  12565. AND b.user_id = #{qcResultShortPageVO.userId}
  12566. </if>
  12567. <if test="qcResultShortPageVO.titleName != null ">
  12568. <if test="qcResultShortPageVO.titleName == '不合格数'">
  12569. AND c.`level`='不合格'
  12570. </if>
  12571. <if test="qcResultShortPageVO.titleName == '合格数'">
  12572. AND c.`level`='合格'
  12573. </if>
  12574. </if>
  12575. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12576. AND a.doctor_name like CONCAT('%', #{qcResultShortPageVO.doctorName}, '%')
  12577. </if>
  12578. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12579. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12580. </if>
  12581. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12582. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12583. </if>
  12584. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12585. <if test="qcResultShortPageVO.startDate != null ">
  12586. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12587. </if>
  12588. <if test="qcResultShortPageVO.endDate != null ">
  12589. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12590. </if>
  12591. </if>
  12592. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12593. <if test="qcResultShortPageVO.startDate != null ">
  12594. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12595. </if>
  12596. <if test="qcResultShortPageVO.endDate != null">
  12597. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12598. </if>
  12599. </if>
  12600. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12601. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12602. </if>
  12603. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12604. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  12605. </if>
  12606. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12607. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12608. </if>
  12609. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12610. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12611. </if>
  12612. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12613. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12614. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12615. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12616. </if>
  12617. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12618. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12619. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12620. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12621. </if>
  12622. )be
  12623. left join med_check_info mci
  12624. on mci.is_deleted = 'N'
  12625. and mci.check_type = 0
  12626. and be.hospital_id = mci.hospital_id
  12627. and be.behospital_code = mci.behospital_code
  12628. left join med_check_info hm_mci
  12629. on hm_mci.is_deleted = 'N'
  12630. and hm_mci.check_type = 1
  12631. and be.hospital_id = hm_mci.hospital_id
  12632. and be.behospital_code = hm_mci.behospital_code
  12633. left join med_qcresult_info b
  12634. on b.is_deleted = 'N'
  12635. AND be.hospital_id = b.hospital_id
  12636. AND be.behospital_code = b.behospital_code
  12637. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12638. AND b.`level` = #{qcResultPageVO.level}
  12639. </if>
  12640. left join qc_cases_entry d
  12641. on d.is_deleted = 'N'
  12642. AND be.cases_id = d.cases_id
  12643. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12644. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12645. </if>
  12646. <if test="qcResultShortPageVO.casesEntryId != null ">
  12647. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12648. </if>
  12649. <if test="qcResultShortPageVO.ruleType != null">
  12650. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12651. </if>
  12652. ) t1
  12653. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12654. AND t1.behospital_code = t2.behospital_code
  12655. AND t2.is_deleted = 'N'
  12656. ) t
  12657. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12658. AND t.hospitalId = qi.hospital_id
  12659. AND t.behospitalCode = qi.behospital_code
  12660. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12661. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  12662. AND t.hospitalId = qd.hospital_id
  12663. AND t.behospitalCode = qd.behospital_code
  12664. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  12665. AND qd.cases_id = qc.id
  12666. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  12667. AND qd.cases_id = qce.cases_id
  12668. AND qd.cases_entry_id = qce.id
  12669. </if>
  12670. where 1=1
  12671. <if test="qcResultShortPageVO.checkStatus != null">
  12672. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12673. </if>
  12674. <if test="qcResultShortPageVO.mrStatus != null">
  12675. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12676. </if>
  12677. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12678. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12679. </if>
  12680. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12681. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12682. </if>
  12683. <if test="qcResultShortPageVO.chTimeStart != null ">
  12684. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12685. </if>
  12686. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12687. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12688. </if>
  12689. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12690. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12691. </if>
  12692. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12693. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12694. </if>
  12695. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12696. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  12697. </if>
  12698. <if test="qcResultShortPageVO.casesEntryId != null ">
  12699. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  12700. </if>
  12701. )f1,
  12702. (SELECT
  12703. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  12704. t.doctorId,
  12705. t.doctorName
  12706. FROM
  12707. (SELECT DISTINCT
  12708. t1.hospital_id AS hospitalId,
  12709. t1.behospital_code AS behospitalCode,
  12710. t1.bed_code AS bedCode,
  12711. t1.LEVEL AS LEVEL,
  12712. t1.grade_type AS gradeType,
  12713. t1.score_res AS scoreRes,
  12714. t1.NAME AS NAME,
  12715. t1.sex AS sex,
  12716. t1.beh_dept_id AS behDeptId,
  12717. t1.beh_dept_name AS behDeptName,
  12718. t1.doctor_id AS doctorId,
  12719. t1.doctor_name AS doctorName,
  12720. t1.beh_doctor_id AS behDoctorId,
  12721. t1.beh_doctor_name AS behDoctorName,
  12722. t1.director_doctor_id AS directorDoctorId,
  12723. t1.director_doctor_name AS directorDoctorName,
  12724. t1.birthday AS birthday,
  12725. t1.behospital_date AS behospitalDate,
  12726. t1.leave_hospital_date AS leaveHospitalDate,
  12727. t1.placefile_date AS placefileDate,
  12728. t1.gmt_create AS gradeTime,
  12729. t1.diagnose,
  12730. t1.ward_name AS wardName,
  12731. t2.age,
  12732. t1.file_code AS fileCode,
  12733. t1.checkStatus,
  12734. t1.mrStatus,
  12735. t1.chName,
  12736. t1.mrName,
  12737. t1.chTime,
  12738. t1.mrTime
  12739. FROM
  12740. (SELECT
  12741. be.*,
  12742. b.grade_type,
  12743. b.score_res,
  12744. b.gmt_create,
  12745. b.LEVEL,
  12746. ifnull(mci.status,0) AS checkStatus,
  12747. ifnull(hm_mci.status,0) AS mrStatus,
  12748. mci.check_name as chName,
  12749. hm_mci.check_name as mrName,
  12750. mci.gmt_create as chTime,
  12751. hm_mci.gmt_create as mrTime
  12752. FROM
  12753. (
  12754. SELECT DISTINCT
  12755. a.hospital_id,
  12756. a.behospital_code,
  12757. a.bed_code,
  12758. a.file_code,
  12759. a.NAME,
  12760. a.sex,
  12761. a.beh_dept_id,
  12762. a.beh_dept_name,
  12763. a.birthday,
  12764. a.behospital_date,
  12765. a.leave_hospital_date,
  12766. a.doctor_id,
  12767. a.doctor_name,
  12768. a.beh_doctor_id,
  12769. a.beh_doctor_name,
  12770. a.director_doctor_id,
  12771. a.director_doctor_name,
  12772. a.diagnose,
  12773. a.placefile_date,
  12774. a.ward_name
  12775. FROM
  12776. med_behospital_info a,
  12777. med_qcresult_detail k,
  12778. sys_user_dept b,
  12779. med_qcresult_cases c,
  12780. qc_cases_entry d
  12781. WHERE
  12782. a.is_deleted = 'N'
  12783. AND b.is_deleted = 'N'
  12784. AND c.is_deleted = 'N'
  12785. AND d.is_deleted = 'N'
  12786. AND a.hospital_id = b.hospital_id
  12787. AND a.hospital_id = c.hospital_id
  12788. AND a.behospital_code = c.behospital_code
  12789. AND a.beh_dept_id = b.dept_id
  12790. AND c.cases_id = d.cases_id
  12791. AND a.hospital_id = k.hospital_id
  12792. AND a.behospital_code = k.behospital_code
  12793. AND c.cases_id = k.cases_id
  12794. AND k.cases_id = d.cases_id
  12795. AND k.cases_entry_id = d.id
  12796. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  12797. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  12798. <!-- AND c.`level`='不合格'-->
  12799. <!-- </if>-->
  12800. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  12801. <!-- AND c.`level`='合格'-->
  12802. <!-- </if>-->
  12803. <!-- </if>-->
  12804. AND a.qc_type_id != 0
  12805. <if test="qcResultShortPageVO.userId!=null">
  12806. AND b.user_id = #{qcResultShortPageVO.userId}
  12807. </if>
  12808. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12809. and a.doctor_name = #{qcResultShortPageVO.doctorName}
  12810. </if>
  12811. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12812. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12813. </if>
  12814. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12815. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12816. </if>
  12817. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12818. <if test="qcResultShortPageVO.startDate != null ">
  12819. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12820. </if>
  12821. <if test="qcResultShortPageVO.endDate != null ">
  12822. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12823. </if>
  12824. </if>
  12825. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12826. <if test="qcResultShortPageVO.startDate != null ">
  12827. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12828. </if>
  12829. <if test="qcResultShortPageVO.endDate != null">
  12830. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12831. </if>
  12832. </if>
  12833. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12834. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12835. </if>
  12836. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12837. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultShortPageVO.deptName}, '%' )
  12838. </if>
  12839. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12840. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12841. </if>
  12842. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12843. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12844. </if>
  12845. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  12846. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  12847. </if>
  12848. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12849. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12850. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12851. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12852. </if>
  12853. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12854. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12855. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12856. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12857. </if>
  12858. <if test="qcResultShortPageVO.casesEntryId != null ">
  12859. AND d.id = #{qcResultShortPageVO.casesEntryId}
  12860. </if>
  12861. <if test="qcResultShortPageVO.ruleType != null">
  12862. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  12863. </if>
  12864. )be
  12865. left join med_check_info mci
  12866. on mci.is_deleted = 'N'
  12867. and mci.check_type = 0
  12868. and be.hospital_id = mci.hospital_id
  12869. and be.behospital_code = mci.behospital_code
  12870. left join med_check_info hm_mci
  12871. on hm_mci.is_deleted = 'N'
  12872. and hm_mci.check_type = 1
  12873. and be.hospital_id = hm_mci.hospital_id
  12874. and be.behospital_code = hm_mci.behospital_code
  12875. left join med_qcresult_info b
  12876. on b.is_deleted = 'N'
  12877. AND be.hospital_id = b.hospital_id
  12878. AND be.behospital_code = b.behospital_code
  12879. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12880. AND b.`level` = #{qcResultPageVO.level}
  12881. </if>
  12882. ) t1
  12883. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12884. AND t1.behospital_code = t2.behospital_code
  12885. AND t2.is_deleted = 'N'
  12886. ) t
  12887. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  12888. AND t.hospitalId = qi.hospital_id
  12889. AND t.behospitalCode = qi.behospital_code
  12890. where 1=1
  12891. <if test="qcResultShortPageVO.checkStatus != null">
  12892. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12893. </if>
  12894. <if test="qcResultShortPageVO.mrStatus != null">
  12895. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12896. </if>
  12897. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12898. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12899. </if>
  12900. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12901. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12902. </if>
  12903. <if test="qcResultShortPageVO.chTimeStart != null ">
  12904. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12905. </if>
  12906. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12907. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12908. </if>
  12909. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12910. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12911. </if>
  12912. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12913. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12914. </if>
  12915. GROUP BY
  12916. t.behDeptId,
  12917. t.behDeptName,
  12918. t.doctorId,
  12919. t.doctorName
  12920. )f2
  12921. WHERE
  12922. f1.doctorId = f2.doctorId
  12923. AND f1.doctorName = f2.doctorName
  12924. </select>
  12925. <!-- 未整改病历缺陷评分详情页导出-->
  12926. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  12927. SELECT
  12928. f1.behDeptId,
  12929. f1.behDeptName,
  12930. f1.doctorName,
  12931. f1.patName,
  12932. f1.behospitalCode,
  12933. f1.hospitalId,
  12934. f1.behospitalDate,
  12935. f1.leaveHospitalDate,
  12936. f1.score,
  12937. f1.scoreBn,
  12938. f2.avgScore,
  12939. f1.msg,
  12940. f1.caseName,
  12941. f1.checkStatus,
  12942. f1.mrStatus,
  12943. f1.chName,
  12944. f1.mrName,
  12945. f1.chTime,
  12946. f1.mrTime
  12947. FROM
  12948. (SELECT
  12949. t.doctorName,
  12950. t.`name` AS patName,
  12951. t.behospitalCode AS behospitalCode,
  12952. t.behospitalDate AS behospitalDate,
  12953. t.leaveHospitalDate AS leaveHospitalDate,
  12954. qi.score_res AS score,
  12955. t.scoreBn,
  12956. qd.msg AS msg,
  12957. qc.NAME AS caseName,
  12958. t.behDeptId,
  12959. t.behDeptName,
  12960. t.hospitalId,
  12961. t.checkStatus,
  12962. t.mrStatus,
  12963. t.chName,
  12964. t.mrName,
  12965. t.chTime,
  12966. t.mrTime
  12967. FROM
  12968. (SELECT DISTINCT
  12969. t1.hospital_id AS hospitalId,
  12970. t1.behospital_code AS behospitalCode,
  12971. t1.bed_code AS bedCode,
  12972. t1.LEVEL AS LEVEL,
  12973. t1.grade_type AS gradeType,
  12974. t1.score_res AS scoreRes,
  12975. t1.scoreBn,
  12976. t1.NAME AS NAME,
  12977. t1.sex AS sex,
  12978. t1.beh_dept_id AS behDeptId,
  12979. t1.beh_dept_name AS behDeptName,
  12980. t1.doctor_id AS doctorId,
  12981. t1.doctor_name AS doctorName,
  12982. t1.beh_doctor_id AS behDoctorId,
  12983. t1.beh_doctor_name AS behDoctorName,
  12984. t1.director_doctor_id AS directorDoctorId,
  12985. t1.director_doctor_name AS directorDoctorName,
  12986. t1.birthday AS birthday,
  12987. t1.behospital_date AS behospitalDate,
  12988. t1.leave_hospital_date AS leaveHospitalDate,
  12989. t1.placefile_date AS placefileDate,
  12990. t1.gmt_create AS gradeTime,
  12991. t1.diagnose,
  12992. t1.ward_name AS wardName,
  12993. t2.age,
  12994. t1.file_code AS fileCode,
  12995. t1.checkStatus,
  12996. t1.mrStatus,
  12997. t1.chName,
  12998. t1.mrName,
  12999. t1.chTime,
  13000. t1.mrTime
  13001. FROM
  13002. (SELECT
  13003. be.*,
  13004. ifnull(mci.status,0) AS checkStatus,
  13005. ifnull(hm_mci.status,0) AS mrStatus,
  13006. mci.check_name as chName,
  13007. e.score_res as scoreBn,
  13008. hm_mci.check_name as mrName,
  13009. mci.gmt_create as chTime,
  13010. hm_mci.gmt_create as mrTime
  13011. FROM
  13012. (
  13013. SELECT DISTINCT
  13014. a.hospital_id,
  13015. a.behospital_code,
  13016. a.bed_code,
  13017. a.file_code,
  13018. b.LEVEL,
  13019. b.grade_type,
  13020. b.score_res,
  13021. a.NAME,
  13022. a.sex,
  13023. a.beh_dept_id,
  13024. a.beh_dept_name,
  13025. a.birthday,
  13026. a.behospital_date,
  13027. a.leave_hospital_date,
  13028. a.doctor_id,
  13029. a.doctor_name,
  13030. a.beh_doctor_id,
  13031. a.beh_doctor_name,
  13032. a.director_doctor_id,
  13033. a.director_doctor_name,
  13034. a.diagnose,
  13035. a.placefile_date,
  13036. a.ward_name,
  13037. b.gmt_create
  13038. FROM
  13039. med_behospital_info a,
  13040. med_qcresult_info b,
  13041. med_qcresult_detail c,
  13042. qc_cases_entry d
  13043. WHERE
  13044. a.is_deleted = 'N'
  13045. AND b.is_deleted = 'N'
  13046. AND c.is_deleted = 'N'
  13047. AND d.is_deleted = 'N'
  13048. AND a.hospital_id = b.hospital_id
  13049. AND a.hospital_id = c.hospital_id
  13050. AND a.behospital_code = b.behospital_code
  13051. AND a.behospital_code = c.behospital_code
  13052. AND c.cases_id = d.cases_id
  13053. AND c.cases_entry_id = d.id
  13054. AND a.qc_type_id != 0
  13055. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13056. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13057. </if>
  13058. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13059. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13060. </if>
  13061. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13062. <if test="qcResultShortPageVO.startDate != null ">
  13063. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13064. </if>
  13065. <if test="qcResultShortPageVO.endDate != null ">
  13066. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13067. </if>
  13068. </if>
  13069. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13070. <if test="qcResultShortPageVO.startDate != null ">
  13071. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13072. </if>
  13073. <if test="qcResultShortPageVO.endDate != null">
  13074. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13075. </if>
  13076. </if>
  13077. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13078. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13079. </if>
  13080. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13081. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13082. </if>
  13083. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13084. AND b.`level` = #{qcResultShortPageVO.level}
  13085. </if>
  13086. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13087. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13088. </if>
  13089. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13090. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13091. </if>
  13092. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13093. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13094. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13095. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13096. </if>
  13097. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13098. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13099. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13100. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13101. </if>
  13102. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13103. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13104. </if>
  13105. <if test="qcResultShortPageVO.casesEntryId != null ">
  13106. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13107. </if>
  13108. <if test="qcResultShortPageVO.isReject != null">
  13109. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13110. </if>
  13111. <if test="qcResultShortPageVO.ruleType != null">
  13112. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13113. </if>
  13114. )be
  13115. left join med_check_info mci
  13116. on mci.is_deleted = 'N'
  13117. and mci.check_type = 0
  13118. and be.hospital_id = mci.hospital_id
  13119. and be.behospital_code = mci.behospital_code
  13120. left join med_check_info hm_mci
  13121. on hm_mci.is_deleted = 'N'
  13122. and hm_mci.check_type = 1
  13123. and be.hospital_id = hm_mci.hospital_id
  13124. and be.behospital_code = hm_mci.behospital_code
  13125. LEFT JOIN med_qcresult_cases e
  13126. on be.behospital_code = e.behospital_code
  13127. and be.hospital_id = e.hospital_id
  13128. AND e.is_deleted = 'N'
  13129. and e.cases_id = 243
  13130. ) t1
  13131. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13132. AND t1.behospital_code = t2.behospital_code
  13133. AND t2.is_deleted = 'N'
  13134. ) t
  13135. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13136. AND t.hospitalId = qi.hospital_id
  13137. AND t.behospitalCode = qi.behospital_code
  13138. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13139. AND t.hospitalId = qd.hospital_id
  13140. AND t.behospitalCode = qd.behospital_code
  13141. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13142. AND qd.cases_id = qc.id
  13143. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13144. AND qd.cases_id = qce.cases_id
  13145. AND qd.cases_entry_id = qce.id
  13146. where 1=1
  13147. <if test="qcResultShortPageVO.checkStatus != null">
  13148. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13149. </if>
  13150. <if test="qcResultShortPageVO.mrStatus != null">
  13151. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13152. </if>
  13153. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13154. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13155. </if>
  13156. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13157. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13158. </if>
  13159. <if test="qcResultShortPageVO.chTimeStart != null ">
  13160. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13161. </if>
  13162. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13163. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13164. </if>
  13165. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13166. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13167. </if>
  13168. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13169. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13170. </if>
  13171. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13172. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13173. </if>
  13174. <if test="qcResultShortPageVO.casesEntryId != null ">
  13175. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13176. </if>
  13177. )f1,
  13178. (SELECT
  13179. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13180. t.behDeptId,
  13181. t.behDeptName
  13182. FROM
  13183. (SELECT DISTINCT
  13184. t1.hospital_id AS hospitalId,
  13185. t1.behospital_code AS behospitalCode,
  13186. t1.bed_code AS bedCode,
  13187. t1.LEVEL AS LEVEL,
  13188. t1.grade_type AS gradeType,
  13189. t1.score_res AS scoreRes,
  13190. t1.NAME AS NAME,
  13191. t1.sex AS sex,
  13192. t1.beh_dept_id AS behDeptId,
  13193. t1.beh_dept_name AS behDeptName,
  13194. t1.doctor_id AS doctorId,
  13195. t1.doctor_name AS doctorName,
  13196. t1.beh_doctor_id AS behDoctorId,
  13197. t1.beh_doctor_name AS behDoctorName,
  13198. t1.director_doctor_id AS directorDoctorId,
  13199. t1.director_doctor_name AS directorDoctorName,
  13200. t1.birthday AS birthday,
  13201. t1.behospital_date AS behospitalDate,
  13202. t1.leave_hospital_date AS leaveHospitalDate,
  13203. t1.placefile_date AS placefileDate,
  13204. t1.gmt_create AS gradeTime,
  13205. t1.diagnose,
  13206. t1.ward_name AS wardName,
  13207. t2.age,
  13208. t1.file_code AS fileCode,
  13209. t1.checkStatus,
  13210. t1.mrStatus,
  13211. t1.chName,
  13212. t1.mrName,
  13213. t1.chTime,
  13214. t1.mrTime
  13215. FROM
  13216. (SELECT
  13217. be.*,
  13218. ifnull(mci.status,0) AS checkStatus,
  13219. ifnull(hm_mci.status,0) AS mrStatus,
  13220. mci.check_name as chName,
  13221. hm_mci.check_name as mrName,
  13222. mci.gmt_create as chTime,
  13223. hm_mci.gmt_create as mrTime
  13224. FROM
  13225. (
  13226. SELECT DISTINCT
  13227. a.hospital_id,
  13228. a.behospital_code,
  13229. a.bed_code,
  13230. a.file_code,
  13231. b.LEVEL,
  13232. b.grade_type,
  13233. b.score_res,
  13234. a.NAME,
  13235. a.sex,
  13236. a.beh_dept_id,
  13237. a.beh_dept_name,
  13238. a.birthday,
  13239. a.behospital_date,
  13240. a.leave_hospital_date,
  13241. a.doctor_id,
  13242. a.doctor_name,
  13243. a.beh_doctor_id,
  13244. a.beh_doctor_name,
  13245. a.director_doctor_id,
  13246. a.director_doctor_name,
  13247. a.diagnose,
  13248. a.placefile_date,
  13249. a.ward_name,
  13250. b.gmt_create
  13251. FROM
  13252. med_behospital_info a,
  13253. med_qcresult_info b,
  13254. med_qcresult_detail c,
  13255. qc_cases_entry d
  13256. WHERE
  13257. a.is_deleted = 'N'
  13258. AND b.is_deleted = 'N'
  13259. AND c.is_deleted = 'N'
  13260. AND d.is_deleted = 'N'
  13261. AND a.hospital_id = b.hospital_id
  13262. AND a.hospital_id = c.hospital_id
  13263. AND a.behospital_code = b.behospital_code
  13264. AND a.behospital_code = c.behospital_code
  13265. AND c.cases_id = d.cases_id
  13266. AND c.cases_entry_id = d.id
  13267. AND a.qc_type_id != 0
  13268. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13269. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13270. </if>
  13271. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13272. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13273. </if>
  13274. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13275. <if test="qcResultShortPageVO.startDate != null ">
  13276. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13277. </if>
  13278. <if test="qcResultShortPageVO.endDate != null ">
  13279. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13280. </if>
  13281. </if>
  13282. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13283. <if test="qcResultShortPageVO.startDate != null ">
  13284. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13285. </if>
  13286. <if test="qcResultShortPageVO.endDate != null">
  13287. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13288. </if>
  13289. </if>
  13290. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13291. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13292. </if>
  13293. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13294. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13295. </if>
  13296. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13297. AND b.`level` = #{qcResultShortPageVO.level}
  13298. </if>
  13299. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13300. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13301. </if>
  13302. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13303. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13304. </if>
  13305. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13306. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13307. </if>
  13308. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13309. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13310. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13311. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13312. </if>
  13313. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13314. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13315. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13316. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13317. </if>
  13318. <if test="qcResultShortPageVO.casesEntryId != null ">
  13319. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13320. </if>
  13321. <if test="qcResultShortPageVO.isReject != null">
  13322. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13323. </if>
  13324. <if test="qcResultShortPageVO.ruleType != null">
  13325. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13326. </if>
  13327. )be
  13328. left join med_check_info mci
  13329. on mci.is_deleted = 'N'
  13330. and mci.check_type = 0
  13331. and be.hospital_id = mci.hospital_id
  13332. and be.behospital_code = mci.behospital_code
  13333. left join med_check_info hm_mci
  13334. on hm_mci.is_deleted = 'N'
  13335. and hm_mci.check_type = 1
  13336. and be.hospital_id = hm_mci.hospital_id
  13337. and be.behospital_code = hm_mci.behospital_code
  13338. ) t1
  13339. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13340. AND t1.behospital_code = t2.behospital_code
  13341. AND t2.is_deleted = 'N'
  13342. ) t
  13343. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13344. AND t.hospitalId = qi.hospital_id
  13345. AND t.behospitalCode = qi.behospital_code
  13346. where 1=1
  13347. <if test="qcResultShortPageVO.checkStatus != null">
  13348. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13349. </if>
  13350. <if test="qcResultShortPageVO.mrStatus != null">
  13351. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13352. </if>
  13353. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13354. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13355. </if>
  13356. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13357. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13358. </if>
  13359. <if test="qcResultShortPageVO.chTimeStart != null ">
  13360. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13361. </if>
  13362. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13363. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13364. </if>
  13365. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13366. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13367. </if>
  13368. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13369. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13370. </if>
  13371. GROUP BY
  13372. t.behDeptId,
  13373. t.behDeptName
  13374. )f2
  13375. WHERE
  13376. f1.behDeptId = f2.behDeptId
  13377. AND f1.behDeptName = f2.behDeptName
  13378. </select>
  13379. <!-- 未整改病历缺陷评分详情页导出-科室-->
  13380. <select id="unModifyExportByDept" resultMap="ExportExcelMapByDept">
  13381. SELECT
  13382. f1.behDeptId,
  13383. f1.behDeptName,
  13384. f1.doctorName,
  13385. f1.patName,
  13386. f1.behospitalCode,
  13387. f1.hospitalId,
  13388. f1.behospitalDate,
  13389. f1.leaveHospitalDate,
  13390. f1.score,
  13391. f1.scoreBn,
  13392. f2.avgScore,
  13393. f1.msg,
  13394. f1.caseName,
  13395. f1.checkStatus,
  13396. f1.mrStatus,
  13397. f1.chName,
  13398. f1.mrName,
  13399. f1.chTime,
  13400. f1.mrTime
  13401. FROM
  13402. (SELECT
  13403. t.doctorName,
  13404. t.doctorId,
  13405. t.`name` AS patName,
  13406. t.behospitalCode AS behospitalCode,
  13407. t.behospitalDate AS behospitalDate,
  13408. t.leaveHospitalDate AS leaveHospitalDate,
  13409. qi.score_res AS score,
  13410. t.scoreBn,
  13411. qd.msg AS msg,
  13412. qc.NAME AS caseName,
  13413. t.behDeptId,
  13414. t.behDeptName,
  13415. t.hospitalId,
  13416. t.checkStatus,
  13417. t.mrStatus,
  13418. t.chName,
  13419. t.mrName,
  13420. t.chTime,
  13421. t.mrTime
  13422. FROM
  13423. (SELECT DISTINCT
  13424. t1.hospital_id AS hospitalId,
  13425. t1.behospital_code AS behospitalCode,
  13426. t1.bed_code AS bedCode,
  13427. t1.LEVEL AS LEVEL,
  13428. t1.grade_type AS gradeType,
  13429. t1.score_res AS scoreRes,
  13430. t1.scoreBn,
  13431. t1.NAME AS NAME,
  13432. t1.sex AS sex,
  13433. t1.beh_dept_id AS behDeptId,
  13434. t1.beh_dept_name AS behDeptName,
  13435. t1.doctor_id AS doctorId,
  13436. t1.doctor_name AS doctorName,
  13437. t1.beh_doctor_id AS behDoctorId,
  13438. t1.beh_doctor_name AS behDoctorName,
  13439. t1.director_doctor_id AS directorDoctorId,
  13440. t1.director_doctor_name AS directorDoctorName,
  13441. t1.birthday AS birthday,
  13442. t1.behospital_date AS behospitalDate,
  13443. t1.leave_hospital_date AS leaveHospitalDate,
  13444. t1.placefile_date AS placefileDate,
  13445. t1.gmt_create AS gradeTime,
  13446. t1.diagnose,
  13447. t1.ward_name AS wardName,
  13448. t2.age,
  13449. t1.file_code AS fileCode,
  13450. t1.checkStatus,
  13451. t1.mrStatus,
  13452. t1.chName,
  13453. t1.mrName,
  13454. t1.chTime,
  13455. t1.mrTime
  13456. FROM
  13457. (SELECT
  13458. be.*,
  13459. ifnull(mci.status,0) AS checkStatus,
  13460. ifnull(hm_mci.status,0) AS mrStatus,
  13461. mci.check_name as chName,
  13462. e.score_res as scoreBn,
  13463. hm_mci.check_name as mrName,
  13464. mci.gmt_create as chTime,
  13465. hm_mci.gmt_create as mrTime
  13466. FROM
  13467. (
  13468. SELECT DISTINCT
  13469. a.hospital_id,
  13470. a.behospital_code,
  13471. a.bed_code,
  13472. a.file_code,
  13473. b.LEVEL,
  13474. b.grade_type,
  13475. b.score_res,
  13476. a.NAME,
  13477. a.sex,
  13478. a.beh_dept_id,
  13479. a.beh_dept_name,
  13480. a.birthday,
  13481. a.behospital_date,
  13482. a.leave_hospital_date,
  13483. a.doctor_id,
  13484. a.doctor_name,
  13485. a.beh_doctor_id,
  13486. a.beh_doctor_name,
  13487. a.director_doctor_id,
  13488. a.director_doctor_name,
  13489. a.diagnose,
  13490. a.placefile_date,
  13491. a.ward_name,
  13492. b.gmt_create
  13493. FROM
  13494. med_behospital_info a,
  13495. med_qcresult_info b,
  13496. med_qcresult_detail c,
  13497. qc_cases_entry d,
  13498. sys_user_dept f
  13499. WHERE
  13500. a.is_deleted = 'N'
  13501. AND b.is_deleted = 'N'
  13502. AND c.is_deleted = 'N'
  13503. AND d.is_deleted = 'N'
  13504. AND f.is_deleted = 'N'
  13505. AND a.hospital_id = b.hospital_id
  13506. AND a.hospital_id = c.hospital_id
  13507. AND a.hospital_id = f.hospital_id
  13508. AND a.behospital_code = b.behospital_code
  13509. AND a.behospital_code = c.behospital_code
  13510. AND c.cases_id = d.cases_id
  13511. AND c.cases_entry_id = d.id
  13512. AND a.beh_dept_id = f.dept_id
  13513. AND a.qc_type_id != 0
  13514. <if test="qcResultShortPageVO.userId!=null">
  13515. AND f.user_id = #{qcResultShortPageVO.userId}
  13516. </if>
  13517. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13518. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13519. </if>
  13520. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13521. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13522. </if>
  13523. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13524. <if test="qcResultShortPageVO.startDate != null ">
  13525. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13526. </if>
  13527. <if test="qcResultShortPageVO.endDate != null ">
  13528. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13529. </if>
  13530. </if>
  13531. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13532. <if test="qcResultShortPageVO.startDate != null ">
  13533. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13534. </if>
  13535. <if test="qcResultShortPageVO.endDate != null">
  13536. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13537. </if>
  13538. </if>
  13539. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13540. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13541. </if>
  13542. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13543. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13544. </if>
  13545. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13546. AND b.`level` = #{qcResultShortPageVO.level}
  13547. </if>
  13548. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13549. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13550. </if>
  13551. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13552. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13553. </if>
  13554. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13555. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13556. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13557. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13558. </if>
  13559. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13560. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13561. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13562. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13563. </if>
  13564. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13565. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13566. </if>
  13567. <if test="qcResultShortPageVO.casesEntryId != null ">
  13568. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13569. </if>
  13570. <if test="qcResultShortPageVO.isReject != null">
  13571. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13572. </if>
  13573. <if test="qcResultShortPageVO.ruleType != null">
  13574. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13575. </if>
  13576. )be
  13577. left join med_check_info mci
  13578. on mci.is_deleted = 'N'
  13579. and mci.check_type = 0
  13580. and be.hospital_id = mci.hospital_id
  13581. and be.behospital_code = mci.behospital_code
  13582. left join med_check_info hm_mci
  13583. on hm_mci.is_deleted = 'N'
  13584. and hm_mci.check_type = 1
  13585. and be.hospital_id = hm_mci.hospital_id
  13586. and be.behospital_code = hm_mci.behospital_code
  13587. LEFT JOIN med_qcresult_cases e
  13588. on be.behospital_code = e.behospital_code
  13589. and be.hospital_id = e.hospital_id
  13590. AND e.is_deleted = 'N'
  13591. and e.cases_id = 243
  13592. ) t1
  13593. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13594. AND t1.behospital_code = t2.behospital_code
  13595. AND t2.is_deleted = 'N'
  13596. ) t
  13597. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13598. AND t.hospitalId = qi.hospital_id
  13599. AND t.behospitalCode = qi.behospital_code
  13600. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13601. AND t.hospitalId = qd.hospital_id
  13602. AND t.behospitalCode = qd.behospital_code
  13603. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13604. AND qd.cases_id = qc.id
  13605. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  13606. AND qd.cases_id = qce.cases_id
  13607. AND qd.cases_entry_id = qce.id
  13608. where 1=1
  13609. <if test="qcResultShortPageVO.checkStatus != null">
  13610. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13611. </if>
  13612. <if test="qcResultShortPageVO.mrStatus != null">
  13613. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13614. </if>
  13615. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13616. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13617. </if>
  13618. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13619. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13620. </if>
  13621. <if test="qcResultShortPageVO.chTimeStart != null ">
  13622. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13623. </if>
  13624. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13625. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13626. </if>
  13627. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13628. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13629. </if>
  13630. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13631. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13632. </if>
  13633. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13634. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  13635. </if>
  13636. <if test="qcResultShortPageVO.casesEntryId != null ">
  13637. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  13638. </if>
  13639. )f1,
  13640. (SELECT
  13641. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13642. t.behDeptId,
  13643. t.behDeptName,
  13644. t.doctorId,
  13645. t.doctorName
  13646. FROM
  13647. (SELECT DISTINCT
  13648. t1.hospital_id AS hospitalId,
  13649. t1.behospital_code AS behospitalCode,
  13650. t1.bed_code AS bedCode,
  13651. t1.LEVEL AS LEVEL,
  13652. t1.grade_type AS gradeType,
  13653. t1.score_res AS scoreRes,
  13654. t1.NAME AS NAME,
  13655. t1.sex AS sex,
  13656. t1.beh_dept_id AS behDeptId,
  13657. t1.beh_dept_name AS behDeptName,
  13658. t1.doctor_id AS doctorId,
  13659. t1.doctor_name AS doctorName,
  13660. t1.beh_doctor_id AS behDoctorId,
  13661. t1.beh_doctor_name AS behDoctorName,
  13662. t1.director_doctor_id AS directorDoctorId,
  13663. t1.director_doctor_name AS directorDoctorName,
  13664. t1.birthday AS birthday,
  13665. t1.behospital_date AS behospitalDate,
  13666. t1.leave_hospital_date AS leaveHospitalDate,
  13667. t1.placefile_date AS placefileDate,
  13668. t1.gmt_create AS gradeTime,
  13669. t1.diagnose,
  13670. t1.ward_name AS wardName,
  13671. t2.age,
  13672. t1.file_code AS fileCode,
  13673. t1.checkStatus,
  13674. t1.mrStatus,
  13675. t1.chName,
  13676. t1.mrName,
  13677. t1.chTime,
  13678. t1.mrTime
  13679. FROM
  13680. (SELECT
  13681. be.*,
  13682. ifnull(mci.status,0) AS checkStatus,
  13683. ifnull(hm_mci.status,0) AS mrStatus,
  13684. mci.check_name as chName,
  13685. hm_mci.check_name as mrName,
  13686. mci.gmt_create as chTime,
  13687. hm_mci.gmt_create as mrTime
  13688. FROM
  13689. (
  13690. SELECT DISTINCT
  13691. a.hospital_id,
  13692. a.behospital_code,
  13693. a.bed_code,
  13694. a.file_code,
  13695. b.LEVEL,
  13696. b.grade_type,
  13697. b.score_res,
  13698. a.NAME,
  13699. a.sex,
  13700. a.beh_dept_id,
  13701. a.beh_dept_name,
  13702. a.birthday,
  13703. a.behospital_date,
  13704. a.leave_hospital_date,
  13705. a.doctor_id,
  13706. a.doctor_name,
  13707. a.beh_doctor_id,
  13708. a.beh_doctor_name,
  13709. a.director_doctor_id,
  13710. a.director_doctor_name,
  13711. a.diagnose,
  13712. a.placefile_date,
  13713. a.ward_name,
  13714. b.gmt_create
  13715. FROM
  13716. med_behospital_info a,
  13717. med_qcresult_info b,
  13718. med_qcresult_detail c,
  13719. qc_cases_entry d,
  13720. sys_user_dept f
  13721. WHERE
  13722. a.is_deleted = 'N'
  13723. AND b.is_deleted = 'N'
  13724. AND c.is_deleted = 'N'
  13725. AND d.is_deleted = 'N'
  13726. AND f.is_deleted = 'N'
  13727. AND a.hospital_id = b.hospital_id
  13728. AND a.hospital_id = c.hospital_id
  13729. AND a.hospital_id = f.hospital_id
  13730. AND a.behospital_code = b.behospital_code
  13731. AND a.behospital_code = c.behospital_code
  13732. AND c.cases_id = d.cases_id
  13733. AND c.cases_entry_id = d.id
  13734. AND a.beh_dept_id = f.dept_id
  13735. AND a.qc_type_id != 0
  13736. <if test="qcResultShortPageVO.userId!=null">
  13737. AND f.user_id = #{qcResultShortPageVO.userId}
  13738. </if>
  13739. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13740. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13741. </if>
  13742. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13743. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13744. </if>
  13745. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13746. <if test="qcResultShortPageVO.startDate != null ">
  13747. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13748. </if>
  13749. <if test="qcResultShortPageVO.endDate != null ">
  13750. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13751. </if>
  13752. </if>
  13753. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13754. <if test="qcResultShortPageVO.startDate != null ">
  13755. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13756. </if>
  13757. <if test="qcResultShortPageVO.endDate != null">
  13758. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13759. </if>
  13760. </if>
  13761. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  13762. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  13763. </if>
  13764. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13765. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13766. </if>
  13767. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13768. AND b.`level` = #{qcResultShortPageVO.level}
  13769. </if>
  13770. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13771. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13772. </if>
  13773. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13774. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13775. </if>
  13776. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  13777. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  13778. </if>
  13779. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13780. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13781. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13782. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13783. </if>
  13784. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13785. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13786. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13787. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13788. </if>
  13789. <if test="qcResultShortPageVO.casesEntryId != null ">
  13790. AND d.id = #{qcResultShortPageVO.casesEntryId}
  13791. </if>
  13792. <if test="qcResultShortPageVO.isReject != null">
  13793. AND c.is_reject = #{qcResultShortPageVO.isReject}
  13794. </if>
  13795. <if test="qcResultShortPageVO.ruleType != null">
  13796. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  13797. </if>
  13798. )be
  13799. left join med_check_info mci
  13800. on mci.is_deleted = 'N'
  13801. and mci.check_type = 0
  13802. and be.hospital_id = mci.hospital_id
  13803. and be.behospital_code = mci.behospital_code
  13804. left join med_check_info hm_mci
  13805. on hm_mci.is_deleted = 'N'
  13806. and hm_mci.check_type = 1
  13807. and be.hospital_id = hm_mci.hospital_id
  13808. and be.behospital_code = hm_mci.behospital_code
  13809. ) t1
  13810. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13811. AND t1.behospital_code = t2.behospital_code
  13812. AND t2.is_deleted = 'N'
  13813. ) t
  13814. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13815. AND t.hospitalId = qi.hospital_id
  13816. AND t.behospitalCode = qi.behospital_code
  13817. where 1=1
  13818. <if test="qcResultShortPageVO.checkStatus != null">
  13819. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13820. </if>
  13821. <if test="qcResultShortPageVO.mrStatus != null">
  13822. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13823. </if>
  13824. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13825. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13826. </if>
  13827. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13828. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13829. </if>
  13830. <if test="qcResultShortPageVO.chTimeStart != null ">
  13831. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13832. </if>
  13833. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13834. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13835. </if>
  13836. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13837. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13838. </if>
  13839. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13840. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13841. </if>
  13842. GROUP BY
  13843. t.doctorId,
  13844. t.doctorName
  13845. )f2
  13846. WHERE
  13847. f1.doctorId = f2.doctorId
  13848. AND f1.doctorName = f2.doctorName
  13849. </select>
  13850. <!-- 31天再入院详情页-->
  13851. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  13852. SELECT
  13853. t.fileCode,
  13854. t.diagnose,
  13855. t.NAME,
  13856. t.sex,
  13857. t.hospitalId,
  13858. t.behDeptId,
  13859. t.behDeptName,
  13860. t.behospitalCode,
  13861. t.behospitalDate,
  13862. t.leaveHospitalDate,
  13863. t.lastBehDeptId,
  13864. t.lastBehDeptName,
  13865. t.lastBehospitalCode,
  13866. t.lastBehospitalDate,
  13867. t.lastLeaveHospitalDate,
  13868. t.diffDays,
  13869. mqi.score_res AS scoreRes,
  13870. mqi.LEVEL AS LEVEL,
  13871. mqi_last.score_res AS lastScoreRes,
  13872. mqi_last.LEVEL AS lastLevel,
  13873. mhp.total_fee AS totleFee,
  13874. mhp.behospital_day_num AS behospitalDayNum,
  13875. mhp.again_behospital_plan AS againBehospitalPlan,
  13876. IF(mhp.age is null, null,CONCAT( ifnull(mhp.age,'') ,ifnull(mhp.age_unit,'') ))as age,
  13877. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  13878. IF(mhp_last.age is null, null,CONCAT( ifnull(mhp_last.age,'') ,ifnull(mhp_last.age_unit,'') ))as lastAge,
  13879. mhp_last.total_fee AS lastTotleFee,
  13880. mhp_last.behospital_day_num AS lastBehospitalDayNum
  13881. FROM
  13882. (
  13883. SELECT
  13884. be.fileCode,
  13885. be.diagnose,
  13886. be.NAME,
  13887. be.sex,
  13888. be.hospitalId,
  13889. be.behDeptId,
  13890. be.behDeptName,
  13891. be.behospitalCode,
  13892. be.behospitalDate,
  13893. be.leaveHospitalDate,
  13894. be.lastBehDeptId,
  13895. be.lastBehDeptName,
  13896. be.lastBehospitalCode,
  13897. be.lastBehospitalDate,
  13898. be.lastLeaveHospitalDate,
  13899. be.diffDays
  13900. FROM
  13901. (
  13902. SELECT
  13903. r1.file_code AS fileCode,
  13904. r1.diagnose,
  13905. r1.NAME,
  13906. r1.sex,
  13907. r1.hospital_id AS hospitalId,
  13908. r1.beh_dept_id AS behDeptId,
  13909. r1.beh_dept_name AS behDeptName,
  13910. r1.behospital_code AS behospitalCode,
  13911. r1.behospital_date AS behospitalDate,
  13912. r1.leave_hospital_date AS leaveHospitalDate,
  13913. r2.beh_dept_id AS lastBehDeptId,
  13914. r2.beh_dept_name AS lastBehDeptName,
  13915. r2.behospital_code AS lastBehospitalCode,
  13916. r2.behospital_date AS lastBehospitalDate,
  13917. r2.leave_hospital_date AS lastLeaveHospitalDate,
  13918. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  13919. FROM
  13920. (
  13921. SELECT
  13922. ( @rownum := @rownum + 1 ) AS rownum,
  13923. t1.file_code,
  13924. t1.diagnose,
  13925. t1.NAME,
  13926. t1.sex,
  13927. t1.hospital_id,
  13928. t1.beh_dept_id,
  13929. t1.beh_dept_name,
  13930. t1.behospital_code,
  13931. t1.behospital_date,
  13932. t1.leave_hospital_date
  13933. FROM
  13934. (
  13935. SELECT
  13936. tt1.file_code,
  13937. tt1.diagnose,
  13938. tt2.NAME,
  13939. tt2.sex,
  13940. tt2.hospital_id,
  13941. tt2.beh_dept_id,
  13942. tt2.beh_dept_name,
  13943. tt2.behospital_code,
  13944. tt2.behospital_date,
  13945. tt2.leave_hospital_date
  13946. FROM
  13947. (
  13948. SELECT
  13949. a.file_code,
  13950. a.diagnose
  13951. FROM
  13952. med_behospital_info a
  13953. WHERE
  13954. a.is_deleted = 'N'
  13955. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  13956. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  13957. </if>
  13958. AND a.qc_type_id != 0
  13959. AND IFNULL( a.diagnose, '' )!= ''
  13960. AND IFNULL( a.file_code, '' )!= ''
  13961. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  13962. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  13963. </if>
  13964. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  13965. <if test="reBeHosPageVO.startDate != null ">
  13966. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  13967. </if>
  13968. <if test="reBeHosPageVO.endDate != null ">
  13969. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  13970. </if>
  13971. </if>
  13972. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  13973. <if test="reBeHosPageVO.startDate != null ">
  13974. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  13975. </if>
  13976. <if test="reBeHosPageVO.endDate != null">
  13977. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  13978. </if>
  13979. </if>
  13980. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  13981. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  13982. </if>
  13983. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  13984. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  13985. </if>
  13986. GROUP BY
  13987. a.file_code,
  13988. a.diagnose
  13989. HAVING
  13990. count(*)> 1
  13991. ) tt1,
  13992. med_behospital_info tt2
  13993. WHERE
  13994. tt2.is_deleted = 'N'
  13995. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  13996. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  13997. </if>
  13998. AND tt2.qc_type_id != 0
  13999. AND tt1.file_code = tt2.file_code
  14000. AND tt1.diagnose = tt2.diagnose
  14001. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14002. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14003. </if>
  14004. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14005. <if test="reBeHosPageVO.startDate != null ">
  14006. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14007. </if>
  14008. <if test="reBeHosPageVO.endDate != null ">
  14009. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14010. </if>
  14011. </if>
  14012. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14013. <if test="reBeHosPageVO.startDate != null ">
  14014. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14015. </if>
  14016. <if test="reBeHosPageVO.endDate != null">
  14017. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14018. </if>
  14019. </if>
  14020. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14021. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14022. </if>
  14023. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14024. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14025. </if>
  14026. ORDER BY
  14027. tt1.file_code,
  14028. tt1.diagnose,
  14029. tt2.behospital_date DESC
  14030. ) t1,
  14031. ( SELECT @rownum := 0 ) r
  14032. ) r1
  14033. LEFT JOIN (
  14034. SELECT
  14035. ( @INDEX := @INDEX + 1 ) AS rownum,
  14036. t1.file_code,
  14037. t1.diagnose,
  14038. t1.NAME,
  14039. t1.sex,
  14040. t1.hospital_id,
  14041. t1.beh_dept_id,
  14042. t1.beh_dept_name,
  14043. t1.behospital_code,
  14044. t1.behospital_date,
  14045. t1.leave_hospital_date
  14046. FROM
  14047. (
  14048. SELECT
  14049. tt1.file_code,
  14050. tt1.diagnose,
  14051. tt2.NAME,
  14052. tt2.sex,
  14053. tt2.hospital_id,
  14054. tt2.beh_dept_id,
  14055. tt2.beh_dept_name,
  14056. tt2.behospital_code,
  14057. tt2.behospital_date,
  14058. tt2.leave_hospital_date
  14059. FROM
  14060. (
  14061. SELECT
  14062. a.file_code,
  14063. a.diagnose
  14064. FROM
  14065. med_behospital_info a
  14066. WHERE
  14067. a.is_deleted = 'N'
  14068. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14069. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14070. </if>
  14071. AND a.qc_type_id != 0
  14072. AND IFNULL( a.diagnose, '' )!= ''
  14073. AND IFNULL( a.file_code, '' )!= ''
  14074. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14075. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14076. </if>
  14077. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14078. <if test="reBeHosPageVO.startDate != null ">
  14079. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14080. </if>
  14081. <if test="reBeHosPageVO.endDate != null ">
  14082. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14083. </if>
  14084. </if>
  14085. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14086. <if test="reBeHosPageVO.startDate != null ">
  14087. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14088. </if>
  14089. <if test="reBeHosPageVO.endDate != null">
  14090. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14091. </if>
  14092. </if>
  14093. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14094. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14095. </if>
  14096. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14097. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14098. </if>
  14099. GROUP BY
  14100. a.file_code,
  14101. a.diagnose
  14102. HAVING
  14103. count(*)> 1
  14104. ) tt1,
  14105. med_behospital_info tt2
  14106. WHERE
  14107. tt2.is_deleted = 'N'
  14108. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14109. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14110. </if>
  14111. AND tt2.qc_type_id != 0
  14112. AND tt1.file_code = tt2.file_code
  14113. AND tt1.diagnose = tt2.diagnose
  14114. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14115. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14116. </if>
  14117. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14118. <if test="reBeHosPageVO.startDate != null ">
  14119. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14120. </if>
  14121. <if test="reBeHosPageVO.endDate != null ">
  14122. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14123. </if>
  14124. </if>
  14125. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14126. <if test="reBeHosPageVO.startDate != null ">
  14127. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14128. </if>
  14129. <if test="reBeHosPageVO.endDate != null">
  14130. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14131. </if>
  14132. </if>
  14133. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14134. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14135. </if>
  14136. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14137. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14138. </if>
  14139. ORDER BY
  14140. tt1.file_code,
  14141. tt1.diagnose,
  14142. tt2.behospital_date DESC
  14143. ) t1,(
  14144. SELECT
  14145. @INDEX := 0
  14146. ) r
  14147. ) r2 ON r1.file_code = r2.file_code
  14148. AND r1.rownum = r2.rownum - 1
  14149. ) be
  14150. WHERE
  14151. be.diffDays IS NOT NULL
  14152. AND be.diffDays BETWEEN 0
  14153. AND 31
  14154. ) t
  14155. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14156. AND t.hospitalId = mqi.hospital_id
  14157. AND t.behospitalCode = mqi.behospital_code
  14158. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14159. AND t.hospitalId = mqi_last.hospital_id
  14160. AND t.lastBehospitalCode = mqi_last.behospital_code
  14161. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14162. AND t.hospitalId = mhp.hospital_id
  14163. AND t.behospitalCode = mhp.behospital_code
  14164. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14165. AND t.hospitalId = mhp_last.hospital_id
  14166. AND t.lastBehospitalCode = mhp_last.behospital_code
  14167. </select>
  14168. <!-- 31天再入院详情页-科室-->
  14169. <select id="reHos31DaysPageByDept" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  14170. SELECT
  14171. t.fileCode,
  14172. t.diagnose,
  14173. t.NAME,
  14174. t.sex,
  14175. t.hospitalId,
  14176. t.behDeptId,
  14177. t.behDeptName,
  14178. t.doctorId,
  14179. t.doctorName,
  14180. t.behospitalCode,
  14181. t.behospitalDate,
  14182. t.leaveHospitalDate,
  14183. t.lastBehDeptId,
  14184. t.lastBehDeptName,
  14185. t.lastDoctorName,
  14186. t.lastBehospitalCode,
  14187. t.lastBehospitalDate,
  14188. t.lastLeaveHospitalDate,
  14189. t.diffDays,
  14190. mqi.score_res AS scoreRes,
  14191. mqi.LEVEL AS LEVEL,
  14192. mqi_last.score_res AS lastScoreRes,
  14193. mqi_last.LEVEL AS lastLevel,
  14194. mhp.total_fee AS totleFee,
  14195. mhp.behospital_day_num AS behospitalDayNum,
  14196. mhp_last.total_fee AS lastTotleFee,
  14197. mhp_last.behospital_day_num AS lastBehospitalDayNum
  14198. FROM
  14199. (
  14200. SELECT
  14201. be.fileCode,
  14202. be.diagnose,
  14203. be.NAME,
  14204. be.sex,
  14205. be.hospitalId,
  14206. be.behDeptId,
  14207. be.behDeptName,
  14208. be.doctorId,
  14209. be.doctorName,
  14210. be.behospitalCode,
  14211. be.behospitalDate,
  14212. be.leaveHospitalDate,
  14213. be.lastBehDeptId,
  14214. be.lastBehDeptName,
  14215. be.lastDoctorId,
  14216. be.lastDoctorName,
  14217. be.lastBehospitalCode,
  14218. be.lastBehospitalDate,
  14219. be.lastLeaveHospitalDate,
  14220. be.diffDays
  14221. FROM
  14222. (
  14223. SELECT
  14224. r1.file_code AS fileCode,
  14225. r1.diagnose,
  14226. r1.NAME,
  14227. r1.sex,
  14228. r1.hospital_id AS hospitalId,
  14229. r1.beh_dept_id AS behDeptId,
  14230. r1.beh_dept_name AS behDeptName,
  14231. r1.doctor_id as doctorId,
  14232. r1.doctor_name as doctorName,
  14233. r1.behospital_code AS behospitalCode,
  14234. r1.behospital_date AS behospitalDate,
  14235. r1.leave_hospital_date AS leaveHospitalDate,
  14236. r2.beh_dept_id AS lastBehDeptId,
  14237. r2.beh_dept_name AS lastBehDeptName,
  14238. r2.behospital_code AS lastBehospitalCode,
  14239. r2.behospital_date AS lastBehospitalDate,
  14240. r2.doctor_id as lastDoctorId,
  14241. r2.doctor_name as lastDoctorName,
  14242. r2.leave_hospital_date AS lastLeaveHospitalDate,
  14243. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  14244. FROM
  14245. (
  14246. SELECT
  14247. ( @rownum := @rownum + 1 ) AS rownum,
  14248. t1.file_code,
  14249. t1.diagnose,
  14250. t1.NAME,
  14251. t1.sex,
  14252. t1.doctor_id,
  14253. t1.doctor_name,
  14254. t1.hospital_id,
  14255. t1.beh_dept_id,
  14256. t1.beh_dept_name,
  14257. t1.behospital_code,
  14258. t1.behospital_date,
  14259. t1.leave_hospital_date
  14260. FROM
  14261. (
  14262. SELECT
  14263. tt1.file_code,
  14264. tt1.diagnose,
  14265. tt2.doctor_id,
  14266. tt2.doctor_name,
  14267. tt2.NAME,
  14268. tt2.sex,
  14269. tt2.hospital_id,
  14270. tt2.beh_dept_id,
  14271. tt2.beh_dept_name,
  14272. tt2.behospital_code,
  14273. tt2.behospital_date,
  14274. tt2.leave_hospital_date
  14275. FROM
  14276. (
  14277. SELECT
  14278. a.file_code,
  14279. a.diagnose,
  14280. a.doctor_id,
  14281. a.doctor_name
  14282. FROM
  14283. med_behospital_info a,
  14284. sys_user_dept c
  14285. WHERE
  14286. a.is_deleted = 'N'
  14287. AND c.is_deleted = 'N'
  14288. AND a.hospital_id = c.hospital_id
  14289. AND a.beh_dept_id = c.dept_id
  14290. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14291. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14292. </if>
  14293. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14294. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14295. </if>
  14296. <if test="reBeHosPageVO.userId!=null">
  14297. AND c.user_id = #{reBeHosPageVO.userId}
  14298. </if>
  14299. AND a.qc_type_id != 0
  14300. AND IFNULL( a.diagnose, '' )!= ''
  14301. AND IFNULL( a.file_code, '' )!= ''
  14302. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14303. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14304. </if>
  14305. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14306. <if test="reBeHosPageVO.startDate != null ">
  14307. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14308. </if>
  14309. <if test="reBeHosPageVO.endDate != null ">
  14310. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14311. </if>
  14312. </if>
  14313. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14314. <if test="reBeHosPageVO.startDate != null ">
  14315. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14316. </if>
  14317. <if test="reBeHosPageVO.endDate != null">
  14318. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14319. </if>
  14320. </if>
  14321. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14322. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14323. </if>
  14324. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14325. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14326. </if>
  14327. GROUP BY
  14328. a.file_code,
  14329. a.diagnose
  14330. HAVING
  14331. count(*)> 1
  14332. ) tt1,
  14333. med_behospital_info tt2
  14334. WHERE
  14335. tt2.is_deleted = 'N'
  14336. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14337. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14338. </if>
  14339. AND tt2.qc_type_id != 0
  14340. AND tt1.file_code = tt2.file_code
  14341. AND tt1.diagnose = tt2.diagnose
  14342. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14343. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14344. </if>
  14345. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14346. <if test="reBeHosPageVO.startDate != null ">
  14347. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14348. </if>
  14349. <if test="reBeHosPageVO.endDate != null ">
  14350. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14351. </if>
  14352. </if>
  14353. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14354. <if test="reBeHosPageVO.startDate != null ">
  14355. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14356. </if>
  14357. <if test="reBeHosPageVO.endDate != null">
  14358. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14359. </if>
  14360. </if>
  14361. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14362. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14363. </if>
  14364. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14365. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14366. </if>
  14367. ORDER BY
  14368. tt1.file_code,
  14369. tt1.diagnose,
  14370. tt2.behospital_date DESC
  14371. ) t1,
  14372. ( SELECT @rownum := 0 ) r
  14373. ) r1
  14374. LEFT JOIN (
  14375. SELECT
  14376. ( @INDEX := @INDEX + 1 ) AS rownum,
  14377. t1.file_code,
  14378. t1.diagnose,
  14379. t1.NAME,
  14380. t1.sex,
  14381. t1.hospital_id,
  14382. t1.beh_dept_id,
  14383. t1.beh_dept_name,
  14384. t1.doctor_id,
  14385. t1.doctor_name,
  14386. t1.behospital_code,
  14387. t1.behospital_date,
  14388. t1.leave_hospital_date
  14389. FROM
  14390. (
  14391. SELECT
  14392. tt1.file_code,
  14393. tt1.diagnose,
  14394. tt2.doctor_id,
  14395. tt2.doctor_name,
  14396. tt2.NAME,
  14397. tt2.sex,
  14398. tt2.hospital_id,
  14399. tt2.beh_dept_id,
  14400. tt2.beh_dept_name,
  14401. tt2.behospital_code,
  14402. tt2.behospital_date,
  14403. tt2.leave_hospital_date
  14404. FROM
  14405. (
  14406. SELECT
  14407. a.file_code,
  14408. a.diagnose,
  14409. a.doctor_id ,
  14410. a.doctor_name
  14411. FROM
  14412. med_behospital_info a,
  14413. sys_user_dept c
  14414. WHERE
  14415. a.is_deleted = 'N'
  14416. AND c.is_deleted = 'N'
  14417. AND a.hospital_id = c.hospital_id
  14418. AND a.beh_dept_id = c.dept_id
  14419. <if test="reBeHosPageVO.deptName != null and reBeHosPageVO.deptName != ''">
  14420. and a.beh_dept_name = #{reBeHosPageVO.deptName}
  14421. </if>
  14422. <if test="reBeHosPageVO.userId!=null">
  14423. AND c.user_id = #{reBeHosPageVO.userId}
  14424. </if>
  14425. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14426. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  14427. </if>
  14428. AND a.qc_type_id != 0
  14429. AND IFNULL( a.diagnose, '' )!= ''
  14430. AND IFNULL( a.file_code, '' )!= ''
  14431. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14432. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  14433. </if>
  14434. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14435. <if test="reBeHosPageVO.startDate != null ">
  14436. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14437. </if>
  14438. <if test="reBeHosPageVO.endDate != null ">
  14439. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14440. </if>
  14441. </if>
  14442. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14443. <if test="reBeHosPageVO.startDate != null ">
  14444. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14445. </if>
  14446. <if test="reBeHosPageVO.endDate != null">
  14447. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14448. </if>
  14449. </if>
  14450. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14451. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14452. </if>
  14453. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14454. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  14455. </if>
  14456. GROUP BY
  14457. a.file_code,
  14458. a.diagnose
  14459. HAVING
  14460. count(*)> 1
  14461. ) tt1,
  14462. med_behospital_info tt2
  14463. WHERE
  14464. tt2.is_deleted = 'N'
  14465. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  14466. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  14467. </if>
  14468. AND tt2.qc_type_id != 0
  14469. AND tt1.file_code = tt2.file_code
  14470. AND tt1.diagnose = tt2.diagnose
  14471. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  14472. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  14473. </if>
  14474. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  14475. <if test="reBeHosPageVO.startDate != null ">
  14476. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  14477. </if>
  14478. <if test="reBeHosPageVO.endDate != null ">
  14479. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  14480. </if>
  14481. </if>
  14482. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  14483. <if test="reBeHosPageVO.startDate != null ">
  14484. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  14485. </if>
  14486. <if test="reBeHosPageVO.endDate != null">
  14487. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  14488. </if>
  14489. </if>
  14490. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  14491. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  14492. </if>
  14493. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  14494. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  14495. </if>
  14496. ORDER BY
  14497. tt1.file_code,
  14498. tt1.diagnose,
  14499. tt2.behospital_date DESC
  14500. ) t1,(
  14501. SELECT
  14502. @INDEX := 0
  14503. ) r
  14504. ) r2 ON r1.file_code = r2.file_code
  14505. AND r1.rownum = r2.rownum - 1
  14506. ) be
  14507. WHERE
  14508. be.diffDays IS NOT NULL
  14509. AND be.diffDays BETWEEN 0
  14510. AND 31
  14511. ) t
  14512. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  14513. AND t.hospitalId = mqi.hospital_id
  14514. AND t.behospitalCode = mqi.behospital_code
  14515. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  14516. AND t.hospitalId = mqi_last.hospital_id
  14517. AND t.lastBehospitalCode = mqi_last.behospital_code
  14518. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  14519. AND t.hospitalId = mhp.hospital_id
  14520. AND t.behospitalCode = mhp.behospital_code
  14521. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  14522. AND t.hospitalId = mhp_last.hospital_id
  14523. AND t.lastBehospitalCode = mhp_last.behospital_code
  14524. </select>
  14525. <!-- 单条条目缺陷统计-->
  14526. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  14527. SELECT
  14528. a.beh_dept_id AS id,
  14529. a.beh_dept_name AS NAME,
  14530. count(*) AS num
  14531. FROM
  14532. med_behospital_info a,
  14533. med_qcresult_detail b
  14534. WHERE
  14535. a.is_deleted = 'N'
  14536. AND b.is_deleted = 'N'
  14537. AND a.hospital_id = b.hospital_id
  14538. AND a.behospital_code = b.behospital_code
  14539. AND a.qc_type_id != 0
  14540. and b.cases_entry_id=2658
  14541. <if test="isPlacefile != null and isPlacefile != ''">
  14542. and a.is_placefile = #{isPlacefile}
  14543. </if>
  14544. <if test="hospitalId != null and hospitalId != ''">
  14545. AND a.hospital_id = #{hospitalId}
  14546. </if>
  14547. <if test="isPlacefile != null and isPlacefile == 0">
  14548. <if test="startDate != null and startDate != ''">
  14549. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  14550. </if>
  14551. <if test="endDate != null and endDate != ''">
  14552. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  14553. </if>
  14554. </if>
  14555. <if test="isPlacefile != null and isPlacefile == 1">
  14556. <if test="startDate != null and startDate != ''">
  14557. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  14558. </if>
  14559. <if test="endDate != null and endDate != ''">
  14560. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  14561. </if>
  14562. </if>
  14563. GROUP BY
  14564. a.beh_dept_id,
  14565. a.beh_dept_name
  14566. </select>
  14567. <!-- 单条条目缺陷统计-->
  14568. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  14569. SELECT
  14570. a.beh_dept_id AS deptId,
  14571. a.beh_dept_name AS deptName,
  14572. a.doctor_id as doctorId,
  14573. a.doctor_name as doctorName,
  14574. count(*) AS num
  14575. FROM
  14576. med_behospital_info a,
  14577. med_qcresult_detail b,
  14578. sys_user_dept c
  14579. WHERE
  14580. a.is_deleted = 'N'
  14581. AND b.is_deleted = 'N'
  14582. AND c.is_deleted = 'N'
  14583. AND a.hospital_id = b.hospital_id
  14584. AND a.hospital_id = c.hospital_id
  14585. AND a.behospital_code = b.behospital_code
  14586. AND a.beh_dept_id = c.dept_id
  14587. AND a.qc_type_id != 0
  14588. and b.cases_entry_id=2658
  14589. <if test="isPlacefile != null and isPlacefile != ''">
  14590. and a.is_placefile = #{isPlacefile}
  14591. </if>
  14592. <if test="hospitalId != null and hospitalId != ''">
  14593. AND a.hospital_id = #{hospitalId}
  14594. </if>
  14595. <if test="userId!=null">
  14596. AND c.user_id = #{userId}
  14597. </if>
  14598. <if test="isPlacefile != null and isPlacefile == 0">
  14599. <if test="startDate != null and startDate != ''">
  14600. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  14601. </if>
  14602. <if test="endDate != null and endDate != ''">
  14603. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  14604. </if>
  14605. </if>
  14606. <if test="isPlacefile != null and isPlacefile == 1">
  14607. <if test="startDate != null and startDate != ''">
  14608. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  14609. </if>
  14610. <if test="endDate != null and endDate != ''">
  14611. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  14612. </if>
  14613. </if>
  14614. GROUP BY
  14615. a.beh_dept_id,
  14616. a.beh_dept_name,
  14617. a.doctor_id,
  14618. a.doctor_name
  14619. </select>
  14620. <!-- 病案首页改善率质控评分页(内页)-->
  14621. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  14622. SELECT
  14623. t.*
  14624. FROM
  14625. (
  14626. SELECT DISTINCT
  14627. t1.hospital_id AS hospitalId,
  14628. t1.behospital_code AS behospitalCode,
  14629. t1.bed_code AS bedCode,
  14630. t1.LEVEL AS LEVEL,
  14631. t1.grade_type AS gradeType,
  14632. t1.score_res AS scoreRes,
  14633. t1.NAME AS NAME,
  14634. t1.sex AS sex,
  14635. t1.beh_dept_id AS behDeptId,
  14636. t1.beh_dept_name AS behDeptName,
  14637. t1.doctor_id AS doctorId,
  14638. t1.doctor_name AS doctorName,
  14639. t1.beh_doctor_id AS behDoctorId,
  14640. t1.beh_doctor_name AS behDoctorName,
  14641. t1.director_doctor_id AS directorDoctorId,
  14642. t1.director_doctor_name AS directorDoctorName,
  14643. t1.birthday AS birthday,
  14644. t1.behospital_date AS behospitalDate,
  14645. t1.leave_hospital_date AS leaveHospitalDate,
  14646. t1.placefile_date AS placefileDate,
  14647. t1.gmt_create AS gradeTime,
  14648. t1.diagnose,
  14649. t1.ward_name AS wardName,
  14650. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  14651. t1.file_code AS fileCode,
  14652. t1.checkStatus,
  14653. t1.mrStatus,
  14654. t1.chName,
  14655. t1.mrName,
  14656. t1.chTime,
  14657. t1.mrTime
  14658. FROM
  14659. (
  14660. SELECT
  14661. be.*,
  14662. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14663. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14664. mci.check_name AS chName,
  14665. hm_mci.check_name AS mrName,
  14666. mci.gmt_create AS chTime,
  14667. hm_mci.gmt_create AS mrTime
  14668. FROM
  14669. (
  14670. SELECT DISTINCT
  14671. a.hospital_id,
  14672. a.behospital_code,
  14673. a.bed_code,
  14674. a.file_code,
  14675. c.LEVEL,
  14676. c.grade_type,
  14677. c.score_res,
  14678. a.NAME,
  14679. a.sex,
  14680. a.beh_dept_id,
  14681. a.beh_dept_name,
  14682. a.birthday,
  14683. a.behospital_date,
  14684. a.leave_hospital_date,
  14685. a.doctor_id,
  14686. a.doctor_name,
  14687. a.beh_doctor_id,
  14688. a.beh_doctor_name,
  14689. a.director_doctor_id,
  14690. a.director_doctor_name,
  14691. a.diagnose,
  14692. a.placefile_date,
  14693. a.ward_name,
  14694. c.gmt_create
  14695. FROM
  14696. med_behospital_info a,
  14697. med_home_page b,
  14698. med_qcresult_info c,
  14699. med_qcresult_cases d,
  14700. (
  14701. SELECT
  14702. m4.*
  14703. FROM
  14704. med_behospital_info m1,
  14705. med_home_page m2,
  14706. med_qcresult_info m3,
  14707. med_qcresult_cases m4
  14708. WHERE
  14709. m1.is_deleted = 'N'
  14710. AND m2.is_deleted = 'N'
  14711. AND m3.is_deleted = 'Y'
  14712. AND m4.is_deleted = 'Y'
  14713. AND m1.hospital_id = m2.hospital_id
  14714. AND m1.hospital_id = m3.hospital_id
  14715. AND m1.hospital_id = m4.hospital_id
  14716. AND m1.behospital_code = m2.behospital_code
  14717. AND m1.behospital_code = m3.behospital_code
  14718. AND m1.behospital_code = m4.behospital_code
  14719. AND m3.gmt_create = m4.gmt_create
  14720. AND m3.have_home_page = 1
  14721. AND m4.cases_id = 243
  14722. AND m1.qc_type_id != 0
  14723. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14724. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14725. </if>
  14726. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14727. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  14728. </if>
  14729. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14730. <if test="qcResultShortPageVO.startDate != null ">
  14731. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14732. </if>
  14733. <if test="qcResultShortPageVO.endDate != null ">
  14734. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14735. </if>
  14736. </if>
  14737. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14738. <if test="qcResultShortPageVO.startDate != null">
  14739. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14740. </if>
  14741. <if test="qcResultShortPageVO.endDate != null ">
  14742. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14743. </if>
  14744. </if>
  14745. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14746. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  14747. </if>
  14748. GROUP BY
  14749. m1.behospital_code
  14750. ORDER BY
  14751. m1.behospital_code,
  14752. m4.gmt_create
  14753. ) e
  14754. WHERE
  14755. a.is_deleted = 'N'
  14756. AND b.is_deleted = 'N'
  14757. AND c.is_deleted = 'N'
  14758. AND d.is_deleted = 'N'
  14759. AND a.hospital_id = b.hospital_id
  14760. AND a.hospital_id = c.hospital_id
  14761. AND a.hospital_id = d.hospital_id
  14762. AND a.hospital_id = e.hospital_id
  14763. AND a.behospital_code = b.behospital_code
  14764. AND a.behospital_code = c.behospital_code
  14765. AND a.behospital_code = d.behospital_code
  14766. AND a.behospital_code = e.behospital_code
  14767. AND d.cases_id = 243
  14768. AND d.score_res > e.score_res
  14769. AND a.qc_type_id != 0
  14770. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14771. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14772. </if>
  14773. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14774. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14775. </if>
  14776. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14777. <if test="qcResultShortPageVO.startDate != null ">
  14778. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14779. </if>
  14780. <if test="qcResultShortPageVO.endDate != null ">
  14781. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14782. </if>
  14783. </if>
  14784. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14785. <if test="qcResultShortPageVO.startDate != null ">
  14786. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14787. </if>
  14788. <if test="qcResultShortPageVO.endDate != null">
  14789. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14790. </if>
  14791. </if>
  14792. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14793. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14794. </if>
  14795. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14796. AND c.`level` = #{qcResultShortPageVO.level}
  14797. </if>
  14798. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14799. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14800. </if>
  14801. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14802. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14803. </if>
  14804. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14805. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14806. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14807. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14808. </if>
  14809. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14810. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14811. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14812. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14813. </if>
  14814. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  14815. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  14816. </if>
  14817. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  14818. AND d.score_res = 20
  14819. </if>
  14820. ) be
  14821. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14822. AND mci.check_type = 0
  14823. AND be.hospital_id = mci.hospital_id
  14824. AND be.behospital_code = mci.behospital_code
  14825. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14826. AND hm_mci.check_type = 1
  14827. AND be.hospital_id = hm_mci.hospital_id
  14828. AND be.behospital_code = hm_mci.behospital_code
  14829. ) t1
  14830. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14831. AND t1.behospital_code = t2.behospital_code
  14832. AND t2.is_deleted = 'N'
  14833. ) t
  14834. WHERE
  14835. 1 = 1
  14836. <if test="qcResultShortPageVO.checkStatus != null">
  14837. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14838. </if>
  14839. <if test="qcResultShortPageVO.mrStatus != null">
  14840. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14841. </if>
  14842. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14843. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14844. </if>
  14845. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14846. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14847. </if>
  14848. <if test="qcResultShortPageVO.chTimeStart != null ">
  14849. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14850. </if>
  14851. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14852. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14853. </if>
  14854. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14855. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14856. </if>
  14857. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14858. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14859. </if>
  14860. </select>
  14861. <!-- 病案首页改善率质控评分页(内页)-科室-->
  14862. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  14863. SELECT
  14864. t.*
  14865. FROM
  14866. (
  14867. SELECT DISTINCT
  14868. t1.hospital_id AS hospitalId,
  14869. t1.behospital_code AS behospitalCode,
  14870. t1.bed_code AS bedCode,
  14871. t1.LEVEL AS LEVEL,
  14872. t1.grade_type AS gradeType,
  14873. t1.score_res AS scoreRes,
  14874. t1.NAME AS NAME,
  14875. t1.scoreBn,
  14876. t1.sex AS sex,
  14877. t1.beh_dept_id AS behDeptId,
  14878. t1.beh_dept_name AS behDeptName,
  14879. t1.doctor_id AS doctorId,
  14880. t1.doctor_name AS doctorName,
  14881. t1.beh_doctor_id AS behDoctorId,
  14882. t1.beh_doctor_name AS behDoctorName,
  14883. t1.director_doctor_id AS directorDoctorId,
  14884. t1.director_doctor_name AS directorDoctorName,
  14885. t1.birthday AS birthday,
  14886. t1.behospital_date AS behospitalDate,
  14887. t1.leave_hospital_date AS leaveHospitalDate,
  14888. t1.placefile_date AS placefileDate,
  14889. t1.gmt_create AS gradeTime,
  14890. t1.diagnose,
  14891. t1.ward_name AS wardName,
  14892. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  14893. t1.file_code AS fileCode,
  14894. t1.checkStatus,
  14895. t1.mrStatus,
  14896. t1.chName,
  14897. t1.mrName,
  14898. t1.chTime,
  14899. t1.mrTime
  14900. FROM
  14901. (
  14902. SELECT
  14903. be.*,
  14904. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14905. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14906. mci.check_name AS chName,
  14907. hm_mci.check_name AS mrName,
  14908. e.score_res as scoreBn,
  14909. mci.gmt_create AS chTime,
  14910. hm_mci.gmt_create AS mrTime
  14911. FROM
  14912. (
  14913. SELECT DISTINCT
  14914. a.hospital_id,
  14915. a.behospital_code,
  14916. a.bed_code,
  14917. a.file_code,
  14918. c.LEVEL,
  14919. c.grade_type,
  14920. c.score_res,
  14921. a.NAME,
  14922. a.sex,
  14923. a.beh_dept_id,
  14924. a.beh_dept_name,
  14925. a.birthday,
  14926. a.behospital_date,
  14927. a.leave_hospital_date,
  14928. a.doctor_id,
  14929. a.doctor_name,
  14930. a.beh_doctor_id,
  14931. a.beh_doctor_name,
  14932. a.director_doctor_id,
  14933. a.director_doctor_name,
  14934. a.diagnose,
  14935. a.placefile_date,
  14936. a.ward_name,
  14937. c.gmt_create
  14938. FROM
  14939. med_behospital_info a,
  14940. med_home_page b,
  14941. med_qcresult_info c,
  14942. med_qcresult_cases d,
  14943. sys_user_dept f,
  14944. (
  14945. SELECT
  14946. m4.*
  14947. FROM
  14948. med_behospital_info m1,
  14949. med_home_page m2,
  14950. med_qcresult_info m3,
  14951. med_qcresult_cases m4
  14952. WHERE
  14953. m1.is_deleted = 'N'
  14954. AND m2.is_deleted = 'N'
  14955. AND m3.is_deleted = 'Y'
  14956. AND m4.is_deleted = 'Y'
  14957. AND m1.hospital_id = m2.hospital_id
  14958. AND m1.hospital_id = m3.hospital_id
  14959. AND m1.hospital_id = m4.hospital_id
  14960. AND m1.behospital_code = m2.behospital_code
  14961. AND m1.behospital_code = m3.behospital_code
  14962. AND m1.behospital_code = m4.behospital_code
  14963. AND m3.gmt_create = m4.gmt_create
  14964. AND m3.have_home_page = 1
  14965. AND m4.cases_id = 243
  14966. AND m1.qc_type_id != 0
  14967. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14968. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14969. </if>
  14970. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14971. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  14972. </if>
  14973. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14974. <if test="qcResultShortPageVO.startDate != null ">
  14975. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14976. </if>
  14977. <if test="qcResultShortPageVO.endDate != null ">
  14978. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14979. </if>
  14980. </if>
  14981. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14982. <if test="qcResultShortPageVO.startDate != null">
  14983. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14984. </if>
  14985. <if test="qcResultShortPageVO.endDate != null ">
  14986. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14987. </if>
  14988. </if>
  14989. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14990. AND m1.beh_dept_name like CONCAT('%', #{qcResultShortPageVO.deptName}, '%')
  14991. </if>
  14992. GROUP BY
  14993. m1.behospital_code
  14994. ORDER BY
  14995. m1.behospital_code,
  14996. m4.gmt_create
  14997. ) e
  14998. WHERE
  14999. a.is_deleted = 'N'
  15000. AND b.is_deleted = 'N'
  15001. AND c.is_deleted = 'N'
  15002. AND d.is_deleted = 'N'
  15003. AND f.is_deleted = 'N'
  15004. AND a.hospital_id = b.hospital_id
  15005. AND a.hospital_id = c.hospital_id
  15006. AND a.hospital_id = d.hospital_id
  15007. AND a.hospital_id = f.hospital_id
  15008. AND a.hospital_id = e.hospital_id
  15009. AND a.behospital_code = b.behospital_code
  15010. AND a.behospital_code = c.behospital_code
  15011. AND a.behospital_code = d.behospital_code
  15012. AND a.beh_dept_id = f.dept_id
  15013. AND a.behospital_code = e.behospital_code
  15014. AND d.cases_id = 243
  15015. AND d.score_res > e.score_res
  15016. AND a.qc_type_id != 0
  15017. <if test="qcResultShortPageVO.userId!=null">
  15018. AND f.user_id = #{qcResultShortPageVO.userId}
  15019. </if>
  15020. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15021. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15022. </if>
  15023. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15024. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15025. </if>
  15026. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15027. <if test="qcResultShortPageVO.startDate != null ">
  15028. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15029. </if>
  15030. <if test="qcResultShortPageVO.endDate != null ">
  15031. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15032. </if>
  15033. </if>
  15034. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15035. <if test="qcResultShortPageVO.startDate != null ">
  15036. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15037. </if>
  15038. <if test="qcResultShortPageVO.endDate != null">
  15039. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15040. </if>
  15041. </if>
  15042. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15043. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15044. </if>
  15045. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15046. AND c.`level` = #{qcResultShortPageVO.level}
  15047. </if>
  15048. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15049. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15050. </if>
  15051. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15052. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15053. </if>
  15054. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15055. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15056. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15057. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15058. </if>
  15059. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15060. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15061. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15062. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15063. </if>
  15064. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15065. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15066. </if>
  15067. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15068. AND d.score_res = 20
  15069. </if>
  15070. ) be
  15071. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15072. AND mci.check_type = 0
  15073. AND be.hospital_id = mci.hospital_id
  15074. AND be.behospital_code = mci.behospital_code
  15075. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15076. AND hm_mci.check_type = 1
  15077. AND be.hospital_id = hm_mci.hospital_id
  15078. AND be.behospital_code = hm_mci.behospital_code
  15079. LEFT JOIN med_qcresult_cases e
  15080. on be.behospital_code = e.behospital_code
  15081. and be.hospital_id = e.hospital_id
  15082. AND e.is_deleted = 'N'
  15083. and e.cases_id = 243
  15084. ) t1
  15085. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15086. AND t1.behospital_code = t2.behospital_code
  15087. AND t2.is_deleted = 'N'
  15088. ) t
  15089. WHERE
  15090. 1 = 1
  15091. <if test="qcResultShortPageVO.checkStatus != null">
  15092. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15093. </if>
  15094. <if test="qcResultShortPageVO.mrStatus != null">
  15095. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15096. </if>
  15097. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15098. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15099. </if>
  15100. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15101. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15102. </if>
  15103. <if test="qcResultShortPageVO.chTimeStart != null ">
  15104. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15105. </if>
  15106. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15107. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15108. </if>
  15109. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15110. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15111. </if>
  15112. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15113. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15114. </if>
  15115. </select>
  15116. <!-- 质控核查质控评分页(内页)-->
  15117. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  15118. SELECT
  15119. t.*
  15120. FROM
  15121. (
  15122. SELECT DISTINCT
  15123. t1.hospital_id AS hospitalId,
  15124. t1.behospital_code AS behospitalCode,
  15125. t1.bed_code AS bedCode,
  15126. t1.LEVEL AS LEVEL,
  15127. t1.grade_type AS gradeType,
  15128. t1.score_res AS scoreRes,
  15129. t1.scoreBn,
  15130. t1.NAME AS NAME,
  15131. t1.sex AS sex,
  15132. t1.beh_dept_id AS behDeptId,
  15133. t1.beh_dept_name AS behDeptName,
  15134. t1.doctor_id AS doctorId,
  15135. t1.doctor_name AS doctorName,
  15136. t1.beh_doctor_id AS behDoctorId,
  15137. t1.beh_doctor_name AS behDoctorName,
  15138. t1.director_doctor_id AS directorDoctorId,
  15139. t1.director_doctor_name AS directorDoctorName,
  15140. t1.birthday AS birthday,
  15141. t1.behospital_date AS behospitalDate,
  15142. t1.leave_hospital_date AS leaveHospitalDate,
  15143. t1.placefile_date AS placefileDate,
  15144. t1.gmt_create AS gradeTime,
  15145. t1.diagnose,
  15146. t1.ward_name AS wardName,
  15147. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15148. t1.file_code AS fileCode,
  15149. t1.checkStatus,
  15150. t1.mrStatus,
  15151. t1.chName,
  15152. t1.mrName,
  15153. t1.chTime,
  15154. t1.mrTime
  15155. FROM
  15156. (
  15157. SELECT
  15158. be.*,
  15159. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15160. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15161. mci.check_name AS chName,
  15162. e.score_res as scoreBn,
  15163. hm_mci.check_name AS mrName,
  15164. mci.gmt_create AS chTime,
  15165. hm_mci.gmt_create AS mrTime
  15166. FROM
  15167. (
  15168. SELECT DISTINCT
  15169. a.hospital_id,
  15170. a.behospital_code,
  15171. a.bed_code,
  15172. a.file_code,
  15173. b.LEVEL,
  15174. b.grade_type,
  15175. b.score_res,
  15176. a.NAME,
  15177. a.sex,
  15178. a.beh_dept_id,
  15179. a.beh_dept_name,
  15180. a.birthday,
  15181. a.behospital_date,
  15182. a.leave_hospital_date,
  15183. a.doctor_id,
  15184. a.doctor_name,
  15185. a.beh_doctor_id,
  15186. a.beh_doctor_name,
  15187. a.director_doctor_id,
  15188. a.director_doctor_name,
  15189. a.diagnose,
  15190. a.placefile_date,
  15191. a.ward_name,
  15192. b.gmt_create
  15193. FROM
  15194. med_behospital_info a,
  15195. med_qcresult_info b
  15196. WHERE
  15197. a.is_deleted = 'N'
  15198. AND b.is_deleted = 'N'
  15199. AND a.hospital_id = b.hospital_id
  15200. AND a.behospital_code = b.behospital_code
  15201. AND a.qc_type_id != 0
  15202. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15203. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15204. </if>
  15205. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15206. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15207. </if>
  15208. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15209. <if test="qcResultShortPageVO.startDate != null ">
  15210. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15211. </if>
  15212. <if test="qcResultShortPageVO.endDate != null ">
  15213. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15214. </if>
  15215. </if>
  15216. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15217. <if test="qcResultShortPageVO.startDate != null ">
  15218. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15219. </if>
  15220. <if test="qcResultShortPageVO.endDate != null">
  15221. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15222. </if>
  15223. </if>
  15224. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15225. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15226. </if>
  15227. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15228. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15229. </if>
  15230. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15231. AND b.`level` = #{qcResultShortPageVO.level}
  15232. </if>
  15233. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15234. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15235. </if>
  15236. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15237. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15238. </if>
  15239. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15240. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15241. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15242. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15243. </if>
  15244. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15245. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15246. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15247. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15248. </if>
  15249. ) be
  15250. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15251. AND mci.check_type = 0
  15252. AND be.hospital_id = mci.hospital_id
  15253. AND be.behospital_code = mci.behospital_code
  15254. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15255. AND hm_mci.check_type = 1
  15256. AND be.hospital_id = hm_mci.hospital_id
  15257. AND be.behospital_code = hm_mci.behospital_code
  15258. LEFT JOIN med_qcresult_cases e
  15259. on be.behospital_code = e.behospital_code
  15260. and be.hospital_id = e.hospital_id
  15261. AND e.is_deleted = 'N'
  15262. and e.cases_id = 243
  15263. ) t1
  15264. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15265. AND t1.behospital_code = t2.behospital_code
  15266. AND t2.is_deleted = 'N'
  15267. ) t
  15268. WHERE
  15269. 1 = 1
  15270. <if test="qcResultShortPageVO.checkStatus != null">
  15271. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15272. </if>
  15273. <if test="qcResultShortPageVO.mrStatus != null">
  15274. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15275. </if>
  15276. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15277. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15278. </if>
  15279. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15280. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15281. </if>
  15282. <if test="qcResultShortPageVO.chTimeStart != null ">
  15283. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15284. </if>
  15285. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15286. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15287. </if>
  15288. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15289. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15290. </if>
  15291. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15292. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15293. </if>
  15294. </select>
  15295. <!-- 质控核查质控评分页-科室(内页)-->
  15296. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDTO">
  15297. SELECT
  15298. t.*
  15299. FROM
  15300. (
  15301. SELECT DISTINCT
  15302. t1.hospital_id AS hospitalId,
  15303. t1.behospital_code AS behospitalCode,
  15304. t1.bed_code AS bedCode,
  15305. t1.LEVEL AS LEVEL,
  15306. t1.grade_type AS gradeType,
  15307. t1.score_res AS scoreRes,
  15308. t1.scoreBn,
  15309. t1.NAME AS NAME,
  15310. t1.sex AS sex,
  15311. t1.beh_dept_id AS behDeptId,
  15312. t1.beh_dept_name AS behDeptName,
  15313. t1.doctor_id AS doctorId,
  15314. t1.doctor_name AS doctorName,
  15315. t1.beh_doctor_id AS behDoctorId,
  15316. t1.beh_doctor_name AS behDoctorName,
  15317. t1.director_doctor_id AS directorDoctorId,
  15318. t1.director_doctor_name AS directorDoctorName,
  15319. t1.birthday AS birthday,
  15320. t1.behospital_date AS behospitalDate,
  15321. t1.leave_hospital_date AS leaveHospitalDate,
  15322. t1.placefile_date AS placefileDate,
  15323. t1.gmt_create AS gradeTime,
  15324. t1.diagnose,
  15325. t1.ward_name AS wardName,
  15326. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  15327. t1.file_code AS fileCode,
  15328. t1.checkStatus,
  15329. t1.mrStatus,
  15330. t1.chName,
  15331. t1.mrName,
  15332. t1.chTime,
  15333. t1.mrTime
  15334. FROM
  15335. (
  15336. SELECT
  15337. be.*,
  15338. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15339. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15340. mci.check_name AS chName,
  15341. e.score_res as scoreBn,
  15342. hm_mci.check_name AS mrName,
  15343. mci.gmt_create AS chTime,
  15344. hm_mci.gmt_create AS mrTime
  15345. FROM
  15346. (
  15347. SELECT DISTINCT
  15348. a.hospital_id,
  15349. a.behospital_code,
  15350. a.bed_code,
  15351. a.file_code,
  15352. b.LEVEL,
  15353. b.grade_type,
  15354. b.score_res,
  15355. a.NAME,
  15356. a.sex,
  15357. a.beh_dept_id,
  15358. a.beh_dept_name,
  15359. a.birthday,
  15360. a.behospital_date,
  15361. a.leave_hospital_date,
  15362. a.doctor_id,
  15363. a.doctor_name,
  15364. a.beh_doctor_id,
  15365. a.beh_doctor_name,
  15366. a.director_doctor_id,
  15367. a.director_doctor_name,
  15368. a.diagnose,
  15369. a.placefile_date,
  15370. a.ward_name,
  15371. b.gmt_create
  15372. FROM
  15373. med_behospital_info a,
  15374. med_qcresult_info b,
  15375. sys_user_dept c
  15376. WHERE
  15377. a.is_deleted = 'N'
  15378. AND b.is_deleted = 'N'
  15379. AND c.is_deleted = 'N'
  15380. AND a.hospital_id = b.hospital_id
  15381. AND a.hospital_id = c.hospital_id
  15382. AND a.beh_dept_id = c.dept_id
  15383. AND a.behospital_code = b.behospital_code
  15384. AND a.qc_type_id != 0
  15385. <if test="qcResultShortPageVO.userId!=null">
  15386. AND c.user_id = #{qcResultShortPageVO.userId}
  15387. </if>
  15388. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15389. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15390. </if>
  15391. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15392. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15393. </if>
  15394. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15395. <if test="qcResultShortPageVO.startDate != null ">
  15396. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15397. </if>
  15398. <if test="qcResultShortPageVO.endDate != null ">
  15399. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15400. </if>
  15401. </if>
  15402. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15403. <if test="qcResultShortPageVO.startDate != null ">
  15404. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15405. </if>
  15406. <if test="qcResultShortPageVO.endDate != null">
  15407. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15408. </if>
  15409. </if>
  15410. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  15411. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  15412. </if>
  15413. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15414. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15415. </if>
  15416. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15417. AND b.`level` = #{qcResultShortPageVO.level}
  15418. </if>
  15419. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15420. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15421. </if>
  15422. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15423. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15424. </if>
  15425. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15426. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15427. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15428. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15429. </if>
  15430. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15431. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15432. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15433. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15434. </if>
  15435. ) be
  15436. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15437. AND mci.check_type = 0
  15438. AND be.hospital_id = mci.hospital_id
  15439. AND be.behospital_code = mci.behospital_code
  15440. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15441. AND hm_mci.check_type = 1
  15442. AND be.hospital_id = hm_mci.hospital_id
  15443. AND be.behospital_code = hm_mci.behospital_code
  15444. LEFT JOIN med_qcresult_cases e
  15445. on be.behospital_code = e.behospital_code
  15446. and be.hospital_id = e.hospital_id
  15447. AND e.is_deleted = 'N'
  15448. and e.cases_id = 243
  15449. ) t1
  15450. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15451. AND t1.behospital_code = t2.behospital_code
  15452. AND t2.is_deleted = 'N'
  15453. ) t
  15454. WHERE
  15455. 1 = 1
  15456. <if test="qcResultShortPageVO.checkStatus != null">
  15457. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15458. </if>
  15459. <if test="qcResultShortPageVO.mrStatus != null">
  15460. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15461. </if>
  15462. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15463. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15464. </if>
  15465. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15466. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15467. </if>
  15468. <if test="qcResultShortPageVO.chTimeStart != null ">
  15469. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15470. </if>
  15471. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15472. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15473. </if>
  15474. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15475. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15476. </if>
  15477. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15478. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15479. </if>
  15480. </select>
  15481. <!-- 病案首页改善率质控评分页导出-->
  15482. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  15483. SELECT
  15484. f1.behDeptId,
  15485. f1.behDeptName,
  15486. f1.doctorName,
  15487. f1.patName,
  15488. f1.behospitalCode,
  15489. f1.hospitalId,
  15490. f1.behospitalDate,
  15491. f1.leaveHospitalDate,
  15492. f1.score,
  15493. f2.avgScore,
  15494. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15495. f1.msg,
  15496. f1.caseName,
  15497. </if>
  15498. f1.checkStatus,
  15499. f1.mrStatus,
  15500. f1.chName,
  15501. f1.mrName,
  15502. f1.chTime,
  15503. f1.mrTime
  15504. FROM
  15505. (SELECT
  15506. t.doctorName AS behDoctorName,
  15507. t.`name` AS patName,
  15508. t.behospitalCode AS behospitalCode,
  15509. t.behospitalDate AS behospitalDate,
  15510. t.leaveHospitalDate AS leaveHospitalDate,
  15511. qi.score_res AS score,
  15512. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15513. qd.msg AS msg,
  15514. qc.NAME AS caseName,
  15515. </if>
  15516. t.behDeptId,
  15517. t.behDeptName,
  15518. t.hospitalId,
  15519. t.checkStatus,
  15520. t.mrStatus,
  15521. t.chName,
  15522. t.mrName,
  15523. t.chTime,
  15524. t.mrTime
  15525. FROM
  15526. (
  15527. SELECT DISTINCT
  15528. t1.hospital_id AS hospitalId,
  15529. t1.behospital_code AS behospitalCode,
  15530. t1.bed_code AS bedCode,
  15531. t1.LEVEL AS LEVEL,
  15532. t1.grade_type AS gradeType,
  15533. t1.score_res AS scoreRes,
  15534. t1.NAME AS NAME,
  15535. t1.sex AS sex,
  15536. t1.beh_dept_id AS behDeptId,
  15537. t1.beh_dept_name AS behDeptName,
  15538. t1.doctor_id AS doctorId,
  15539. t1.doctor_name AS doctorName,
  15540. t1.beh_doctor_id AS behDoctorId,
  15541. t1.beh_doctor_name AS behDoctorName,
  15542. t1.director_doctor_id AS directorDoctorId,
  15543. t1.director_doctor_name AS directorDoctorName,
  15544. t1.birthday AS birthday,
  15545. t1.behospital_date AS behospitalDate,
  15546. t1.leave_hospital_date AS leaveHospitalDate,
  15547. t1.placefile_date AS placefileDate,
  15548. t1.gmt_create AS gradeTime,
  15549. t1.diagnose,
  15550. t1.ward_name AS wardName,
  15551. t2.age,
  15552. t1.file_code AS fileCode,
  15553. t1.checkStatus,
  15554. t1.mrStatus,
  15555. t1.chName,
  15556. t1.mrName,
  15557. t1.chTime,
  15558. t1.mrTime
  15559. FROM
  15560. (
  15561. SELECT
  15562. be.*,
  15563. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15564. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15565. mci.check_name AS chName,
  15566. hm_mci.check_name AS mrName,
  15567. mci.gmt_create AS chTime,
  15568. hm_mci.gmt_create AS mrTime
  15569. FROM
  15570. (
  15571. SELECT DISTINCT
  15572. a.hospital_id,
  15573. a.behospital_code,
  15574. a.bed_code,
  15575. a.file_code,
  15576. c.LEVEL,
  15577. c.grade_type,
  15578. c.score_res,
  15579. a.NAME,
  15580. a.sex,
  15581. a.beh_dept_id,
  15582. a.beh_dept_name,
  15583. a.birthday,
  15584. a.behospital_date,
  15585. a.leave_hospital_date,
  15586. a.doctor_id,
  15587. a.doctor_name,
  15588. a.beh_doctor_id,
  15589. a.beh_doctor_name,
  15590. a.director_doctor_id,
  15591. a.director_doctor_name,
  15592. a.diagnose,
  15593. a.placefile_date,
  15594. a.ward_name,
  15595. c.gmt_create
  15596. FROM
  15597. med_behospital_info a,
  15598. med_home_page b,
  15599. med_qcresult_info c,
  15600. med_qcresult_cases d,
  15601. (
  15602. SELECT
  15603. m4.*
  15604. FROM
  15605. med_behospital_info m1,
  15606. med_home_page m2,
  15607. med_qcresult_info m3,
  15608. med_qcresult_cases m4
  15609. WHERE
  15610. m1.is_deleted = 'N'
  15611. AND m2.is_deleted = 'N'
  15612. AND m3.is_deleted = 'Y'
  15613. AND m4.is_deleted = 'Y'
  15614. AND m1.hospital_id = m2.hospital_id
  15615. AND m1.hospital_id = m3.hospital_id
  15616. AND m1.hospital_id = m4.hospital_id
  15617. AND m1.behospital_code = m2.behospital_code
  15618. AND m1.behospital_code = m3.behospital_code
  15619. AND m1.behospital_code = m4.behospital_code
  15620. AND m3.gmt_create = m4.gmt_create
  15621. AND m3.have_home_page = 1
  15622. AND m4.cases_id = 243
  15623. AND m1.qc_type_id != 0
  15624. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15625. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15626. </if>
  15627. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15628. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15629. </if>
  15630. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15631. <if test="qcResultShortPageVO.startDate != null ">
  15632. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15633. </if>
  15634. <if test="qcResultShortPageVO.endDate != null ">
  15635. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15636. </if>
  15637. </if>
  15638. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15639. <if test="qcResultShortPageVO.startDate != null">
  15640. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15641. </if>
  15642. <if test="qcResultShortPageVO.endDate != null ">
  15643. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15644. </if>
  15645. </if>
  15646. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15647. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15648. </if>
  15649. GROUP BY
  15650. m1.behospital_code
  15651. ORDER BY
  15652. m1.behospital_code,
  15653. m4.gmt_create
  15654. ) e
  15655. WHERE
  15656. a.is_deleted = 'N'
  15657. AND b.is_deleted = 'N'
  15658. AND c.is_deleted = 'N'
  15659. AND d.is_deleted = 'N'
  15660. AND a.hospital_id = b.hospital_id
  15661. AND a.hospital_id = c.hospital_id
  15662. AND a.hospital_id = d.hospital_id
  15663. AND a.hospital_id = e.hospital_id
  15664. AND a.behospital_code = b.behospital_code
  15665. AND a.behospital_code = c.behospital_code
  15666. AND a.behospital_code = d.behospital_code
  15667. AND a.behospital_code = e.behospital_code
  15668. AND d.cases_id = 243
  15669. AND d.score_res > e.score_res
  15670. AND a.qc_type_id != 0
  15671. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15672. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15673. </if>
  15674. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15675. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15676. </if>
  15677. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15678. <if test="qcResultShortPageVO.startDate != null ">
  15679. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15680. </if>
  15681. <if test="qcResultShortPageVO.endDate != null ">
  15682. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15683. </if>
  15684. </if>
  15685. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15686. <if test="qcResultShortPageVO.startDate != null ">
  15687. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15688. </if>
  15689. <if test="qcResultShortPageVO.endDate != null">
  15690. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15691. </if>
  15692. </if>
  15693. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15694. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15695. </if>
  15696. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15697. AND c.`level` = #{qcResultShortPageVO.level}
  15698. </if>
  15699. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15700. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15701. </if>
  15702. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15703. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15704. </if>
  15705. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15706. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15707. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15708. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15709. </if>
  15710. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15711. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15712. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15713. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15714. </if>
  15715. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15716. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15717. </if>
  15718. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15719. AND d.score_res = 20
  15720. </if>
  15721. ) be
  15722. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15723. AND mci.check_type = 0
  15724. AND be.hospital_id = mci.hospital_id
  15725. AND be.behospital_code = mci.behospital_code
  15726. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15727. AND hm_mci.check_type = 1
  15728. AND be.hospital_id = hm_mci.hospital_id
  15729. AND be.behospital_code = hm_mci.behospital_code
  15730. ) t1
  15731. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15732. AND t1.behospital_code = t2.behospital_code
  15733. AND t2.is_deleted = 'N'
  15734. ) t
  15735. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15736. AND t.hospitalId = qi.hospital_id
  15737. AND t.behospitalCode = qi.behospital_code
  15738. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  15739. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  15740. AND t.hospitalId = qd.hospital_id
  15741. AND t.behospitalCode = qd.behospital_code
  15742. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  15743. AND qd.cases_id = qc.id
  15744. </if>
  15745. where 1=1
  15746. <if test="qcResultShortPageVO.checkStatus != null">
  15747. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15748. </if>
  15749. <if test="qcResultShortPageVO.mrStatus != null">
  15750. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15751. </if>
  15752. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15753. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15754. </if>
  15755. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15756. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  15757. </if>
  15758. <if test="qcResultShortPageVO.chTimeStart != null ">
  15759. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  15760. </if>
  15761. <if test="qcResultShortPageVO.chTimeEnd != null ">
  15762. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  15763. </if>
  15764. <if test="qcResultShortPageVO.mrTimeStart != null ">
  15765. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  15766. </if>
  15767. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  15768. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  15769. </if>
  15770. )f1,
  15771. (SELECT
  15772. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  15773. t.behDeptId,
  15774. t.behDeptName
  15775. FROM
  15776. (
  15777. SELECT DISTINCT
  15778. t1.hospital_id AS hospitalId,
  15779. t1.behospital_code AS behospitalCode,
  15780. t1.bed_code AS bedCode,
  15781. t1.LEVEL AS LEVEL,
  15782. t1.grade_type AS gradeType,
  15783. t1.score_res AS scoreRes,
  15784. t1.NAME AS NAME,
  15785. t1.sex AS sex,
  15786. t1.beh_dept_id AS behDeptId,
  15787. t1.beh_dept_name AS behDeptName,
  15788. t1.doctor_id AS doctorId,
  15789. t1.doctor_name AS doctorName,
  15790. t1.beh_doctor_id AS behDoctorId,
  15791. t1.beh_doctor_name AS behDoctorName,
  15792. t1.director_doctor_id AS directorDoctorId,
  15793. t1.director_doctor_name AS directorDoctorName,
  15794. t1.birthday AS birthday,
  15795. t1.behospital_date AS behospitalDate,
  15796. t1.leave_hospital_date AS leaveHospitalDate,
  15797. t1.placefile_date AS placefileDate,
  15798. t1.gmt_create AS gradeTime,
  15799. t1.diagnose,
  15800. t1.ward_name AS wardName,
  15801. t2.age,
  15802. t1.file_code AS fileCode,
  15803. t1.checkStatus,
  15804. t1.mrStatus,
  15805. t1.chName,
  15806. t1.mrName,
  15807. t1.chTime,
  15808. t1.mrTime
  15809. FROM
  15810. (
  15811. SELECT
  15812. be.*,
  15813. ifnull( mci.STATUS, 0 ) AS checkStatus,
  15814. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  15815. mci.check_name AS chName,
  15816. hm_mci.check_name AS mrName,
  15817. mci.gmt_create AS chTime,
  15818. hm_mci.gmt_create AS mrTime
  15819. FROM
  15820. (
  15821. SELECT DISTINCT
  15822. a.hospital_id,
  15823. a.behospital_code,
  15824. a.bed_code,
  15825. a.file_code,
  15826. c.LEVEL,
  15827. c.grade_type,
  15828. c.score_res,
  15829. a.NAME,
  15830. a.sex,
  15831. a.beh_dept_id,
  15832. a.beh_dept_name,
  15833. a.birthday,
  15834. a.behospital_date,
  15835. a.leave_hospital_date,
  15836. a.doctor_id,
  15837. a.doctor_name,
  15838. a.beh_doctor_id,
  15839. a.beh_doctor_name,
  15840. a.director_doctor_id,
  15841. a.director_doctor_name,
  15842. a.diagnose,
  15843. a.placefile_date,
  15844. a.ward_name,
  15845. c.gmt_create
  15846. FROM
  15847. med_behospital_info a,
  15848. med_home_page b,
  15849. med_qcresult_info c,
  15850. med_qcresult_cases d,
  15851. (
  15852. SELECT
  15853. m4.*
  15854. FROM
  15855. med_behospital_info m1,
  15856. med_home_page m2,
  15857. med_qcresult_info m3,
  15858. med_qcresult_cases m4
  15859. WHERE
  15860. m1.is_deleted = 'N'
  15861. AND m2.is_deleted = 'N'
  15862. AND m3.is_deleted = 'Y'
  15863. AND m4.is_deleted = 'Y'
  15864. AND m1.hospital_id = m2.hospital_id
  15865. AND m1.hospital_id = m3.hospital_id
  15866. AND m1.hospital_id = m4.hospital_id
  15867. AND m1.behospital_code = m2.behospital_code
  15868. AND m1.behospital_code = m3.behospital_code
  15869. AND m1.behospital_code = m4.behospital_code
  15870. AND m3.gmt_create = m4.gmt_create
  15871. AND m3.have_home_page = 1
  15872. AND m4.cases_id = 243
  15873. AND m1.qc_type_id != 0
  15874. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15875. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15876. </if>
  15877. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15878. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  15879. </if>
  15880. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15881. <if test="qcResultShortPageVO.startDate != null ">
  15882. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15883. </if>
  15884. <if test="qcResultShortPageVO.endDate != null ">
  15885. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15886. </if>
  15887. </if>
  15888. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15889. <if test="qcResultShortPageVO.startDate != null">
  15890. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15891. </if>
  15892. <if test="qcResultShortPageVO.endDate != null ">
  15893. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15894. </if>
  15895. </if>
  15896. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15897. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  15898. </if>
  15899. GROUP BY
  15900. m1.behospital_code
  15901. ORDER BY
  15902. m1.behospital_code,
  15903. m4.gmt_create
  15904. ) e
  15905. WHERE
  15906. a.is_deleted = 'N'
  15907. AND b.is_deleted = 'N'
  15908. AND c.is_deleted = 'N'
  15909. AND d.is_deleted = 'N'
  15910. AND a.hospital_id = b.hospital_id
  15911. AND a.hospital_id = c.hospital_id
  15912. AND a.hospital_id = d.hospital_id
  15913. AND a.hospital_id = e.hospital_id
  15914. AND a.behospital_code = b.behospital_code
  15915. AND a.behospital_code = c.behospital_code
  15916. AND a.behospital_code = d.behospital_code
  15917. AND a.behospital_code = e.behospital_code
  15918. AND d.cases_id = 243
  15919. AND d.score_res > e.score_res
  15920. AND a.qc_type_id != 0
  15921. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  15922. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  15923. </if>
  15924. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  15925. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  15926. </if>
  15927. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  15928. <if test="qcResultShortPageVO.startDate != null ">
  15929. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  15930. </if>
  15931. <if test="qcResultShortPageVO.endDate != null ">
  15932. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  15933. </if>
  15934. </if>
  15935. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  15936. <if test="qcResultShortPageVO.startDate != null ">
  15937. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  15938. </if>
  15939. <if test="qcResultShortPageVO.endDate != null">
  15940. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  15941. </if>
  15942. </if>
  15943. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  15944. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  15945. </if>
  15946. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  15947. AND c.`level` = #{qcResultShortPageVO.level}
  15948. </if>
  15949. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  15950. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  15951. </if>
  15952. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  15953. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  15954. </if>
  15955. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  15956. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15957. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  15958. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  15959. </if>
  15960. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  15961. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15962. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  15963. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  15964. </if>
  15965. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  15966. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  15967. </if>
  15968. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  15969. AND d.score_res = 20
  15970. </if>
  15971. ) be
  15972. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  15973. AND mci.check_type = 0
  15974. AND be.hospital_id = mci.hospital_id
  15975. AND be.behospital_code = mci.behospital_code
  15976. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  15977. AND hm_mci.check_type = 1
  15978. AND be.hospital_id = hm_mci.hospital_id
  15979. AND be.behospital_code = hm_mci.behospital_code
  15980. ) t1
  15981. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  15982. AND t1.behospital_code = t2.behospital_code
  15983. AND t2.is_deleted = 'N'
  15984. ) t
  15985. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  15986. AND t.hospitalId = qi.hospital_id
  15987. AND t.behospitalCode = qi.behospital_code
  15988. where 1=1
  15989. <if test="qcResultShortPageVO.checkStatus != null">
  15990. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  15991. </if>
  15992. <if test="qcResultShortPageVO.mrStatus != null">
  15993. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  15994. </if>
  15995. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  15996. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  15997. </if>
  15998. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  15999. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16000. </if>
  16001. <if test="qcResultShortPageVO.chTimeStart != null ">
  16002. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16003. </if>
  16004. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16005. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16006. </if>
  16007. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16008. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16009. </if>
  16010. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16011. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16012. </if>
  16013. GROUP BY
  16014. t.behDeptId,
  16015. t.behDeptName
  16016. )f2
  16017. WHERE
  16018. f1.behDeptId = f2.behDeptId
  16019. AND f1.behDeptName = f2.behDeptName
  16020. </select>
  16021. <!-- 病案首页改善率质控评分页导出-->
  16022. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  16023. SELECT
  16024. f1.behDeptId,
  16025. f1.behDeptName,
  16026. f1.doctorId,
  16027. f1.doctorName,
  16028. f1.patName,
  16029. f1.behospitalCode,
  16030. f1.hospitalId,
  16031. f1.scoreBn,
  16032. f1.behospitalDate,
  16033. f1.leaveHospitalDate,
  16034. f1.score,
  16035. f2.avgScore,
  16036. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16037. f1.msg,
  16038. f1.caseName,
  16039. </if>
  16040. f1.checkStatus,
  16041. f1.mrStatus,
  16042. f1.chName,
  16043. f1.mrName,
  16044. f1.chTime,
  16045. f1.mrTime
  16046. FROM
  16047. (SELECT
  16048. t.doctorId,
  16049. t.doctorName,
  16050. t.`name` AS patName,
  16051. t.behospitalCode AS behospitalCode,
  16052. t.behospitalDate AS behospitalDate,
  16053. t.leaveHospitalDate AS leaveHospitalDate,
  16054. qi.score_res AS score,
  16055. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16056. qd.msg AS msg,
  16057. qc.NAME AS caseName,
  16058. </if>
  16059. t.behDeptId,
  16060. t.behDeptName,
  16061. t.hospitalId,
  16062. t.checkStatus,
  16063. t.mrStatus,
  16064. t.chName,
  16065. t.mrName,
  16066. t.chTime,
  16067. t.mrTime
  16068. FROM
  16069. (
  16070. SELECT DISTINCT
  16071. t1.hospital_id AS hospitalId,
  16072. t1.behospital_code AS behospitalCode,
  16073. t1.bed_code AS bedCode,
  16074. t1.LEVEL AS LEVEL,
  16075. t1.grade_type AS gradeType,
  16076. t1.score_res AS scoreRes,
  16077. t1.NAME AS NAME,
  16078. t1.sex AS sex,
  16079. t1.beh_dept_id AS behDeptId,
  16080. t1.beh_dept_name AS behDeptName,
  16081. t1.doctor_id AS doctorId,
  16082. t1.doctor_name AS doctorName,
  16083. t1.beh_doctor_id AS behDoctorId,
  16084. t1.beh_doctor_name AS behDoctorName,
  16085. t1.director_doctor_id AS directorDoctorId,
  16086. t1.director_doctor_name AS directorDoctorName,
  16087. t1.birthday AS birthday,
  16088. t1.behospital_date AS behospitalDate,
  16089. t1.leave_hospital_date AS leaveHospitalDate,
  16090. t1.placefile_date AS placefileDate,
  16091. t1.gmt_create AS gradeTime,
  16092. t1.diagnose,
  16093. t1.ward_name AS wardName,
  16094. t1.scoreBn,
  16095. t1.file_code AS fileCode,
  16096. t1.checkStatus,
  16097. t1.mrStatus,
  16098. t1.chName,
  16099. t1.mrName,
  16100. t1.chTime,
  16101. t1.mrTime
  16102. FROM
  16103. (
  16104. SELECT
  16105. be.*,
  16106. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16107. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16108. mci.check_name AS chName,
  16109. e.score_res as scoreBn,
  16110. hm_mci.check_name AS mrName,
  16111. mci.gmt_create AS chTime,
  16112. hm_mci.gmt_create AS mrTime
  16113. FROM
  16114. (
  16115. SELECT DISTINCT
  16116. a.hospital_id,
  16117. a.behospital_code,
  16118. a.bed_code,
  16119. a.file_code,
  16120. c.LEVEL,
  16121. c.grade_type,
  16122. c.score_res,
  16123. a.NAME,
  16124. a.sex,
  16125. a.beh_dept_id,
  16126. a.beh_dept_name,
  16127. a.birthday,
  16128. a.behospital_date,
  16129. a.leave_hospital_date,
  16130. a.doctor_id,
  16131. a.doctor_name,
  16132. a.beh_doctor_id,
  16133. a.beh_doctor_name,
  16134. a.director_doctor_id,
  16135. a.director_doctor_name,
  16136. a.diagnose,
  16137. a.placefile_date,
  16138. a.ward_name,
  16139. c.gmt_create
  16140. FROM
  16141. med_behospital_info a,
  16142. med_home_page b,
  16143. med_qcresult_info c,
  16144. med_qcresult_cases d,
  16145. sys_user_dept f,
  16146. (
  16147. SELECT
  16148. m4.*
  16149. FROM
  16150. med_behospital_info m1,
  16151. med_home_page m2,
  16152. med_qcresult_info m3,
  16153. med_qcresult_cases m4
  16154. WHERE
  16155. m1.is_deleted = 'N'
  16156. AND m2.is_deleted = 'N'
  16157. AND m3.is_deleted = 'Y'
  16158. AND m4.is_deleted = 'Y'
  16159. AND m1.hospital_id = m2.hospital_id
  16160. AND m1.hospital_id = m3.hospital_id
  16161. AND m1.hospital_id = m4.hospital_id
  16162. AND m1.behospital_code = m2.behospital_code
  16163. AND m1.behospital_code = m3.behospital_code
  16164. AND m1.behospital_code = m4.behospital_code
  16165. AND m3.gmt_create = m4.gmt_create
  16166. AND m3.have_home_page = 1
  16167. AND m4.cases_id = 243
  16168. AND m1.qc_type_id != 0
  16169. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16170. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16171. </if>
  16172. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16173. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16174. </if>
  16175. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16176. <if test="qcResultShortPageVO.startDate != null ">
  16177. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16178. </if>
  16179. <if test="qcResultShortPageVO.endDate != null ">
  16180. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16181. </if>
  16182. </if>
  16183. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16184. <if test="qcResultShortPageVO.startDate != null">
  16185. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16186. </if>
  16187. <if test="qcResultShortPageVO.endDate != null ">
  16188. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16189. </if>
  16190. </if>
  16191. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16192. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16193. </if>
  16194. GROUP BY
  16195. m1.behospital_code
  16196. ORDER BY
  16197. m1.behospital_code,
  16198. m4.gmt_create
  16199. ) e
  16200. WHERE
  16201. a.is_deleted = 'N'
  16202. AND b.is_deleted = 'N'
  16203. AND c.is_deleted = 'N'
  16204. AND d.is_deleted = 'N'
  16205. AND f.is_deleted = 'N'
  16206. AND a.hospital_id = b.hospital_id
  16207. AND a.hospital_id = c.hospital_id
  16208. AND a.hospital_id = d.hospital_id
  16209. AND a.hospital_id = e.hospital_id
  16210. AND a.hospital_id = f.hospital_id
  16211. AND a.behospital_code = b.behospital_code
  16212. AND a.behospital_code = c.behospital_code
  16213. AND a.behospital_code = d.behospital_code
  16214. AND a.behospital_code = e.behospital_code
  16215. AND a.beh_dept_id = f.dept_id
  16216. AND d.cases_id = 243
  16217. AND d.score_res > e.score_res
  16218. AND a.qc_type_id != 0
  16219. <if test="qcResultShortPageVO.userId!=null">
  16220. AND f.user_id = #{qcResultShortPageVO.userId}
  16221. </if>
  16222. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16223. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16224. </if>
  16225. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16226. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16227. </if>
  16228. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16229. <if test="qcResultShortPageVO.startDate != null ">
  16230. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16231. </if>
  16232. <if test="qcResultShortPageVO.endDate != null ">
  16233. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16234. </if>
  16235. </if>
  16236. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16237. <if test="qcResultShortPageVO.startDate != null ">
  16238. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16239. </if>
  16240. <if test="qcResultShortPageVO.endDate != null">
  16241. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16242. </if>
  16243. </if>
  16244. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16245. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16246. </if>
  16247. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16248. AND c.`level` = #{qcResultShortPageVO.level}
  16249. </if>
  16250. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16251. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16252. </if>
  16253. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16254. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16255. </if>
  16256. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16257. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16258. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16259. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16260. </if>
  16261. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16262. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16263. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16264. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16265. </if>
  16266. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16267. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16268. </if>
  16269. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16270. AND d.score_res = 20
  16271. </if>
  16272. ) be
  16273. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16274. AND mci.check_type = 0
  16275. AND be.hospital_id = mci.hospital_id
  16276. AND be.behospital_code = mci.behospital_code
  16277. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16278. AND hm_mci.check_type = 1
  16279. AND be.hospital_id = hm_mci.hospital_id
  16280. AND be.behospital_code = hm_mci.behospital_code
  16281. LEFT JOIN med_qcresult_cases e
  16282. on be.behospital_code = e.behospital_code
  16283. and be.hospital_id = e.hospital_id
  16284. AND e.is_deleted = 'N'
  16285. and e.cases_id = 243
  16286. ) t1
  16287. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16288. AND t1.behospital_code = t2.behospital_code
  16289. AND t2.is_deleted = 'N'
  16290. ) t
  16291. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16292. AND t.hospitalId = qi.hospital_id
  16293. AND t.behospitalCode = qi.behospital_code
  16294. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16295. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  16296. AND t.hospitalId = qd.hospital_id
  16297. AND t.behospitalCode = qd.behospital_code
  16298. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  16299. AND qd.cases_id = qc.id
  16300. </if>
  16301. where 1=1
  16302. <if test="qcResultShortPageVO.checkStatus != null">
  16303. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16304. </if>
  16305. <if test="qcResultShortPageVO.mrStatus != null">
  16306. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16307. </if>
  16308. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16309. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16310. </if>
  16311. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16312. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16313. </if>
  16314. <if test="qcResultShortPageVO.chTimeStart != null ">
  16315. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16316. </if>
  16317. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16318. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16319. </if>
  16320. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16321. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16322. </if>
  16323. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16324. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16325. </if>
  16326. )f1,
  16327. (SELECT
  16328. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16329. t.behDeptId,
  16330. t.behDeptName,
  16331. t.doctorId,
  16332. t.doctorName
  16333. FROM
  16334. (
  16335. SELECT DISTINCT
  16336. t1.hospital_id AS hospitalId,
  16337. t1.behospital_code AS behospitalCode,
  16338. t1.bed_code AS bedCode,
  16339. t1.LEVEL AS LEVEL,
  16340. t1.grade_type AS gradeType,
  16341. t1.score_res AS scoreRes,
  16342. t1.NAME AS NAME,
  16343. t1.sex AS sex,
  16344. t1.beh_dept_id AS behDeptId,
  16345. t1.beh_dept_name AS behDeptName,
  16346. t1.doctor_id AS doctorId,
  16347. t1.doctor_name AS doctorName,
  16348. t1.beh_doctor_id AS behDoctorId,
  16349. t1.beh_doctor_name AS behDoctorName,
  16350. t1.director_doctor_id AS directorDoctorId,
  16351. t1.director_doctor_name AS directorDoctorName,
  16352. t1.birthday AS birthday,
  16353. t1.behospital_date AS behospitalDate,
  16354. t1.leave_hospital_date AS leaveHospitalDate,
  16355. t1.placefile_date AS placefileDate,
  16356. t1.gmt_create AS gradeTime,
  16357. t1.diagnose,
  16358. t1.ward_name AS wardName,
  16359. t2.age,
  16360. t1.file_code AS fileCode,
  16361. t1.checkStatus,
  16362. t1.mrStatus,
  16363. t1.chName,
  16364. t1.mrName,
  16365. t1.chTime,
  16366. t1.mrTime
  16367. FROM
  16368. (
  16369. SELECT
  16370. be.*,
  16371. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16372. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16373. mci.check_name AS chName,
  16374. hm_mci.check_name AS mrName,
  16375. mci.gmt_create AS chTime,
  16376. hm_mci.gmt_create AS mrTime
  16377. FROM
  16378. (
  16379. SELECT DISTINCT
  16380. a.hospital_id,
  16381. a.behospital_code,
  16382. a.bed_code,
  16383. a.file_code,
  16384. c.LEVEL,
  16385. c.grade_type,
  16386. c.score_res,
  16387. a.NAME,
  16388. a.sex,
  16389. a.beh_dept_id,
  16390. a.beh_dept_name,
  16391. a.birthday,
  16392. a.behospital_date,
  16393. a.leave_hospital_date,
  16394. a.doctor_id,
  16395. a.doctor_name,
  16396. a.beh_doctor_id,
  16397. a.beh_doctor_name,
  16398. a.director_doctor_id,
  16399. a.director_doctor_name,
  16400. a.diagnose,
  16401. a.placefile_date,
  16402. a.ward_name,
  16403. c.gmt_create
  16404. FROM
  16405. med_behospital_info a,
  16406. med_home_page b,
  16407. med_qcresult_info c,
  16408. med_qcresult_cases d,
  16409. sys_user_dept f,
  16410. (
  16411. SELECT
  16412. m4.*
  16413. FROM
  16414. med_behospital_info m1,
  16415. med_home_page m2,
  16416. med_qcresult_info m3,
  16417. med_qcresult_cases m4
  16418. WHERE
  16419. m1.is_deleted = 'N'
  16420. AND m2.is_deleted = 'N'
  16421. AND m3.is_deleted = 'Y'
  16422. AND m4.is_deleted = 'Y'
  16423. AND m1.hospital_id = m2.hospital_id
  16424. AND m1.hospital_id = m3.hospital_id
  16425. AND m1.hospital_id = m4.hospital_id
  16426. AND m1.behospital_code = m2.behospital_code
  16427. AND m1.behospital_code = m3.behospital_code
  16428. AND m1.behospital_code = m4.behospital_code
  16429. AND m3.gmt_create = m4.gmt_create
  16430. AND m3.have_home_page = 1
  16431. AND m4.cases_id = 243
  16432. AND m1.qc_type_id != 0
  16433. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16434. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16435. </if>
  16436. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16437. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  16438. </if>
  16439. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16440. <if test="qcResultShortPageVO.startDate != null ">
  16441. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16442. </if>
  16443. <if test="qcResultShortPageVO.endDate != null ">
  16444. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16445. </if>
  16446. </if>
  16447. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16448. <if test="qcResultShortPageVO.startDate != null">
  16449. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16450. </if>
  16451. <if test="qcResultShortPageVO.endDate != null ">
  16452. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16453. </if>
  16454. </if>
  16455. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16456. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  16457. </if>
  16458. GROUP BY
  16459. m1.behospital_code
  16460. ORDER BY
  16461. m1.behospital_code,
  16462. m4.gmt_create
  16463. ) e
  16464. WHERE
  16465. a.is_deleted = 'N'
  16466. AND b.is_deleted = 'N'
  16467. AND c.is_deleted = 'N'
  16468. AND d.is_deleted = 'N'
  16469. AND f.is_deleted = 'N'
  16470. AND a.hospital_id = b.hospital_id
  16471. AND a.hospital_id = c.hospital_id
  16472. AND a.hospital_id = d.hospital_id
  16473. AND a.hospital_id = e.hospital_id
  16474. AND a.hospital_id = f.hospital_id
  16475. AND a.behospital_code = b.behospital_code
  16476. AND a.behospital_code = c.behospital_code
  16477. AND a.behospital_code = d.behospital_code
  16478. AND a.behospital_code = e.behospital_code
  16479. AND a.beh_dept_id = f.dept_id
  16480. AND d.cases_id = 243
  16481. AND d.score_res > e.score_res
  16482. AND a.qc_type_id != 0
  16483. <if test="qcResultShortPageVO.userId!=null">
  16484. AND f.user_id = #{qcResultShortPageVO.userId}
  16485. </if>
  16486. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16487. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16488. </if>
  16489. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16490. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16491. </if>
  16492. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16493. <if test="qcResultShortPageVO.startDate != null ">
  16494. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16495. </if>
  16496. <if test="qcResultShortPageVO.endDate != null ">
  16497. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16498. </if>
  16499. </if>
  16500. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16501. <if test="qcResultShortPageVO.startDate != null ">
  16502. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16503. </if>
  16504. <if test="qcResultShortPageVO.endDate != null">
  16505. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16506. </if>
  16507. </if>
  16508. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16509. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16510. </if>
  16511. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16512. AND c.`level` = #{qcResultShortPageVO.level}
  16513. </if>
  16514. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16515. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16516. </if>
  16517. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16518. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16519. </if>
  16520. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16521. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16522. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16523. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16524. </if>
  16525. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16526. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16527. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16528. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16529. </if>
  16530. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  16531. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  16532. </if>
  16533. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  16534. AND d.score_res = 20
  16535. </if>
  16536. ) be
  16537. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16538. AND mci.check_type = 0
  16539. AND be.hospital_id = mci.hospital_id
  16540. AND be.behospital_code = mci.behospital_code
  16541. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16542. AND hm_mci.check_type = 1
  16543. AND be.hospital_id = hm_mci.hospital_id
  16544. AND be.behospital_code = hm_mci.behospital_code
  16545. ) t1
  16546. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16547. AND t1.behospital_code = t2.behospital_code
  16548. AND t2.is_deleted = 'N'
  16549. ) t
  16550. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16551. AND t.hospitalId = qi.hospital_id
  16552. AND t.behospitalCode = qi.behospital_code
  16553. where 1=1
  16554. <if test="qcResultShortPageVO.checkStatus != null">
  16555. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16556. </if>
  16557. <if test="qcResultShortPageVO.mrStatus != null">
  16558. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16559. </if>
  16560. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16561. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16562. </if>
  16563. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16564. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16565. </if>
  16566. <if test="qcResultShortPageVO.chTimeStart != null ">
  16567. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16568. </if>
  16569. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16570. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16571. </if>
  16572. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16573. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16574. </if>
  16575. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16576. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16577. </if>
  16578. GROUP BY
  16579. t.doctorId,
  16580. t.doctorName
  16581. )f2
  16582. WHERE
  16583. f1.doctorId = f2.doctorId
  16584. AND f1.doctorName = f2.doctorName
  16585. </select>
  16586. <!-- 质控核查质控评分页导出-->
  16587. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  16588. SELECT
  16589. f1.behDeptId,
  16590. f1.behDeptName,
  16591. f1.doctorName,
  16592. f1.patName,
  16593. f1.behospitalCode,
  16594. f1.hospitalId,
  16595. f1.behospitalDate,
  16596. f1.leaveHospitalDate,
  16597. f1.score,
  16598. f1.scoreBn,
  16599. f2.avgScore,
  16600. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16601. f1.msg,
  16602. f1.caseName,
  16603. </if>
  16604. f1.checkStatus,
  16605. f1.mrStatus,
  16606. f1.chName,
  16607. f1.mrName,
  16608. f1.chTime,
  16609. f1.mrTime
  16610. FROM
  16611. (SELECT
  16612. t.doctorName,
  16613. t.`name` AS patName,
  16614. t.behospitalCode AS behospitalCode,
  16615. t.behospitalDate AS behospitalDate,
  16616. t.leaveHospitalDate AS leaveHospitalDate,
  16617. qi.score_res AS score,
  16618. t.scoreBn,
  16619. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16620. qd.msg AS msg,
  16621. qc.NAME AS caseName,
  16622. </if>
  16623. t.behDeptId,
  16624. t.behDeptName,
  16625. t.hospitalId,
  16626. t.checkStatus,
  16627. t.mrStatus,
  16628. t.chName,
  16629. t.mrName,
  16630. t.chTime,
  16631. t.mrTime
  16632. FROM
  16633. (
  16634. SELECT DISTINCT
  16635. t1.hospital_id AS hospitalId,
  16636. t1.behospital_code AS behospitalCode,
  16637. t1.bed_code AS bedCode,
  16638. t1.LEVEL AS LEVEL,
  16639. t1.grade_type AS gradeType,
  16640. t1.score_res AS scoreRes,
  16641. t1.scoreBn,
  16642. t1.NAME AS NAME,
  16643. t1.sex AS sex,
  16644. t1.beh_dept_id AS behDeptId,
  16645. t1.beh_dept_name AS behDeptName,
  16646. t1.doctor_id AS doctorId,
  16647. t1.doctor_name AS doctorName,
  16648. t1.beh_doctor_id AS behDoctorId,
  16649. t1.beh_doctor_name AS behDoctorName,
  16650. t1.director_doctor_id AS directorDoctorId,
  16651. t1.director_doctor_name AS directorDoctorName,
  16652. t1.birthday AS birthday,
  16653. t1.behospital_date AS behospitalDate,
  16654. t1.leave_hospital_date AS leaveHospitalDate,
  16655. t1.placefile_date AS placefileDate,
  16656. t1.gmt_create AS gradeTime,
  16657. t1.diagnose,
  16658. t1.ward_name AS wardName,
  16659. t2.age,
  16660. t1.file_code AS fileCode,
  16661. t1.checkStatus,
  16662. t1.mrStatus,
  16663. t1.chName,
  16664. t1.mrName,
  16665. t1.chTime,
  16666. t1.mrTime
  16667. FROM
  16668. (
  16669. SELECT
  16670. be.*,
  16671. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16672. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16673. mci.check_name AS chName,
  16674. e.score_res as scoreBn,
  16675. hm_mci.check_name AS mrName,
  16676. mci.gmt_create AS chTime,
  16677. hm_mci.gmt_create AS mrTime
  16678. FROM
  16679. (
  16680. SELECT DISTINCT
  16681. a.hospital_id,
  16682. a.behospital_code,
  16683. a.bed_code,
  16684. a.file_code,
  16685. b.LEVEL,
  16686. b.grade_type,
  16687. b.score_res,
  16688. a.NAME,
  16689. a.sex,
  16690. a.beh_dept_id,
  16691. a.beh_dept_name,
  16692. a.birthday,
  16693. a.behospital_date,
  16694. a.leave_hospital_date,
  16695. a.doctor_id,
  16696. a.doctor_name,
  16697. a.beh_doctor_id,
  16698. a.beh_doctor_name,
  16699. a.director_doctor_id,
  16700. a.director_doctor_name,
  16701. a.diagnose,
  16702. a.placefile_date,
  16703. a.ward_name,
  16704. b.gmt_create
  16705. FROM
  16706. med_behospital_info a,
  16707. med_qcresult_info b
  16708. WHERE
  16709. a.is_deleted = 'N'
  16710. AND b.is_deleted = 'N'
  16711. AND a.hospital_id = b.hospital_id
  16712. AND a.behospital_code = b.behospital_code
  16713. AND a.qc_type_id != 0
  16714. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16715. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16716. </if>
  16717. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16718. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16719. </if>
  16720. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16721. <if test="qcResultShortPageVO.startDate != null ">
  16722. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16723. </if>
  16724. <if test="qcResultShortPageVO.endDate != null ">
  16725. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16726. </if>
  16727. </if>
  16728. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16729. <if test="qcResultShortPageVO.startDate != null ">
  16730. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16731. </if>
  16732. <if test="qcResultShortPageVO.endDate != null">
  16733. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16734. </if>
  16735. </if>
  16736. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  16737. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  16738. </if>
  16739. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16740. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16741. </if>
  16742. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16743. AND c.`level` = #{qcResultShortPageVO.level}
  16744. </if>
  16745. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16746. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16747. </if>
  16748. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16749. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16750. </if>
  16751. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16752. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16753. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16754. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16755. </if>
  16756. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16757. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16758. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16759. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16760. </if>
  16761. ) be
  16762. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16763. AND mci.check_type = 0
  16764. AND be.hospital_id = mci.hospital_id
  16765. AND be.behospital_code = mci.behospital_code
  16766. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16767. AND hm_mci.check_type = 1
  16768. AND be.hospital_id = hm_mci.hospital_id
  16769. AND be.behospital_code = hm_mci.behospital_code
  16770. LEFT JOIN med_qcresult_cases e
  16771. on be.behospital_code = e.behospital_code
  16772. and be.hospital_id = e.hospital_id
  16773. AND e.is_deleted = 'N'
  16774. and e.cases_id = 243
  16775. ) t1
  16776. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16777. AND t1.behospital_code = t2.behospital_code
  16778. AND t2.is_deleted = 'N'
  16779. ) t
  16780. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16781. AND t.hospitalId = qi.hospital_id
  16782. AND t.behospitalCode = qi.behospital_code
  16783. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  16784. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  16785. AND t.hospitalId = qd.hospital_id
  16786. AND t.behospitalCode = qd.behospital_code
  16787. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  16788. AND qd.cases_id = qc.id
  16789. </if>
  16790. where 1=1
  16791. <if test="qcResultShortPageVO.checkStatus != null">
  16792. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16793. </if>
  16794. <if test="qcResultShortPageVO.mrStatus != null">
  16795. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16796. </if>
  16797. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16798. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16799. </if>
  16800. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16801. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16802. </if>
  16803. <if test="qcResultShortPageVO.chTimeStart != null ">
  16804. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16805. </if>
  16806. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16807. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16808. </if>
  16809. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16810. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16811. </if>
  16812. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16813. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16814. </if>
  16815. )f1,
  16816. (SELECT
  16817. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  16818. t.behDeptId,
  16819. t.behDeptName
  16820. FROM
  16821. (
  16822. SELECT DISTINCT
  16823. t1.hospital_id AS hospitalId,
  16824. t1.behospital_code AS behospitalCode,
  16825. t1.bed_code AS bedCode,
  16826. t1.LEVEL AS LEVEL,
  16827. t1.grade_type AS gradeType,
  16828. t1.score_res AS scoreRes,
  16829. t1.NAME AS NAME,
  16830. t1.sex AS sex,
  16831. t1.beh_dept_id AS behDeptId,
  16832. t1.beh_dept_name AS behDeptName,
  16833. t1.doctor_id AS doctorId,
  16834. t1.doctor_name AS doctorName,
  16835. t1.beh_doctor_id AS behDoctorId,
  16836. t1.beh_doctor_name AS behDoctorName,
  16837. t1.director_doctor_id AS directorDoctorId,
  16838. t1.director_doctor_name AS directorDoctorName,
  16839. t1.birthday AS birthday,
  16840. t1.behospital_date AS behospitalDate,
  16841. t1.leave_hospital_date AS leaveHospitalDate,
  16842. t1.placefile_date AS placefileDate,
  16843. t1.gmt_create AS gradeTime,
  16844. t1.diagnose,
  16845. t1.ward_name AS wardName,
  16846. t2.age,
  16847. t1.file_code AS fileCode,
  16848. t1.checkStatus,
  16849. t1.mrStatus,
  16850. t1.chName,
  16851. t1.mrName,
  16852. t1.chTime,
  16853. t1.mrTime
  16854. FROM
  16855. (
  16856. SELECT
  16857. be.*,
  16858. ifnull( mci.STATUS, 0 ) AS checkStatus,
  16859. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  16860. mci.check_name AS chName,
  16861. hm_mci.check_name AS mrName,
  16862. mci.gmt_create AS chTime,
  16863. hm_mci.gmt_create AS mrTime
  16864. FROM
  16865. (
  16866. SELECT DISTINCT
  16867. a.hospital_id,
  16868. a.behospital_code,
  16869. a.bed_code,
  16870. a.file_code,
  16871. b.LEVEL,
  16872. b.grade_type,
  16873. b.score_res,
  16874. a.NAME,
  16875. a.sex,
  16876. a.beh_dept_id,
  16877. a.beh_dept_name,
  16878. a.birthday,
  16879. a.behospital_date,
  16880. a.leave_hospital_date,
  16881. a.doctor_id,
  16882. a.doctor_name,
  16883. a.beh_doctor_id,
  16884. a.beh_doctor_name,
  16885. a.director_doctor_id,
  16886. a.director_doctor_name,
  16887. a.diagnose,
  16888. a.placefile_date,
  16889. a.ward_name,
  16890. b.gmt_create
  16891. FROM
  16892. med_behospital_info a,
  16893. med_qcresult_info b
  16894. WHERE
  16895. a.is_deleted = 'N'
  16896. AND b.is_deleted = 'N'
  16897. AND a.hospital_id = b.hospital_id
  16898. AND a.behospital_code = b.behospital_code
  16899. AND a.qc_type_id != 0
  16900. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  16901. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  16902. </if>
  16903. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  16904. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  16905. </if>
  16906. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  16907. <if test="qcResultShortPageVO.startDate != null ">
  16908. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  16909. </if>
  16910. <if test="qcResultShortPageVO.endDate != null ">
  16911. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  16912. </if>
  16913. </if>
  16914. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  16915. <if test="qcResultShortPageVO.startDate != null ">
  16916. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  16917. </if>
  16918. <if test="qcResultShortPageVO.endDate != null">
  16919. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  16920. </if>
  16921. </if>
  16922. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  16923. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  16924. </if>
  16925. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  16926. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  16927. </if>
  16928. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  16929. AND c.`level` = #{qcResultShortPageVO.level}
  16930. </if>
  16931. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  16932. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  16933. </if>
  16934. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  16935. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  16936. </if>
  16937. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  16938. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16939. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  16940. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  16941. </if>
  16942. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  16943. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16944. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  16945. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  16946. </if>
  16947. ) be
  16948. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  16949. AND mci.check_type = 0
  16950. AND be.hospital_id = mci.hospital_id
  16951. AND be.behospital_code = mci.behospital_code
  16952. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  16953. AND hm_mci.check_type = 1
  16954. AND be.hospital_id = hm_mci.hospital_id
  16955. AND be.behospital_code = hm_mci.behospital_code
  16956. ) t1
  16957. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  16958. AND t1.behospital_code = t2.behospital_code
  16959. AND t2.is_deleted = 'N'
  16960. ) t
  16961. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  16962. AND t.hospitalId = qi.hospital_id
  16963. AND t.behospitalCode = qi.behospital_code
  16964. where 1=1
  16965. <if test="qcResultShortPageVO.checkStatus != null">
  16966. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  16967. </if>
  16968. <if test="qcResultShortPageVO.mrStatus != null">
  16969. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  16970. </if>
  16971. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  16972. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  16973. </if>
  16974. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  16975. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  16976. </if>
  16977. <if test="qcResultShortPageVO.chTimeStart != null ">
  16978. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  16979. </if>
  16980. <if test="qcResultShortPageVO.chTimeEnd != null ">
  16981. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  16982. </if>
  16983. <if test="qcResultShortPageVO.mrTimeStart != null ">
  16984. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  16985. </if>
  16986. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  16987. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  16988. </if>
  16989. GROUP BY
  16990. t.behDeptId,
  16991. t.behDeptName
  16992. )f2
  16993. WHERE
  16994. f1.behDeptId = f2.behDeptId
  16995. AND f1.behDeptName = f2.behDeptName
  16996. </select>
  16997. <!-- 质控核查质控评分页导出 -科室-->
  16998. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  16999. SELECT
  17000. f1.behDeptId,
  17001. f1.behDeptName,
  17002. f1.doctorName,
  17003. f1.doctorId,
  17004. f1.patName,
  17005. f1.behospitalCode,
  17006. f1.hospitalId,
  17007. f1.behospitalDate,
  17008. f1.leaveHospitalDate,
  17009. f1.score,
  17010. f1.scoreBn,
  17011. f2.avgScore,
  17012. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17013. f1.msg,
  17014. f1.caseName,
  17015. </if>
  17016. f1.checkStatus,
  17017. f1.mrStatus,
  17018. f1.chName,
  17019. f1.mrName,
  17020. f1.chTime,
  17021. f1.mrTime
  17022. FROM
  17023. (SELECT
  17024. t.doctorName,
  17025. t.doctorId,
  17026. t.`name` AS patName,
  17027. t.behospitalCode AS behospitalCode,
  17028. t.behospitalDate AS behospitalDate,
  17029. t.leaveHospitalDate AS leaveHospitalDate,
  17030. qi.score_res AS score,
  17031. t.scoreBn,
  17032. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17033. qd.msg AS msg,
  17034. qc.NAME AS caseName,
  17035. </if>
  17036. t.behDeptId,
  17037. t.behDeptName,
  17038. t.hospitalId,
  17039. t.checkStatus,
  17040. t.mrStatus,
  17041. t.chName,
  17042. t.mrName,
  17043. t.chTime,
  17044. t.mrTime
  17045. FROM
  17046. (
  17047. SELECT DISTINCT
  17048. t1.hospital_id AS hospitalId,
  17049. t1.behospital_code AS behospitalCode,
  17050. t1.bed_code AS bedCode,
  17051. t1.LEVEL AS LEVEL,
  17052. t1.grade_type AS gradeType,
  17053. t1.score_res AS scoreRes,
  17054. t1.scoreBn,
  17055. t1.NAME AS NAME,
  17056. t1.sex AS sex,
  17057. t1.beh_dept_id AS behDeptId,
  17058. t1.beh_dept_name AS behDeptName,
  17059. t1.doctor_id AS doctorId,
  17060. t1.doctor_name AS doctorName,
  17061. t1.beh_doctor_id AS behDoctorId,
  17062. t1.beh_doctor_name AS behDoctorName,
  17063. t1.director_doctor_id AS directorDoctorId,
  17064. t1.director_doctor_name AS directorDoctorName,
  17065. t1.birthday AS birthday,
  17066. t1.behospital_date AS behospitalDate,
  17067. t1.leave_hospital_date AS leaveHospitalDate,
  17068. t1.placefile_date AS placefileDate,
  17069. t1.gmt_create AS gradeTime,
  17070. t1.diagnose,
  17071. t1.ward_name AS wardName,
  17072. t2.age,
  17073. t1.file_code AS fileCode,
  17074. t1.checkStatus,
  17075. t1.mrStatus,
  17076. t1.chName,
  17077. t1.mrName,
  17078. t1.chTime,
  17079. t1.mrTime
  17080. FROM
  17081. (
  17082. SELECT
  17083. be.*,
  17084. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17085. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17086. mci.check_name AS chName,
  17087. e.score_res as scoreBn,
  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. b.LEVEL,
  17099. b.grade_type,
  17100. b.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. b.gmt_create
  17118. FROM
  17119. med_behospital_info a,
  17120. med_qcresult_info b,
  17121. sys_user_dept c
  17122. WHERE
  17123. a.is_deleted = 'N'
  17124. AND b.is_deleted = 'N'
  17125. AND c.is_deleted = 'N'
  17126. AND a.hospital_id = b.hospital_id
  17127. AND a.hospital_id = c.hospital_id
  17128. AND a.behospital_code = b.behospital_code
  17129. AND a.beh_dept_id = c.dept_id
  17130. AND a.qc_type_id != 0
  17131. <if test="qcResultShortPageVO.userId!=null">
  17132. AND c.user_id = #{qcResultShortPageVO.userId}
  17133. </if>
  17134. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17135. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17136. </if>
  17137. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17138. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17139. </if>
  17140. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17141. <if test="qcResultShortPageVO.startDate != null ">
  17142. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17143. </if>
  17144. <if test="qcResultShortPageVO.endDate != null ">
  17145. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17146. </if>
  17147. </if>
  17148. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17149. <if test="qcResultShortPageVO.startDate != null ">
  17150. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17151. </if>
  17152. <if test="qcResultShortPageVO.endDate != null">
  17153. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17154. </if>
  17155. </if>
  17156. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17157. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17158. </if>
  17159. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17160. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17161. </if>
  17162. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17163. AND c.`level` = #{qcResultShortPageVO.level}
  17164. </if>
  17165. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17166. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17167. </if>
  17168. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17169. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17170. </if>
  17171. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17172. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17173. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17174. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17175. </if>
  17176. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17177. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17178. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17179. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17180. </if>
  17181. ) be
  17182. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17183. AND mci.check_type = 0
  17184. AND be.hospital_id = mci.hospital_id
  17185. AND be.behospital_code = mci.behospital_code
  17186. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17187. AND hm_mci.check_type = 1
  17188. AND be.hospital_id = hm_mci.hospital_id
  17189. AND be.behospital_code = hm_mci.behospital_code
  17190. LEFT JOIN med_qcresult_cases e
  17191. on be.behospital_code = e.behospital_code
  17192. and be.hospital_id = e.hospital_id
  17193. AND e.is_deleted = 'N'
  17194. and e.cases_id = 243
  17195. ) t1
  17196. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17197. AND t1.behospital_code = t2.behospital_code
  17198. AND t2.is_deleted = 'N'
  17199. ) t
  17200. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17201. AND t.hospitalId = qi.hospital_id
  17202. AND t.behospitalCode = qi.behospital_code
  17203. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  17204. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  17205. AND t.hospitalId = qd.hospital_id
  17206. AND t.behospitalCode = qd.behospital_code
  17207. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  17208. AND qd.cases_id = qc.id
  17209. </if>
  17210. where 1=1
  17211. <if test="qcResultShortPageVO.checkStatus != null">
  17212. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17213. </if>
  17214. <if test="qcResultShortPageVO.mrStatus != null">
  17215. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17216. </if>
  17217. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17218. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17219. </if>
  17220. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17221. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17222. </if>
  17223. <if test="qcResultShortPageVO.chTimeStart != null ">
  17224. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17225. </if>
  17226. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17227. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17228. </if>
  17229. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17230. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17231. </if>
  17232. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17233. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17234. </if>
  17235. )f1,
  17236. (SELECT
  17237. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  17238. t.behDeptId,
  17239. t.behDeptName,
  17240. t.doctorId,
  17241. t.doctorName
  17242. FROM
  17243. (
  17244. SELECT DISTINCT
  17245. t1.hospital_id AS hospitalId,
  17246. t1.behospital_code AS behospitalCode,
  17247. t1.bed_code AS bedCode,
  17248. t1.LEVEL AS LEVEL,
  17249. t1.grade_type AS gradeType,
  17250. t1.score_res AS scoreRes,
  17251. t1.NAME AS NAME,
  17252. t1.sex AS sex,
  17253. t1.beh_dept_id AS behDeptId,
  17254. t1.beh_dept_name AS behDeptName,
  17255. t1.doctor_id AS doctorId,
  17256. t1.doctor_name AS doctorName,
  17257. t1.beh_doctor_id AS behDoctorId,
  17258. t1.beh_doctor_name AS behDoctorName,
  17259. t1.director_doctor_id AS directorDoctorId,
  17260. t1.director_doctor_name AS directorDoctorName,
  17261. t1.birthday AS birthday,
  17262. t1.behospital_date AS behospitalDate,
  17263. t1.leave_hospital_date AS leaveHospitalDate,
  17264. t1.placefile_date AS placefileDate,
  17265. t1.gmt_create AS gradeTime,
  17266. t1.diagnose,
  17267. t1.ward_name AS wardName,
  17268. t2.age,
  17269. t1.file_code AS fileCode,
  17270. t1.checkStatus,
  17271. t1.mrStatus,
  17272. t1.chName,
  17273. t1.mrName,
  17274. t1.chTime,
  17275. t1.mrTime
  17276. FROM
  17277. (
  17278. SELECT
  17279. be.*,
  17280. ifnull( mci.STATUS, 0 ) AS checkStatus,
  17281. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  17282. mci.check_name AS chName,
  17283. hm_mci.check_name AS mrName,
  17284. mci.gmt_create AS chTime,
  17285. hm_mci.gmt_create AS mrTime
  17286. FROM
  17287. (
  17288. SELECT DISTINCT
  17289. a.hospital_id,
  17290. a.behospital_code,
  17291. a.bed_code,
  17292. a.file_code,
  17293. b.LEVEL,
  17294. b.grade_type,
  17295. b.score_res,
  17296. a.NAME,
  17297. a.sex,
  17298. a.beh_dept_id,
  17299. a.beh_dept_name,
  17300. a.birthday,
  17301. a.behospital_date,
  17302. a.leave_hospital_date,
  17303. a.doctor_id,
  17304. a.doctor_name,
  17305. a.beh_doctor_id,
  17306. a.beh_doctor_name,
  17307. a.director_doctor_id,
  17308. a.director_doctor_name,
  17309. a.diagnose,
  17310. a.placefile_date,
  17311. a.ward_name,
  17312. b.gmt_create
  17313. FROM
  17314. med_behospital_info a,
  17315. med_qcresult_info b,
  17316. sys_user_dept c
  17317. WHERE
  17318. a.is_deleted = 'N'
  17319. AND b.is_deleted = 'N'
  17320. AND c.is_deleted = 'N'
  17321. AND a.hospital_id = b.hospital_id
  17322. AND a.hospital_id = c.hospital_id
  17323. AND a.behospital_code = b.behospital_code
  17324. AND a.beh_dept_id = c.dept_id
  17325. AND a.qc_type_id != 0
  17326. <if test="qcResultShortPageVO.userId!=null">
  17327. AND c.user_id = #{qcResultShortPageVO.userId}
  17328. </if>
  17329. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  17330. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  17331. </if>
  17332. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  17333. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  17334. </if>
  17335. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  17336. <if test="qcResultShortPageVO.startDate != null ">
  17337. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  17338. </if>
  17339. <if test="qcResultShortPageVO.endDate != null ">
  17340. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  17341. </if>
  17342. </if>
  17343. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  17344. <if test="qcResultShortPageVO.startDate != null ">
  17345. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  17346. </if>
  17347. <if test="qcResultShortPageVO.endDate != null">
  17348. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  17349. </if>
  17350. </if>
  17351. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  17352. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  17353. </if>
  17354. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  17355. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  17356. </if>
  17357. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  17358. AND c.`level` = #{qcResultShortPageVO.level}
  17359. </if>
  17360. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  17361. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  17362. </if>
  17363. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  17364. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  17365. </if>
  17366. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  17367. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17368. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  17369. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  17370. </if>
  17371. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  17372. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17373. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  17374. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  17375. </if>
  17376. ) be
  17377. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  17378. AND mci.check_type = 0
  17379. AND be.hospital_id = mci.hospital_id
  17380. AND be.behospital_code = mci.behospital_code
  17381. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  17382. AND hm_mci.check_type = 1
  17383. AND be.hospital_id = hm_mci.hospital_id
  17384. AND be.behospital_code = hm_mci.behospital_code
  17385. ) t1
  17386. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  17387. AND t1.behospital_code = t2.behospital_code
  17388. AND t2.is_deleted = 'N'
  17389. ) t
  17390. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  17391. AND t.hospitalId = qi.hospital_id
  17392. AND t.behospitalCode = qi.behospital_code
  17393. where 1=1
  17394. <if test="qcResultShortPageVO.checkStatus != null">
  17395. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  17396. </if>
  17397. <if test="qcResultShortPageVO.mrStatus != null">
  17398. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  17399. </if>
  17400. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  17401. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  17402. </if>
  17403. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  17404. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  17405. </if>
  17406. <if test="qcResultShortPageVO.chTimeStart != null ">
  17407. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  17408. </if>
  17409. <if test="qcResultShortPageVO.chTimeEnd != null ">
  17410. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  17411. </if>
  17412. <if test="qcResultShortPageVO.mrTimeStart != null ">
  17413. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  17414. </if>
  17415. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  17416. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  17417. </if>
  17418. GROUP BY
  17419. t.doctorId,
  17420. t.doctorName
  17421. )f2
  17422. WHERE
  17423. f1.doctorId = f2.doctorId
  17424. AND f1.doctorName = f2.doctorName
  17425. </select>
  17426. <!-- 入院,手术,出院病案情况-->
  17427. <select id="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17428. SELECT
  17429. count(
  17430. DISTINCT
  17431. CASE
  17432. WHEN q.type=5 THEN
  17433. a.behospital_code
  17434. ELSE
  17435. NULL
  17436. END
  17437. ) AS 'operationNote',
  17438. count(
  17439. DISTINCT
  17440. CASE
  17441. WHEN q.type = 4 THEN
  17442. a.behospital_code
  17443. ELSE
  17444. NULL
  17445. END
  17446. ) AS 'residentAdmitNote',
  17447. count(
  17448. DISTINCT
  17449. CASE
  17450. WHEN q.type = 6 THEN
  17451. a.behospital_code
  17452. ELSE
  17453. NULL
  17454. END
  17455. ) AS 'dischargeRecord',
  17456. count(
  17457. DISTINCT
  17458. CASE
  17459. WHEN q.type = 7 THEN
  17460. a.behospital_code
  17461. ELSE
  17462. NULL
  17463. END
  17464. ) AS 'medicalRecord'
  17465. FROM
  17466. (
  17467. SELECT
  17468. a.behospital_code,
  17469. a.cases_entry_id,
  17470. a.hospital_id
  17471. FROM
  17472. (
  17473. SELECT
  17474. a.behospital_code,
  17475. c.cases_entry_id,
  17476. a.hospital_id
  17477. FROM
  17478. (
  17479. SELECT
  17480. a.behospital_code,
  17481. a.hospital_id
  17482. FROM
  17483. med_behospital_info a,
  17484. med_qcresult_info c
  17485. WHERE
  17486. a.is_deleted = 'N'
  17487. AND c.is_deleted = 'N'
  17488. AND a.is_placefile = #{filterVO.isPlacefile}
  17489. <if test="filterVO.startDate != null and filterVO.endDate != null">
  17490. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  17491. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17492. </if>
  17493. <![CDATA[ and a.qc_type_id <>'0' ]]>
  17494. AND a.behospital_code = c.behospital_code
  17495. AND a.hospital_id = #{filterVO.hospitalId}
  17496. AND a.hospital_id = c.hospital_id
  17497. ) a
  17498. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  17499. AND a.behospital_code = c.behospital_code
  17500. AND a.hospital_id = c.hospital_id
  17501. ) a
  17502. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  17503. AND d.is_deleted = 'N'
  17504. ) a
  17505. LEFT JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  17506. AND a.hospital_id = q.hospital_id
  17507. </select>
  17508. <!-- 时间段出院,住院, 手术费,抗菌药物,手术和病理费等含有人数 -->
  17509. <select id="selectOperationNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17510. select
  17511. d.behospital_code behospitalCode,
  17512. b.operation_fee operationFee,
  17513. b.pathology_fee pathologyFee,
  17514. b.antibiosis_fee antibiosisFee
  17515. FROM
  17516. (
  17517. SELECT
  17518. a.behospital_code,
  17519. a.hospital_id,
  17520. a.behospital_date,
  17521. a.leave_hospital_date
  17522. FROM
  17523. med_behospital_info a,
  17524. med_qcresult_info c
  17525. WHERE
  17526. a.is_deleted = 'N'
  17527. AND c.is_deleted = 'N'
  17528. AND a.is_placefile = #{filterVO.isPlacefile}
  17529. <if test="filterVO.startDate != null and filterVO.endDate != null">
  17530. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  17531. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17532. </if>
  17533. <![CDATA[ and a.qc_type_id <>'0' ]]>
  17534. AND a.hospital_id = c.hospital_id
  17535. AND a.hospital_id = #{filterVO.hospitalId}
  17536. and a.behospital_code = c.behospital_code
  17537. ) d
  17538. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  17539. AND d.hospital_id = b.hospital_id
  17540. AND b.is_deleted = 'N'
  17541. </select>
  17542. <!-- 关于触发规则不符合人数-->
  17543. <select id="triggeringRules" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17544. SELECT
  17545. count(
  17546. DISTINCT
  17547. CASE
  17548. WHEN a.type=5 THEN
  17549. a.behospital_code
  17550. ELSE
  17551. NULL
  17552. END
  17553. ) AS 'operationNote',
  17554. count(
  17555. DISTINCT
  17556. CASE
  17557. WHEN a.type = 4 THEN
  17558. a.behospital_code
  17559. ELSE
  17560. NULL
  17561. END
  17562. ) AS 'residentAdmitNote',
  17563. count(
  17564. DISTINCT
  17565. CASE
  17566. WHEN a.type = 6 THEN
  17567. a.behospital_code
  17568. ELSE
  17569. NULL
  17570. END
  17571. ) AS 'dischargeRecord',
  17572. count(
  17573. DISTINCT
  17574. CASE
  17575. WHEN a.type = 7 THEN
  17576. a.behospital_code
  17577. ELSE
  17578. NULL
  17579. END
  17580. ) AS 'medicalRecord',
  17581. count(
  17582. DISTINCT
  17583. CASE
  17584. WHEN a.type=8 THEN
  17585. a.behospital_code
  17586. ELSE
  17587. NULL
  17588. END
  17589. ) AS 'CT',
  17590. count(
  17591. DISTINCT
  17592. CASE
  17593. WHEN a.type = 9 THEN
  17594. a.behospital_code
  17595. ELSE
  17596. NULL
  17597. END
  17598. ) AS 'MR',
  17599. count(
  17600. DISTINCT
  17601. CASE
  17602. WHEN a.type = 10 THEN
  17603. a.behospital_code
  17604. ELSE
  17605. NULL
  17606. END
  17607. ) AS 'operationPathologyFee',
  17608. count(
  17609. DISTINCT
  17610. CASE
  17611. WHEN a.type = 11 THEN
  17612. a.behospital_code
  17613. ELSE
  17614. NULL
  17615. END
  17616. ) AS 'bacterialCulture',
  17617. count(
  17618. DISTINCT
  17619. CASE
  17620. WHEN a.type = 12 THEN
  17621. a.behospital_code
  17622. ELSE
  17623. NULL
  17624. END
  17625. ) AS 'antibiosis',
  17626. count(
  17627. DISTINCT
  17628. CASE
  17629. WHEN a.type = 13 THEN
  17630. a.behospital_code
  17631. ELSE
  17632. NULL
  17633. END
  17634. ) AS 'chemotherapyMalignantTumors',
  17635. count(
  17636. DISTINCT
  17637. CASE
  17638. WHEN a.type = 15 THEN
  17639. a.behospital_code
  17640. ELSE
  17641. NULL
  17642. END
  17643. ) AS 'operationRecordNum',
  17644. count(
  17645. DISTINCT
  17646. CASE
  17647. WHEN a.type = 17 THEN
  17648. a.behospital_code
  17649. ELSE
  17650. NULL
  17651. END
  17652. ) AS 'bloodNum',
  17653. count(
  17654. DISTINCT
  17655. CASE
  17656. WHEN a.type = 18 THEN
  17657. a.behospital_code
  17658. ELSE
  17659. NULL
  17660. END
  17661. ) AS 'WardRoundNum',
  17662. count(
  17663. DISTINCT
  17664. CASE
  17665. WHEN a.type = 19 THEN
  17666. a.behospital_code
  17667. ELSE
  17668. NULL
  17669. END
  17670. ) AS 'rescueNum',
  17671. count(
  17672. DISTINCT
  17673. CASE
  17674. WHEN a.type = 22 THEN
  17675. a.behospital_code
  17676. ELSE
  17677. NULL
  17678. END
  17679. ) AS 'unreasonedCopyNum',
  17680. count(
  17681. DISTINCT
  17682. CASE
  17683. WHEN a.type = 14 THEN
  17684. a.behospital_code
  17685. ELSE
  17686. NULL
  17687. END
  17688. ) AS 'tumorRadiationNum',
  17689. count(
  17690. DISTINCT
  17691. CASE
  17692. WHEN a.type = 16 THEN
  17693. a.behospital_code
  17694. ELSE
  17695. NULL
  17696. END
  17697. ) AS 'implantsNum',
  17698. count(
  17699. DISTINCT
  17700. CASE
  17701. WHEN a.type = 23 THEN
  17702. a.behospital_code
  17703. ELSE
  17704. NULL
  17705. END
  17706. ) AS 'InformedNum'
  17707. FROM
  17708. (
  17709. SELECT
  17710. a.behospital_code,
  17711. a.hospital_id,
  17712. q.type
  17713. FROM
  17714. (
  17715. SELECT
  17716. a.behospital_code,
  17717. a.cases_entry_id,
  17718. a.hospital_id
  17719. FROM
  17720. (
  17721. SELECT
  17722. a.behospital_code,
  17723. c.cases_entry_id,
  17724. a.hospital_id
  17725. FROM
  17726. (
  17727. SELECT
  17728. a.behospital_code,
  17729. a.hospital_id
  17730. FROM
  17731. med_behospital_info a,
  17732. med_qcresult_info c
  17733. WHERE
  17734. a.is_deleted = 'N'
  17735. AND c.is_deleted = 'N'
  17736. AND a.is_placefile = #{filterVO.isPlacefile}
  17737. <if test="filterVO.startDate != null and filterVO.endDate != null">
  17738. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  17739. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17740. </if>
  17741. AND a.behospital_code = c.behospital_code
  17742. AND a.hospital_id = #{filterVO.hospitalId}
  17743. AND a.hospital_id = c.hospital_id
  17744. ) a
  17745. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  17746. AND a.behospital_code = c.behospital_code
  17747. AND a.hospital_id = c.hospital_id
  17748. ) a
  17749. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  17750. AND d.is_deleted = 'N'
  17751. ) a
  17752. JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  17753. AND a.hospital_id = q.hospital_id
  17754. ) a
  17755. JOIN med_index_relevance r ON r.behospital_code = a.behospital_code
  17756. AND r.relevance_type = a.type
  17757. AND r.is_deleted = 'N'
  17758. AND a.hospital_id = r.hospital_id
  17759. </select>
  17760. <!-- 跟病案首页关联的出院病历-->
  17761. <select id="getMedicalRecords" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17762. SELECT
  17763. d.behospital_code,
  17764. d.behospital_date,
  17765. d.leave_hospital_date,
  17766. b.behospital_code AS b_code,
  17767. b.operation_fee,
  17768. b.antibiosis_fee,
  17769. b.pathology_fee
  17770. FROM
  17771. (
  17772. SELECT
  17773. a.behospital_code,
  17774. a.hospital_id,
  17775. a.behospital_date,
  17776. a.leave_hospital_date
  17777. FROM
  17778. med_behospital_info a,
  17779. med_qcresult_info c
  17780. WHERE
  17781. a.behospital_code = c.behospital_code
  17782. AND a.hospital_id = #{filterVO.hospitalId}
  17783. AND a.is_placefile = #{filterVO.isPlacefile}
  17784. AND a.hospital_id = c.hospital_id
  17785. AND a.is_deleted = 'N'
  17786. AND c.is_deleted = 'N'
  17787. <![CDATA[ and a.qc_type_id <>'0' ]]>
  17788. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  17789. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  17790. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17791. </if>
  17792. ) d
  17793. LEFT JOIN med_home_page b ON b.behospital_code = d.behospital_code
  17794. AND d.hospital_id = b.hospital_id
  17795. AND b.is_deleted = 'N'
  17796. where ISNULL(b.behospital_code)
  17797. </select>
  17798. <!-- 首页恶性肿瘤-->
  17799. <select id="malignancy" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  17800. select
  17801. a.behospital_code,
  17802. a.hospital_id,
  17803. d.diagnose_name,
  17804. d.diagnose_type,
  17805. d.icd_code
  17806. from(
  17807. SELECT
  17808. d.behospital_code,
  17809. d.hospital_id,
  17810. b.home_page_id
  17811. FROM
  17812. (
  17813. SELECT
  17814. a.behospital_code,
  17815. a.hospital_id,
  17816. a.behospital_date,
  17817. a.leave_hospital_date
  17818. FROM
  17819. med_behospital_info a,
  17820. med_qcresult_info c
  17821. WHERE
  17822. a.behospital_code = c.behospital_code
  17823. AND a.hospital_id = #{filterVO.hospitalId}
  17824. AND a.is_placefile = #{filterVO.isPlacefile}
  17825. AND a.hospital_id = c.hospital_id
  17826. AND a.is_deleted = 'N'
  17827. AND c.is_deleted = 'N'
  17828. <![CDATA[ and a.qc_type_id <>'0' ]]>
  17829. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  17830. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  17831. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  17832. </if>
  17833. ) d
  17834. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  17835. AND d.hospital_id = b.hospital_id
  17836. AND b.is_deleted = 'N'
  17837. )a join
  17838. med_home_diagnose_info d on a.hospital_id=d.hospital_id
  17839. where a.home_page_id =d.home_page_id
  17840. and d.is_deleted ='N'
  17841. and d.diagnose_name like '%恶性肿瘤%'
  17842. and d.icd_code like 'C%'
  17843. </select>
  17844. <!-- 获取患者年龄信息(通过出生日期和入院日期重新计算) -->
  17845. <select id="getBehospitalInfoAge" resultType="com.diagbot.dto.BehospitalInfoAgeDTO">
  17846. SELECT
  17847. mbi.behospital_code behospitalCode,
  17848. mhp.age,
  17849. TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) as ageYear,
  17850. TIMESTAMPDIFF(month,DATE_ADD(ifnull(mhp.birthday,mbi.birthday),INTERVAL TIMESTAMPDIFF(year,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) year),mbi.behospital_date) as ageMon,
  17851. TIMESTAMPDIFF(day,DATE_ADD(ifnull(mhp.birthday,mbi.birthday),INTERVAL TIMESTAMPDIFF(month,ifnull(mhp.birthday,mbi.birthday),mbi.behospital_date) month),mbi.behospital_date) as ageDay
  17852. FROM
  17853. med_behospital_info mbi
  17854. LEFT JOIN med_home_page mhp
  17855. ON mbi.behospital_code=mhp.behospital_code
  17856. AND mbi.hospital_id = mhp.hospital_id AND mhp.is_deleted = 'N'
  17857. WHERE mbi.hospital_id=#{hospitalId} AND mbi.is_deleted = 'N'
  17858. <if test="behospitalCodes !=null and behospitalCodes.size > 0">
  17859. and mbi.behospital_code in
  17860. <foreach collection="behospitalCodes" item="item" open="(" close=")" separator=",">
  17861. #{item}
  17862. </foreach>
  17863. </if>
  17864. </select>
  17865. </mapper>