BehospitalInfoMapper.xml 616 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418
  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="getMsg" resultType="com.diagbot.dto.MsgDTO">
  302. SELECT a.*, u.linkman
  303. FROM
  304. (
  305. SELECT DISTINCT c.score,c.msg,c.cases_entry_id,c.is_reject,c.id id,c.info,
  306. a.name standard_msg, c.opt_type, c.grade_type,
  307. c.gmt_create, c.gmt_modified, c.modifier,c.is_deleted,c.explain_info as explainInfo,
  308. a.type, a.drgs, a.rule_type
  309. FROM
  310. `qc_cases_entry` a, med_qcresult_detail c, qc_cases_hospital d
  311. where a.is_deleted = 'N' and d.is_deleted = 'N'
  312. and a.id = c.cases_entry_id
  313. and c.hospital_id = d.hospital_id
  314. and c.hospital_id = #{hospitalId}
  315. <if test="qcresultInfoId != null">
  316. AND c.qcresult_info_id = #{qcresultInfoId}
  317. </if>
  318. and c.behospital_code = #{behospitalCode} and c.opt_type != 2
  319. order by c.grade_type desc, a.order_no) a
  320. LEFT JOIN sys_user u on u.id = a.modifier and u.is_deleted = 'N'
  321. </select>
  322. <select id="getMsgDetail" resultType="com.diagbot.dto.MsgDTO">
  323. 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,
  324. b.id model_id, a.name standard_msg, c.opt_type, c.grade_type,
  325. c.gmt_create, c.gmt_modified, c.modifier,c.is_deleted,a.remark,
  326. a.type, a.drgs,a.rule_type
  327. FROM
  328. `qc_cases_entry` a, qc_mode b, med_qcresult_detail c
  329. where a.is_deleted = 'N' and b.is_deleted = 'N'
  330. and a.id = c.cases_entry_id and a.mode_id = b.id
  331. and c.hospital_id = #{hospitalId}
  332. <if test="qcresultInfoId != null">
  333. AND c.qcresult_info_id = #{qcresultInfoId}
  334. </if>
  335. and c.behospital_code = #{behospitalCode} and b.id = 6 and c.opt_type not in (2,4)
  336. order by b.order_no, c.grade_type desc, a.order_no
  337. </select>
  338. <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
  339. SELECT b.id model_id,b.`name` model_name,
  340. d.score,d.msg,d.cases_entry_id,d.is_reject,
  341. a.cases_id cases_id, a.name standard_msg,a.code,a.rule_type
  342. FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
  343. where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
  344. and a.mode_id = b.id
  345. and a.id = d.cases_entry_id
  346. and d.is_used = 1
  347. and d.hospital_id = #{hospitalId}
  348. and a.code in
  349. <foreach collection="codeList" item="item" open="(" close=")" separator=",">
  350. #{item}
  351. </foreach>
  352. <if test="modeId != null">
  353. and a.mode_id = #{modeId}
  354. </if>
  355. order by b.order_no, a.order_no;
  356. </select>
  357. <!--病案管理指标基础sql明细-->
  358. <select id="getBaseIndex" parameterType="com.diagbot.vo.MedIndexFilterVO" resultType="java.util.Map">
  359. select
  360. f1.firWorkNum,
  361. f2.secWorkNum,
  362. f3.thrWorkNum,
  363. f3.forWorkNum,
  364. f3.sixWorkNum
  365. from (
  366. SELECT count(DISTINCT a.behospital_code) as firWorkNum
  367. FROM
  368. med_behospital_info a
  369. WHERE
  370. a.is_deleted = 'N'
  371. AND a.is_placefile = 1
  372. <if test="hospitalId != null and hospitalId != ''">
  373. AND a.hospital_id = #{hospitalId}
  374. </if>
  375. <![CDATA[AND a.qc_type_id <>0 ]]>
  376. <if test="startDate != null and startDate != ''">
  377. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  378. </if>
  379. <if test="endDate != null and endDate != ''">
  380. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  381. </if>)f1,
  382. ( SELECT count(DISTINCT a.behospital_code) AS secWorkNum
  383. FROM
  384. med_outpatient_info a
  385. WHERE
  386. a.is_deleted = 'N'
  387. <if test="startDate != null and startDate != ''">
  388. <![CDATA[ AND a.visit_date >= #{lastStartDate}]]>
  389. </if>
  390. <if test="endDate != null and endDate != ''">
  391. <![CDATA[ AND a.visit_date <= #{lastEndDate}]]>
  392. </if>
  393. <if test="hospitalId != null and hospitalId != ''">
  394. AND a.hospital_id = #{hospitalId}
  395. </if>)f2,(
  396. select
  397. count(DISTINCT case when <![CDATA[m.behospital_date >= #{startDate}]]> and <![CDATA[m.behospital_date <= #{endDate}]]>
  398. and m.is_placefile = 0 then m.behospital_code else null end) as thrWorkNum,
  399. 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,
  400. 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
  401. from(
  402. SELECT DISTINCT a.*,b.level
  403. FROM
  404. med_behospital_info a,
  405. med_qcresult_info b
  406. WHERE
  407. a.is_deleted = 'N'
  408. AND b.is_deleted = 'N'
  409. AND a.hospital_id = b.hospital_id
  410. AND a.behospital_code = b.behospital_code
  411. <![CDATA[AND a.qc_type_id <>0 ]]>
  412. <if test="hospitalId != null and hospitalId != ''">
  413. AND a.hospital_id = #{hospitalId}
  414. </if>)m
  415. )f3
  416. </select>
  417. <!-- 病案管理规则质控缺陷病历总数查询-->
  418. <select id="getMedManageParams" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.MedManageParamsDTO">
  419. SELECT
  420. f1.behospitalCode,
  421. <if test="flagStr != null and flagStr == 1 ">
  422. f2.rep_name as repName,
  423. </if>
  424. <if test="flagStr != null and flagStr == 2">
  425. f3.da_item_name as daItemName,
  426. f3.da_status AS daStatus,
  427. f3.doctor_advice_type as doctorAdviceType,
  428. </if>
  429. <if test="flagStr != null and flagStr == 4 ">
  430. f5.content as content,
  431. f5.rec_title as recTitle,
  432. </if>
  433. f1.hospitalId
  434. from(
  435. SELECT DISTINCT
  436. a.hospital_id as hospitalId,
  437. a.behospital_code as behospitalCode
  438. FROM
  439. med_behospital_info a,
  440. med_qcresult_info b
  441. WHERE
  442. a.is_deleted = 'N'
  443. AND b.is_deleted = 'N'
  444. AND a.hospital_id = b.hospital_id
  445. AND a.behospital_code = b.behospital_code
  446. AND <![CDATA[a.leave_hospital_date >= #{startDate}]]>
  447. AND <![CDATA[a.leave_hospital_date <= #{endDate}]]>
  448. AND a.is_placefile = 1
  449. <![CDATA[AND a.qc_type_id <>0 ]]>
  450. <if test="hospitalId != null and hospitalId != ''">
  451. AND a.hospital_id = #{hospitalId}
  452. </if>)f1
  453. <if test="flagStr != null and flagStr == 1 ">
  454. join med_lis_info f2
  455. on f2.is_deleted = 'N'
  456. AND f1.hospitalId = f2.hospital_id
  457. AND f1.behospitalCode = f2.behospital_code
  458. </if>
  459. <if test="flagStr != null and flagStr == 2">
  460. join med_doctor_advice f3
  461. on f3.is_deleted = 'N'
  462. AND f1.hospitalId = f3.hospital_id
  463. AND f1.behospitalCode = f3.behospital_code
  464. </if>
  465. <if test="flagStr != null and flagStr == 3">
  466. join med_qcresult_detail f4
  467. on f4.is_deleted = 'N'
  468. AND f1.hospitalId = f4.hospital_id
  469. AND f1.behospitalCode = f4.behospital_code
  470. AND f4.is_reject = 1
  471. </if>
  472. <if test="flagStr != null and flagStr == 4">
  473. join str_informed_consent f5
  474. on f5.is_deleted = 'N'
  475. AND f1.hospitalId = f5.hospital_id
  476. AND f1.behospitalCode = f5.behospital_code
  477. </if>
  478. </select>
  479. <!-- 各科室缺陷占比-全院-首页 -->
  480. <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
  481. resultType="com.diagbot.dto.NumDTO">
  482. SELECT
  483. a.beh_dept_id as id,
  484. a.beh_dept_name as name,
  485. count(*) AS num
  486. FROM
  487. med_behospital_info a,
  488. med_qcresult_info c,
  489. med_qcresult_detail d
  490. WHERE
  491. a.behospital_code = c.behospital_code
  492. AND a.hospital_id = c.hospital_id
  493. AND a.behospital_code = d.behospital_code
  494. AND a.hospital_id = d.hospital_id
  495. AND a.is_deleted = 'N'
  496. AND c.is_deleted = 'N'
  497. AND d.is_deleted = 'N'
  498. <if test="isPlacefile != null and isPlacefile != ''">
  499. and a.is_placefile = #{isPlacefile}
  500. </if>
  501. <![CDATA[AND a.qc_type_id <>0 ]]>
  502. <if test="hospitalId != null and hospitalId != ''">
  503. AND a.hospital_id = #{hospitalId}
  504. </if>
  505. <if test="isPlacefile != null and isPlacefile == 0">
  506. <if test="startDate != null and startDate != ''">
  507. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  508. </if>
  509. <if test="endDate != null and endDate != ''">
  510. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  511. </if>
  512. </if>
  513. <if test="isPlacefile != null and isPlacefile == 1">
  514. <if test="startDate != null and startDate != ''">
  515. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  516. </if>
  517. <if test="endDate != null and endDate != ''">
  518. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  519. </if>
  520. </if>
  521. GROUP BY
  522. a.beh_dept_id,
  523. a.beh_dept_name
  524. ORDER BY
  525. count(*) DESC
  526. </select>
  527. <!-- 质控结果缺陷总数查询-->
  528. <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  529. SELECT
  530. count(*) AS totle
  531. FROM
  532. med_behospital_info a,
  533. med_qcresult_info c,
  534. med_qcresult_detail d
  535. WHERE
  536. a.behospital_code = c.behospital_code
  537. AND a.hospital_id = c.hospital_id
  538. AND a.behospital_code = d.behospital_code
  539. AND a.hospital_id = d.hospital_id
  540. AND a.is_deleted = 'N'
  541. AND c.is_deleted = 'N'
  542. AND d.is_deleted = 'N'
  543. <if test="isPlacefile != null and isPlacefile != ''">
  544. and a.is_placefile = #{isPlacefile}
  545. </if>
  546. <![CDATA[AND a.qc_type_id <>0 ]]>
  547. <if test="hospitalId != null and hospitalId != ''">
  548. AND a.hospital_id = #{hospitalId}
  549. </if>
  550. <if test="isPlacefile != null and isPlacefile == 0">
  551. <if test="startDate != null and startDate != ''">
  552. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  553. </if>
  554. <if test="endDate != null and endDate != ''">
  555. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  556. </if>
  557. </if>
  558. <if test="isPlacefile != null and isPlacefile == 1">
  559. <if test="startDate != null and startDate != ''">
  560. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  561. </if>
  562. <if test="endDate != null and endDate != ''">
  563. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  564. </if>
  565. </if>
  566. </select>
  567. <!--获取病历-->
  568. <select id="getNoGrade" resultMap="BaseResultMap">
  569. select * from med_behospital_info a
  570. where a.is_deleted = 'N'
  571. and a.qc_type_id != 0
  572. <if test="isPlacefile != null and isPlacefile != ''">
  573. and a.is_placefile = #{isPlacefile}
  574. </if>
  575. <if test="filterFlag != null and filterFlag == 0">
  576. and
  577. not EXISTS (
  578. SELECT
  579. 1
  580. FROM
  581. med_qcresult_info b
  582. WHERE
  583. b.is_deleted = 'N'
  584. AND a.hospital_id = b.hospital_id
  585. AND a.behospital_code = b.behospital_code
  586. )
  587. </if>
  588. <if test="leaveDate != null">
  589. <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
  590. </if>
  591. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  592. and a.hospital_id in
  593. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  594. #{item}
  595. </foreach>
  596. </if>
  597. <if test="behospitalCodeList != null and behospitalCodeList.size > 0 ">
  598. and a.behospital_code in
  599. <foreach collection="behospitalCodeList" item="item" open="(" separator="," close=")">
  600. #{item}
  601. </foreach>
  602. </if>
  603. <if test="individuation != null and individuation.contains(1)">
  604. union
  605. select * from med_behospital_info b
  606. where b.is_deleted = 'N'
  607. and b.qc_type_id != 0
  608. <if test="isPlacefile != null and isPlacefile != ''">
  609. and b.is_placefile = #{isPlacefile}
  610. </if>
  611. <if test="startLeaveDate != null">
  612. <![CDATA[ and b.leave_hospital_date >= #{startLeaveDate}]]>
  613. </if>
  614. <if test="endLeaveDate != null">
  615. <![CDATA[ and b.leave_hospital_date <= #{endLeaveDate}]]>
  616. </if>
  617. <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
  618. and b.hospital_id in
  619. <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
  620. #{item}
  621. </foreach>
  622. </if>
  623. </if>
  624. </select>
  625. <!-- 出院总人数统计-全院-首页 -->
  626. <select id="leaveHosCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  627. SELECT
  628. COUNT(*)
  629. FROM
  630. med_behospital_info a
  631. WHERE
  632. a.is_deleted = 'N'
  633. and a.qc_type_id != 0
  634. <if test="isPlacefile != null and isPlacefile != ''">
  635. and a.is_placefile = #{isPlacefile}
  636. </if>
  637. <if test="hospitalId != null and hospitalId != ''">
  638. AND a.hospital_id = #{hospitalId}
  639. </if>
  640. <if test="isPlacefile != null and isPlacefile == 0">
  641. <if test="startDate != null and startDate != ''">
  642. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  643. </if>
  644. <if test="endDate != null and endDate != ''">
  645. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  646. </if>
  647. </if>
  648. <if test="isPlacefile != null and isPlacefile == 1">
  649. <if test="startDate != null and startDate != ''">
  650. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  651. </if>
  652. <if test="endDate != null and endDate != ''">
  653. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  654. </if>
  655. </if>
  656. </select>
  657. <!-- 新生儿出院人数统计-全院-首页 -->
  658. <select id="newBornCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  659. SELECT
  660. COUNT(*)
  661. FROM
  662. med_behospital_info a,
  663. med_home_page b
  664. WHERE
  665. a.is_deleted = 'N'
  666. AND b.is_deleted = 'N'
  667. AND a.hospital_id = b.hospital_id
  668. AND a.behospital_code = b.behospital_code
  669. <if test="isPlacefile != null and isPlacefile != ''">
  670. and a.is_placefile = #{isPlacefile}
  671. </if>
  672. AND (
  673. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-' AND b.newborn_day != '—')
  674. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  675. )
  676. <![CDATA[AND a.qc_type_id <>0 ]]>
  677. <if test="hospitalId != null and hospitalId != ''">
  678. AND a.hospital_id = #{hospitalId}
  679. </if>
  680. <if test="isPlacefile != null and isPlacefile == 0">
  681. <if test="startDate != null and startDate != ''">
  682. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  683. </if>
  684. <if test="endDate != null and endDate != ''">
  685. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  686. </if>
  687. </if>
  688. <if test="isPlacefile != null and isPlacefile == 1">
  689. <if test="startDate != null and startDate != ''">
  690. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  691. </if>
  692. <if test="endDate != null and endDate != ''">
  693. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  694. </if>
  695. </if>
  696. </select>
  697. <!-- 死亡人数统计-全院-首页 -->
  698. <select id="deathCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  699. select COUNT(*) from(
  700. SELECT distinct a.*
  701. FROM
  702. med_behospital_info a,
  703. med_medical_record b,
  704. med_medical_record_content c
  705. WHERE
  706. a.is_deleted = 'N'
  707. AND b.is_deleted = 'N'
  708. AND c.is_deleted = 'N'
  709. AND a.hospital_id = b.hospital_id
  710. AND a.hospital_id = c.hospital_id
  711. AND a.behospital_code = b.behospital_code
  712. AND b.rec_id = c.rec_id
  713. and b.mode_id = '24'
  714. <if test="isPlacefile != null and isPlacefile != ''">
  715. and a.is_placefile = #{isPlacefile}
  716. </if>
  717. <![CDATA[AND a.qc_type_id <>0 ]]>
  718. <if test="hospitalId != null and hospitalId != ''">
  719. AND a.hospital_id = #{hospitalId}
  720. </if>
  721. <if test="isPlacefile != null and isPlacefile == 0">
  722. <if test="startDate != null and startDate != ''">
  723. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  724. </if>
  725. <if test="endDate != null and endDate != ''">
  726. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  727. </if>
  728. </if>
  729. <if test="isPlacefile != null and isPlacefile == 1">
  730. <if test="startDate != null and startDate != ''">
  731. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  732. </if>
  733. <if test="endDate != null and endDate != ''">
  734. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  735. </if>
  736. </if>)m
  737. </select>
  738. <!-- 手术人数统计-全院-首页 -->
  739. <select id="operationCount" parameterType="com.diagbot.vo.FilterVO" resultType="int">
  740. SELECT
  741. COUNT( DISTINCT a.behospital_code )
  742. FROM
  743. med_behospital_info a,
  744. med_medical_record c,
  745. qc_mode d
  746. WHERE
  747. a.is_deleted = 'N'
  748. AND c.is_deleted = 'N'
  749. AND d.is_deleted = 'N'
  750. AND a.hospital_id = c.hospital_id
  751. AND a.behospital_code = c.behospital_code
  752. AND c.mode_id = d.id
  753. <if test="isPlacefile != null and isPlacefile != ''">
  754. and a.is_placefile = #{isPlacefile}
  755. </if>
  756. AND d.`name` = '手术记录'
  757. <![CDATA[AND a.qc_type_id <>0 ]]>
  758. <if test="hospitalId != null and hospitalId != ''">
  759. AND a.hospital_id = #{hospitalId}
  760. </if>
  761. <if test="isPlacefile != null and isPlacefile == 0">
  762. <if test="startDate != null and startDate != ''">
  763. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  764. </if>
  765. <if test="endDate != null and endDate != ''">
  766. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  767. </if>
  768. </if>
  769. <if test="isPlacefile != null and isPlacefile == 1">
  770. <if test="startDate != null and startDate != ''">
  771. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  772. </if>
  773. <if test="endDate != null and endDate != ''">
  774. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  775. </if>
  776. </if>
  777. </select>
  778. <!-- 入院人数统计-首页 -->
  779. <select id="beHosCount" parameterType="com.diagbot.vo.FilterVO"
  780. resultType="com.diagbot.dto.NumDTO">
  781. SELECT
  782. a.beh_dept_id AS id,
  783. a.beh_dept_name AS NAME,
  784. COUNT(*) AS num
  785. FROM
  786. med_behospital_info a
  787. WHERE
  788. a.is_deleted = 'N'
  789. and a.qc_type_id != 0
  790. <if test="isPlacefile != null and isPlacefile != ''">
  791. and a.is_placefile = #{isPlacefile}
  792. </if>
  793. <if test="hospitalId != null and hospitalId != ''">
  794. AND a.hospital_id = #{hospitalId}
  795. </if>
  796. <if test="isPlacefile != null and isPlacefile == 0">
  797. <if test="startDate != null and startDate != ''">
  798. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  799. </if>
  800. <if test="endDate != null and endDate != ''">
  801. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  802. </if>
  803. </if>
  804. <if test="isPlacefile != null and isPlacefile == 1">
  805. <if test="startDate != null and startDate != ''">
  806. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  807. </if>
  808. <if test="endDate != null and endDate != ''">
  809. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  810. </if>
  811. </if>
  812. GROUP BY
  813. a.beh_dept_id,
  814. a.beh_dept_name
  815. </select>
  816. <!-- 入院总人数统计-科室-首页 -->
  817. <select id="admissionHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
  818. resultType="com.diagbot.dto.AdmissionCountDTO">
  819. SELECT
  820. a.beh_dept_id as deptId,
  821. a.beh_dept_name as deptName,
  822. a.doctor_id as doctorId,
  823. a.doctor_name as doctorName,
  824. COUNT(*) AS num
  825. FROM
  826. med_behospital_info a,
  827. sys_user_dept c
  828. WHERE
  829. a.is_deleted = 'N'
  830. AND c.is_deleted = 'N'
  831. and a.qc_type_id != 0
  832. AND a.hospital_id = c.hospital_id
  833. AND a.beh_dept_id = c.dept_id
  834. <if test="isPlacefile != null and isPlacefile != ''">
  835. and a.is_placefile = #{isPlacefile}
  836. </if>
  837. <if test="userId!=null">
  838. AND c.user_id = #{userId}
  839. </if>
  840. <if test="hospitalId != null and hospitalId != ''">
  841. AND a.hospital_id = #{hospitalId}
  842. </if>
  843. <if test="isPlacefile != null and isPlacefile == 0">
  844. <if test="startDate != null and startDate != ''">
  845. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  846. </if>
  847. <if test="endDate != null and endDate != ''">
  848. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  849. </if>
  850. </if>
  851. <if test="isPlacefile != null and isPlacefile == 1">
  852. <if test="startDate != null and startDate != ''">
  853. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  854. </if>
  855. <if test="endDate != null and endDate != ''">
  856. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  857. </if>
  858. </if>
  859. GROUP BY
  860. a.beh_dept_id,
  861. a.beh_dept_name,
  862. a.doctor_id,
  863. a.doctor_name
  864. </select>
  865. <!-- 新生儿出院人数统计-科室-首页 -->
  866. <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
  867. resultType="com.diagbot.dto.NumDTO">
  868. SELECT
  869. a.beh_dept_id AS id,
  870. a.beh_dept_name AS NAME,
  871. COUNT(*) AS num
  872. FROM
  873. med_behospital_info a,
  874. med_home_page b,
  875. sys_user_dept c
  876. WHERE
  877. a.is_deleted = 'N'
  878. AND b.is_deleted = 'N'
  879. AND c.is_deleted = 'N'
  880. AND a.hospital_id = b.hospital_id
  881. AND a.hospital_id = c.hospital_id
  882. AND a.behospital_code = b.behospital_code
  883. AND a.beh_dept_id = c.dept_id
  884. AND (
  885. ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' AND b.newborn_day != '-'AND b.newborn_day != '—' )
  886. OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' AND b.newborn_month != '-' AND b.newborn_month != '—')
  887. )
  888. <if test="isPlacefile != null and isPlacefile != ''">
  889. and a.is_placefile = #{isPlacefile}
  890. </if>
  891. <![CDATA[AND a.qc_type_id <>0 ]]>
  892. <if test="userId!=null">
  893. AND c.user_id = #{userId}
  894. </if>
  895. <if test="hospitalId != null and hospitalId != ''">
  896. AND a.hospital_id = #{hospitalId}
  897. </if>
  898. <if test="isPlacefile != null and isPlacefile == 0">
  899. <if test="startDate != null and startDate != ''">
  900. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  901. </if>
  902. <if test="endDate != null and endDate != ''">
  903. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  904. </if>
  905. </if>
  906. <if test="isPlacefile != null and isPlacefile == 1">
  907. <if test="startDate != null and startDate != ''">
  908. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  909. </if>
  910. <if test="endDate != null and endDate != ''">
  911. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  912. </if>
  913. </if>
  914. GROUP BY
  915. a.beh_dept_id,
  916. a.beh_dept_name
  917. </select>
  918. <!-- 死亡人数统计-科室-首页 -->
  919. <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
  920. resultType="com.diagbot.dto.NumDTO">
  921. SELECT
  922. a.beh_dept_id AS id,
  923. a.beh_dept_name AS NAME,
  924. COUNT(*) AS num
  925. FROM
  926. med_behospital_info a,
  927. sys_user_dept c,
  928. med_medical_record d,
  929. med_medical_record_content e
  930. WHERE
  931. a.is_deleted = 'N'
  932. AND c.is_deleted = 'N'
  933. AND d.is_deleted = 'N'
  934. AND e.is_deleted = 'N'
  935. AND a.hospital_id = c.hospital_id
  936. AND a.hospital_id = d.hospital_id
  937. AND a.hospital_id = e.hospital_id
  938. AND a.behospital_code = d.behospital_code
  939. AND a.beh_dept_id = c.dept_id
  940. AND d.rec_id = e.rec_id
  941. AND d.mode_id = '24'
  942. <if test="isPlacefile != null and isPlacefile != ''">
  943. and a.is_placefile = #{isPlacefile}
  944. </if>
  945. <![CDATA[AND a.qc_type_id <>0 ]]>
  946. <if test="userId!=null">
  947. AND c.user_id = #{userId}
  948. </if>
  949. <if test="hospitalId != null and hospitalId != ''">
  950. AND a.hospital_id = #{hospitalId}
  951. </if>
  952. <if test="isPlacefile != null and isPlacefile == 0">
  953. <if test="startDate != null and startDate != ''">
  954. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  955. </if>
  956. <if test="endDate != null and endDate != ''">
  957. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  958. </if>
  959. </if>
  960. <if test="isPlacefile != null and isPlacefile == 1">
  961. <if test="startDate != null and startDate != ''">
  962. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  963. </if>
  964. <if test="endDate != null and endDate != ''">
  965. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  966. </if>
  967. </if>
  968. GROUP BY
  969. a.beh_dept_id,
  970. a.beh_dept_name
  971. </select>
  972. <!-- 手术人数统计-科室-首页 -->
  973. <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
  974. resultType="com.diagbot.dto.NumDTO">
  975. SELECT
  976. a.beh_dept_id AS id,
  977. a.beh_dept_name AS NAME,
  978. COUNT( DISTINCT a.behospital_code ) AS num
  979. FROM
  980. med_behospital_info a,
  981. sys_user_dept c,
  982. med_medical_record d,
  983. qc_mode e
  984. WHERE
  985. a.is_deleted = 'N'
  986. AND c.is_deleted = 'N'
  987. AND d.is_deleted = 'N'
  988. AND e.is_deleted = 'N'
  989. AND a.hospital_id = c.hospital_id
  990. AND a.hospital_id = d.hospital_id
  991. AND a.behospital_code = d.behospital_code
  992. AND a.beh_dept_id = c.dept_id
  993. AND d.mode_id = e.id
  994. AND e.`name` = '手术记录'
  995. <if test="isPlacefile != null and isPlacefile != ''">
  996. and a.is_placefile = #{isPlacefile}
  997. </if>
  998. <![CDATA[AND a.qc_type_id <>0 ]]>
  999. <if test="userId!=null">
  1000. AND c.user_id = #{userId}
  1001. </if>
  1002. <if test="hospitalId != null and hospitalId != ''">
  1003. AND a.hospital_id = #{hospitalId}
  1004. </if>
  1005. <if test="isPlacefile != null and isPlacefile == 0">
  1006. <if test="startDate != null and startDate != ''">
  1007. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1008. </if>
  1009. <if test="endDate != null and endDate != ''">
  1010. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1011. </if>
  1012. </if>
  1013. <if test="isPlacefile != null and isPlacefile == 1">
  1014. <if test="startDate != null and startDate != ''">
  1015. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1016. </if>
  1017. <if test="endDate != null and endDate != ''">
  1018. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1019. </if>
  1020. </if>
  1021. GROUP BY
  1022. a.beh_dept_id,
  1023. a.beh_dept_name
  1024. </select>
  1025. <!-- 各科室缺陷占比排行(分页) -->
  1026. <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
  1027. SELECT t.*
  1028. FROM
  1029. (SELECT
  1030. t1.beh_dept_name AS NAME,
  1031. t1.num AS num,
  1032. t2.totle AS totleNum,
  1033. round( t1.num / t2.totle, 4 ) AS percent,
  1034. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1035. FROM
  1036. (
  1037. SELECT
  1038. a.beh_dept_id,
  1039. a.beh_dept_name,
  1040. count(*) AS num
  1041. FROM
  1042. med_behospital_info a,
  1043. med_qcresult_info c,
  1044. med_qcresult_detail d
  1045. WHERE
  1046. a.behospital_code = c.behospital_code
  1047. AND a.hospital_id = c.hospital_id
  1048. AND a.behospital_code = d.behospital_code
  1049. AND a.hospital_id = d.hospital_id
  1050. AND a.is_deleted = 'N'
  1051. AND c.is_deleted = 'N'
  1052. AND d.is_deleted = 'N'
  1053. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1054. and a.is_placefile = #{filterPageVO.isPlacefile}
  1055. </if>
  1056. <![CDATA[AND a.qc_type_id <>0 ]]>
  1057. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1058. AND a.hospital_id = #{filterPageVO.hospitalId}
  1059. </if>
  1060. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1061. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1062. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1063. </if>
  1064. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1065. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1066. </if>
  1067. </if>
  1068. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1069. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1070. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1071. </if>
  1072. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1073. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1074. </if>
  1075. </if>
  1076. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1077. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1078. </if>
  1079. GROUP BY
  1080. a.beh_dept_id,
  1081. a.beh_dept_name
  1082. ORDER BY
  1083. count(*) DESC
  1084. ) t1,
  1085. (
  1086. SELECT
  1087. count(*) AS totle
  1088. FROM
  1089. med_behospital_info a,
  1090. med_qcresult_info c,
  1091. med_qcresult_detail d
  1092. WHERE
  1093. a.behospital_code = c.behospital_code
  1094. AND a.hospital_id = c.hospital_id
  1095. AND a.behospital_code = d.behospital_code
  1096. AND a.hospital_id = d.hospital_id
  1097. AND a.is_deleted = 'N'
  1098. AND c.is_deleted = 'N'
  1099. AND d.is_deleted = 'N'
  1100. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
  1101. and a.is_placefile = #{filterPageVO.isPlacefile}
  1102. </if>
  1103. <![CDATA[AND a.qc_type_id <>0 ]]>
  1104. <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
  1105. AND a.hospital_id = #{filterPageVO.hospitalId}
  1106. </if>
  1107. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 0">
  1108. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1109. <![CDATA[ AND a.behospital_date >= #{filterPageVO.startDate}]]>
  1110. </if>
  1111. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1112. <![CDATA[ AND a.behospital_date <= #{filterPageVO.endDate}]]>
  1113. </if>
  1114. </if>
  1115. <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile == 1">
  1116. <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
  1117. <![CDATA[ AND a.leave_hospital_date >= #{filterPageVO.startDate}]]>
  1118. </if>
  1119. <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
  1120. <![CDATA[ AND a.leave_hospital_date <= #{filterPageVO.endDate}]]>
  1121. </if>
  1122. </if>
  1123. <if test="filterPageVO.name != null and filterPageVO.name != ''">
  1124. AND a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
  1125. </if>
  1126. ) t2
  1127. )t
  1128. </select>
  1129. <!-- 科室缺陷占比(主任医生) -->
  1130. <select id="resultStatisticsByDeptAndDoctorPage" resultType="com.diagbot.dto.DeptNumDTO">
  1131. SELECT
  1132. t.*
  1133. FROM
  1134. (
  1135. SELECT
  1136. t1.NAME,
  1137. t1.num AS num,
  1138. t2.totle AS totleNum,
  1139. round( t1.num / t2.totle, 4 ) AS percent,
  1140. concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
  1141. FROM
  1142. (
  1143. SELECT
  1144. d.msg as name,
  1145. count(*) AS num
  1146. FROM
  1147. med_behospital_info a,
  1148. med_qcresult_info c,
  1149. med_qcresult_detail d,
  1150. sys_user_dept e
  1151. WHERE
  1152. a.behospital_code = c.behospital_code
  1153. AND a.hospital_id = c.hospital_id
  1154. AND a.behospital_code = d.behospital_code
  1155. AND a.hospital_id = d.hospital_id
  1156. AND a.is_deleted = 'N'
  1157. AND c.is_deleted = 'N'
  1158. AND d.is_deleted = 'N'
  1159. AND e.is_deleted = 'N'
  1160. AND a.beh_dept_id = e.dept_id
  1161. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1162. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1163. </if>
  1164. <![CDATA[AND a.qc_type_id <>0 ]]>
  1165. <if test="filterPageByDeptVO.userId!=null">
  1166. AND e.user_id = #{filterPageByDeptVO.userId}
  1167. </if>
  1168. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1169. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1170. </if>
  1171. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1172. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1173. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1174. </if>
  1175. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1176. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1177. </if>
  1178. </if>
  1179. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1180. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1181. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1182. </if>
  1183. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1184. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1185. </if>
  1186. </if>
  1187. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1188. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1189. </if>
  1190. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1191. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1192. </if>
  1193. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1194. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1195. </if>
  1196. GROUP BY
  1197. d.msg
  1198. ORDER BY
  1199. count(*) DESC
  1200. ) t1,
  1201. (
  1202. SELECT
  1203. count(*) AS totle
  1204. FROM
  1205. med_behospital_info a,
  1206. med_qcresult_info c,
  1207. med_qcresult_detail d,
  1208. sys_user_dept e
  1209. WHERE
  1210. a.behospital_code = c.behospital_code
  1211. AND a.hospital_id = c.hospital_id
  1212. AND a.behospital_code = d.behospital_code
  1213. AND a.hospital_id = d.hospital_id
  1214. AND a.is_deleted = 'N'
  1215. AND c.is_deleted = 'N'
  1216. AND d.is_deleted = 'N'
  1217. AND e.is_deleted = 'N'
  1218. AND a.beh_dept_id = e.dept_id
  1219. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile != ''">
  1220. and a.is_placefile = #{filterPageByDeptVO.isPlacefile}
  1221. </if>
  1222. <![CDATA[AND a.qc_type_id <>0 ]]>
  1223. <if test="filterPageByDeptVO.userId!=null">
  1224. AND e.user_id = #{filterPageByDeptVO.userId}
  1225. </if>
  1226. <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
  1227. AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
  1228. </if>
  1229. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 0">
  1230. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1231. <![CDATA[ AND a.behospital_date >= #{filterPageByDeptVO.startDate}]]>
  1232. </if>
  1233. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1234. <![CDATA[ AND a.behospital_date <= #{filterPageByDeptVO.endDate}]]>
  1235. </if>
  1236. </if>
  1237. <if test="filterPageByDeptVO.isPlacefile != null and filterPageByDeptVO.isPlacefile == 1">
  1238. <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
  1239. <![CDATA[ AND a.leave_hospital_date >= #{filterPageByDeptVO.startDate}]]>
  1240. </if>
  1241. <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
  1242. <![CDATA[ AND a.leave_hospital_date <= #{filterPageByDeptVO.endDate}]]>
  1243. </if>
  1244. </if>
  1245. <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
  1246. AND d.msg like CONCAT('%', #{filterPageByDeptVO.name},'%')
  1247. </if>
  1248. <if test="filterPageByDeptVO.doctorName != null and filterPageByDeptVO.doctorName != ''">
  1249. AND a.doctor_name = #{filterPageByDeptVO.doctorName}
  1250. </if>
  1251. <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
  1252. AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
  1253. </if>
  1254. ) t2
  1255. )t
  1256. </select>
  1257. <!-- 各科室缺陷占比(组合)-全院 -->
  1258. <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
  1259. resultType="com.diagbot.dto.LevelStatisticsDTO">
  1260. SELECT
  1261. m1.deptId,
  1262. m1.deptName,
  1263. m1.entryNum,
  1264. m2.sameNum,
  1265. m1.mrNum,
  1266. m2.sameMrNum,
  1267. m1.totleValue,
  1268. m2.sameTotleValue,
  1269. m1.averageValue,
  1270. m2.sameAvgValue,
  1271. m1.firstLevelNum,
  1272. m2.sameFirstLevelNum,
  1273. m1.secondLevelNum,
  1274. m2.sameSecondLevelNum,
  1275. m1.thirdLevelNum,
  1276. m2.sameThirdLevelNum,
  1277. m1.firstLevelPercent,
  1278. m2.sameFirstLevelPercent,
  1279. m1.secondLevelPercent,
  1280. m2.sameSecondLevelPercent,
  1281. m1.thirdLevelPercent,
  1282. m2.sameThirdLevelPercent,
  1283. m1.firstLevelPercentStr,
  1284. m2.sameFirstLevelPercentStr,
  1285. m1.secondLevelPercentStr,
  1286. m2.sameSecondLevelPercentStr,
  1287. m1.thirdLevelPercentStr,
  1288. m2.sameThirdLevelPercentStr
  1289. FROM
  1290. (
  1291. SELECT
  1292. t1.deptId,
  1293. t1.deptName,
  1294. t2.entryNum,
  1295. t1.mrNum,
  1296. t1.totleValue,
  1297. t1.averageValue,
  1298. t1.firstLevelNum,
  1299. t1.secondLevelNum,
  1300. t1.thirdLevelNum,
  1301. t1.firstLevelPercent,
  1302. t1.secondLevelPercent,
  1303. t1.thirdLevelPercent,
  1304. t1.firstLevelPercentStr,
  1305. t1.secondLevelPercentStr,
  1306. t1.thirdLevelPercentStr
  1307. FROM
  1308. (
  1309. SELECT
  1310. a.beh_dept_id AS deptId,
  1311. a.beh_dept_name AS deptName,
  1312. count(*) AS mrNum,
  1313. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1314. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1315. SUM( c.`level` = '甲' ) AS firstLevelNum,
  1316. SUM( c.`level` = '乙' ) AS secondLevelNum,
  1317. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  1318. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  1319. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  1320. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  1321. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1322. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1323. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1324. FROM
  1325. med_behospital_info a,
  1326. med_qcresult_info c
  1327. WHERE
  1328. a.is_deleted = 'N'
  1329. AND c.is_deleted = 'N'
  1330. AND a.hospital_id = c.hospital_id
  1331. AND a.behospital_code = c.behospital_code
  1332. <if test="isPlacefile != null and isPlacefile != ''">
  1333. and a.is_placefile = #{isPlacefile}
  1334. </if>
  1335. AND a.qc_type_id != 0
  1336. <if test="hospitalId != null and hospitalId != ''">
  1337. AND a.hospital_id = #{hospitalId}
  1338. </if>
  1339. <if test="isPlacefile != null and isPlacefile == 0">
  1340. <if test="startDate != null and startDate != ''">
  1341. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1342. </if>
  1343. <if test="endDate != null and endDate != ''">
  1344. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1345. </if>
  1346. </if>
  1347. <if test="isPlacefile != null and isPlacefile == 1">
  1348. <if test="startDate != null and startDate != ''">
  1349. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1350. </if>
  1351. <if test="endDate != null and endDate != ''">
  1352. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1353. </if>
  1354. </if>
  1355. <if test="level != null and level != ''">
  1356. and c.level = #{level}
  1357. </if>
  1358. <if test="deptName != null and deptName != ''">
  1359. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1360. </if>
  1361. GROUP BY
  1362. a.beh_dept_id,
  1363. a.beh_dept_name
  1364. ) t1,
  1365. (
  1366. SELECT
  1367. a.beh_dept_id AS deptId,
  1368. a.beh_dept_name AS deptName,
  1369. count( * ) AS entryNum
  1370. FROM
  1371. med_behospital_info a,
  1372. med_qcresult_info c,
  1373. med_qcresult_detail d,
  1374. qc_cases_entry e
  1375. WHERE
  1376. a.is_deleted = 'N'
  1377. AND c.is_deleted = 'N'
  1378. AND d.is_deleted = 'N'
  1379. AND e.is_deleted = 'N'
  1380. AND a.hospital_id = c.hospital_id
  1381. AND a.hospital_id = d.hospital_id
  1382. AND a.behospital_code = c.behospital_code
  1383. AND a.behospital_code = d.behospital_code
  1384. AND d.cases_id = e.cases_id
  1385. AND d.cases_entry_id = e.id
  1386. <if test="isPlacefile != null and isPlacefile != ''">
  1387. and a.is_placefile = #{isPlacefile}
  1388. </if>
  1389. AND a.qc_type_id != 0
  1390. <if test="hospitalId != null and hospitalId != ''">
  1391. AND a.hospital_id = #{hospitalId}
  1392. </if>
  1393. <if test="isPlacefile != null and isPlacefile == 0">
  1394. <if test="startDate != null and startDate != ''">
  1395. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1396. </if>
  1397. <if test="endDate != null and endDate != ''">
  1398. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1399. </if>
  1400. </if>
  1401. <if test="isPlacefile != null and isPlacefile == 1">
  1402. <if test="startDate != null and startDate != ''">
  1403. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1404. </if>
  1405. <if test="endDate != null and endDate != ''">
  1406. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1407. </if>
  1408. </if>
  1409. <if test="level != null and level != ''">
  1410. and c.level = #{level}
  1411. </if>
  1412. <if test="deptName != null and deptName != ''">
  1413. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1414. </if>
  1415. GROUP BY
  1416. a.beh_dept_id,
  1417. a.beh_dept_name
  1418. ) t2
  1419. WHERE
  1420. t1.deptId = t2.deptId
  1421. AND t1.deptName = t2.deptName)m1 left join
  1422. ( SELECT
  1423. t1.deptId,
  1424. t1.deptName,
  1425. t2.entryNum as sameNum,
  1426. t1.mrNum as sameMrNum,
  1427. t1.totleValue as sameTotleValue,
  1428. t1.averageValue as sameAvgValue,
  1429. t1.firstLevelNum as sameFirstLevelNum,
  1430. t1.secondLevelNum as sameSecondLevelNum,
  1431. t1.thirdLevelNum as sameThirdLevelNum,
  1432. t1.firstLevelPercent as sameFirstLevelPercent,
  1433. t1.secondLevelPercent as sameSecondLevelPercent,
  1434. t1.thirdLevelPercent as sameThirdLevelPercent,
  1435. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  1436. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  1437. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  1438. FROM
  1439. (
  1440. SELECT
  1441. a.beh_dept_id AS deptId,
  1442. a.beh_dept_name AS deptName,
  1443. count(*) AS mrNum,
  1444. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1445. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1446. SUM( c.`level` = '甲' ) AS firstLevelNum,
  1447. SUM( c.`level` = '乙' ) AS secondLevelNum,
  1448. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  1449. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  1450. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  1451. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  1452. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1453. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1454. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1455. FROM
  1456. med_behospital_info a,
  1457. med_qcresult_info c
  1458. WHERE
  1459. a.is_deleted = 'N'
  1460. AND c.is_deleted = 'N'
  1461. AND a.hospital_id = c.hospital_id
  1462. AND a.behospital_code = c.behospital_code
  1463. <if test="isPlacefile != null and isPlacefile != ''">
  1464. and a.is_placefile = #{isPlacefile}
  1465. </if>
  1466. AND a.qc_type_id != 0
  1467. <if test="hospitalId != null and hospitalId != ''">
  1468. AND a.hospital_id = #{hospitalId}
  1469. </if>
  1470. <if test="isPlacefile != null and isPlacefile == 0">
  1471. <if test="lastStartDate != null and lastStartDate != ''">
  1472. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  1473. </if>
  1474. <if test="lastEndDate != null and lastEndDate != ''">
  1475. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  1476. </if>
  1477. </if>
  1478. <if test="isPlacefile != null and isPlacefile == 1">
  1479. <if test="lastStartDate != null and lastStartDate != ''">
  1480. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  1481. </if>
  1482. <if test="lastEndDate != null and lastEndDate != ''">
  1483. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  1484. </if>
  1485. </if>
  1486. <if test="level != null and level != ''">
  1487. and c.level = #{level}
  1488. </if>
  1489. <if test="deptName != null and deptName != ''">
  1490. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1491. </if>
  1492. GROUP BY
  1493. a.beh_dept_id,
  1494. a.beh_dept_name
  1495. ) t1,
  1496. (
  1497. SELECT
  1498. a.beh_dept_id AS deptId,
  1499. a.beh_dept_name AS deptName,
  1500. count( * ) AS entryNum
  1501. FROM
  1502. med_behospital_info a,
  1503. med_qcresult_info c,
  1504. med_qcresult_detail d,
  1505. qc_cases_entry e
  1506. WHERE
  1507. a.is_deleted = 'N'
  1508. AND c.is_deleted = 'N'
  1509. AND d.is_deleted = 'N'
  1510. AND e.is_deleted = 'N'
  1511. AND a.hospital_id = c.hospital_id
  1512. AND a.hospital_id = d.hospital_id
  1513. AND a.behospital_code = c.behospital_code
  1514. AND a.behospital_code = d.behospital_code
  1515. AND d.cases_id = e.cases_id
  1516. AND d.cases_entry_id = e.id
  1517. <if test="isPlacefile != null and isPlacefile != ''">
  1518. and a.is_placefile = #{isPlacefile}
  1519. </if>
  1520. AND a.qc_type_id != 0
  1521. <if test="hospitalId != null and hospitalId != ''">
  1522. AND a.hospital_id = #{hospitalId}
  1523. </if>
  1524. <if test="isPlacefile != null and isPlacefile == 0">
  1525. <if test="lastStartDate != null and lastStartDate != ''">
  1526. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  1527. </if>
  1528. <if test="lastEndDate != null and lastEndDate != ''">
  1529. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  1530. </if>
  1531. </if>
  1532. <if test="isPlacefile != null and isPlacefile == 1">
  1533. <if test="lastStartDate != null and lastStartDate != ''">
  1534. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  1535. </if>
  1536. <if test="lastEndDate != null and lastEndDate != ''">
  1537. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  1538. </if>
  1539. </if>
  1540. <if test="level != null and level != ''">
  1541. and c.level = #{level}
  1542. </if>
  1543. <if test="deptName != null and deptName != ''">
  1544. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1545. </if>
  1546. GROUP BY
  1547. a.beh_dept_id,
  1548. a.beh_dept_name
  1549. ) t2
  1550. WHERE
  1551. t1.deptId = t2.deptId
  1552. AND t1.deptName = t2.deptName)m2
  1553. on
  1554. m1.deptId = m2.deptId
  1555. AND m1.deptName = m2.deptName
  1556. <if test="asc != null and asc !=''">
  1557. order by
  1558. <choose>
  1559. <when test='asc=="deptId"'>m1.deptId asc</when>
  1560. <when test='asc=="deptName"'>m1.deptName asc</when>
  1561. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  1562. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  1563. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  1564. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  1565. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  1566. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  1567. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  1568. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  1569. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  1570. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  1571. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  1572. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  1573. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  1574. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  1575. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  1576. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  1577. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  1578. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  1579. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  1580. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  1581. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  1582. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  1583. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  1584. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  1585. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  1586. <otherwise>deptName asc</otherwise>
  1587. </choose>
  1588. </if>
  1589. <if test="desc != null and desc!=''">
  1590. order by
  1591. <choose>
  1592. <when test='desc=="deptId"'>m1.deptId desc</when>
  1593. <when test='desc=="deptName"'>m1.deptName desc</when>
  1594. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  1595. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  1596. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  1597. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  1598. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  1599. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  1600. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  1601. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  1602. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  1603. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  1604. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  1605. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  1606. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  1607. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  1608. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  1609. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  1610. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  1611. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  1612. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  1613. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  1614. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  1615. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  1616. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  1617. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  1618. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  1619. <otherwise>deptName desc</otherwise>
  1620. </choose>
  1621. </if>
  1622. </select>
  1623. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
  1624. <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
  1625. resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  1626. SELECT
  1627. t1.deptId,
  1628. t1.deptName,
  1629. t1.deptClassId,
  1630. t1.deptClass,
  1631. t2.entryNum,
  1632. t1.mrNum,
  1633. t1.totleValue,
  1634. t1.averageValue,
  1635. t1.firstLevelNum,
  1636. t1.secondLevelNum,
  1637. t1.thirdLevelNum,
  1638. t1.firstLevelPercent,
  1639. t1.secondLevelPercent,
  1640. t1.thirdLevelPercent,
  1641. t1.firstLevelPercentStr,
  1642. t1.secondLevelPercentStr,
  1643. t1.thirdLevelPercentStr
  1644. FROM
  1645. (
  1646. SELECT
  1647. a.beh_dept_id AS deptId,
  1648. a.beh_dept_name AS deptName,
  1649. e.dept_id AS deptClassId,
  1650. e.dept_name AS deptClass,
  1651. count( DISTINCT c.id ) AS mrNum,
  1652. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1653. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
  1654. COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
  1655. COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
  1656. COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
  1657. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
  1658. ) AS firstLevelPercent,
  1659. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
  1660. ) AS secondLevelPercent,
  1661. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
  1662. ) AS thirdLevelPercent,
  1663. concat(
  1664. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
  1665. 100, 2 ),
  1666. '%'
  1667. ) AS firstLevelPercentStr,
  1668. concat(
  1669. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
  1670. 100, 2 ),
  1671. '%'
  1672. ) AS secondLevelPercentStr,
  1673. concat(
  1674. ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
  1675. 100, 2 ),
  1676. '%'
  1677. ) AS thirdLevelPercentStr
  1678. FROM
  1679. med_behospital_info a,
  1680. med_qcresult_info c,
  1681. bas_dept_info d,
  1682. bas_dept_info e
  1683. WHERE
  1684. a.is_deleted = 'N'
  1685. AND c.is_deleted = 'N'
  1686. AND d.is_deleted = 'N'
  1687. AND e.is_deleted = 'N'
  1688. AND a.hospital_id = c.hospital_id
  1689. AND a.hospital_id = d.hospital_id
  1690. AND a.hospital_id = e.hospital_id
  1691. AND a.behospital_code = c.behospital_code
  1692. AND a.beh_dept_id = d.dept_id
  1693. AND d.parent_dept_id = e.dept_id
  1694. <if test="isPlacefile != null and isPlacefile != ''">
  1695. and a.is_placefile = #{isPlacefile}
  1696. </if>
  1697. <![CDATA[AND a.qc_type_id <>0 ]]>
  1698. <if test="hospitalId != null and hospitalId != ''">
  1699. AND a.hospital_id = #{hospitalId}
  1700. </if>
  1701. <if test="isPlacefile != null and isPlacefile == 0">
  1702. <if test="startDate != null and startDate != ''">
  1703. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1704. </if>
  1705. <if test="endDate != null and endDate != ''">
  1706. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1707. </if>
  1708. </if>
  1709. <if test="isPlacefile != null and isPlacefile == 1">
  1710. <if test="startDate != null and startDate != ''">
  1711. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1712. </if>
  1713. <if test="endDate != null and endDate != ''">
  1714. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1715. </if>
  1716. </if>
  1717. <if test="level != null and level != ''">
  1718. and c.level = #{level}
  1719. </if>
  1720. <if test="deptName != null and deptName != ''">
  1721. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1722. </if>
  1723. <if test="deptClass != null and deptClass != ''">
  1724. and e.dept_name = #{deptClass}
  1725. </if>
  1726. GROUP BY
  1727. a.beh_dept_id,
  1728. a.beh_dept_name,
  1729. e.dept_id,
  1730. e.dept_name
  1731. ) t1,
  1732. (
  1733. SELECT
  1734. a.beh_dept_id AS deptId,
  1735. a.beh_dept_name AS deptName,
  1736. g.dept_id AS deptClassId,
  1737. g.dept_name AS deptClass,
  1738. count( * ) AS entryNum
  1739. FROM
  1740. med_behospital_info a,
  1741. med_qcresult_info c,
  1742. med_qcresult_detail d,
  1743. qc_cases_entry e,
  1744. bas_dept_info f,
  1745. bas_dept_info g
  1746. WHERE
  1747. a.is_deleted = 'N'
  1748. AND c.is_deleted = 'N'
  1749. AND d.is_deleted = 'N'
  1750. AND e.is_deleted = 'N'
  1751. AND f.is_deleted = 'N'
  1752. AND g.is_deleted = 'N'
  1753. AND a.hospital_id = c.hospital_id
  1754. AND a.hospital_id = d.hospital_id
  1755. AND a.hospital_id = f.hospital_id
  1756. AND a.hospital_id = g.hospital_id
  1757. AND a.behospital_code = c.behospital_code
  1758. AND a.behospital_code = d.behospital_code
  1759. AND d.cases_id = e.cases_id
  1760. AND d.cases_entry_id = e.id
  1761. AND a.beh_dept_id = f.dept_id
  1762. AND f.parent_dept_id = g.dept_id
  1763. <if test="isPlacefile != null and isPlacefile != ''">
  1764. and a.is_placefile = #{isPlacefile}
  1765. </if>
  1766. <![CDATA[AND a.qc_type_id <>0 ]]>
  1767. <if test="hospitalId != null and hospitalId != ''">
  1768. AND a.hospital_id = #{hospitalId}
  1769. </if>
  1770. <if test="isPlacefile != null and isPlacefile == 0">
  1771. <if test="startDate != null and startDate != ''">
  1772. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1773. </if>
  1774. <if test="endDate != null and endDate != ''">
  1775. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1776. </if>
  1777. </if>
  1778. <if test="isPlacefile != null and isPlacefile == 1">
  1779. <if test="startDate != null and startDate != ''">
  1780. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1781. </if>
  1782. <if test="endDate != null and endDate != ''">
  1783. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1784. </if>
  1785. </if>
  1786. <if test="level != null and level != ''">
  1787. and c.level = #{level}
  1788. </if>
  1789. <if test="deptName != null and deptName != ''">
  1790. and a.beh_dept_name like CONCAT('%',#{deptName},'%')
  1791. </if>
  1792. <if test="deptClass != null and deptClass != ''">
  1793. and g.dept_name = #{deptClass}
  1794. </if>
  1795. GROUP BY
  1796. a.beh_dept_id,
  1797. a.beh_dept_name,
  1798. g.dept_id,
  1799. g.dept_name
  1800. ) t2
  1801. WHERE
  1802. t1.deptId = t2.deptId
  1803. AND t1.deptName = t2.deptName
  1804. AND t1.deptClassId = t2.deptClassId
  1805. AND t1.deptClass = t2.deptClass
  1806. <if test="asc != null and asc !=''">
  1807. order by
  1808. <choose>
  1809. <when test='asc=="deptId"'>deptId asc</when>
  1810. <when test='asc=="deptName"'>deptName asc</when>
  1811. <when test='asc=="deptClassId"'>deptClassId asc</when>
  1812. <when test='asc=="deptClass"'>deptClass asc</when>
  1813. <when test='asc=="entryNum"'>entryNum asc</when>
  1814. <when test='asc=="mrNum"'>mrNum asc</when>
  1815. <when test='asc=="totleValue"'>totleValue asc</when>
  1816. <when test='asc=="averageValue"'>averageValue asc</when>
  1817. <when test='asc=="firstLevelNum"'>firstLevelNum asc</when>
  1818. <when test='asc=="secondLevelNum"'>secondLevelNum asc</when>
  1819. <when test='asc=="thirdLevelNum"'>thirdLevelNum asc</when>
  1820. <when test='asc=="firstLevelPercent"'>firstLevelPercent asc</when>
  1821. <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
  1822. <when test='asc=="thirdLevelPercent"'>thirdLevelPercent asc</when>
  1823. <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
  1824. <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
  1825. <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
  1826. <otherwise>deptName asc</otherwise>
  1827. </choose>
  1828. </if>
  1829. <if test="desc != null and desc!=''">
  1830. order by
  1831. <choose>
  1832. <when test='desc=="deptId"'>deptId desc</when>
  1833. <when test='desc=="deptName"'>deptName desc</when>
  1834. <when test='desc=="deptClassId"'>deptClassId desc</when>
  1835. <when test='desc=="deptClass"'>deptClass desc</when>
  1836. <when test='desc=="entryNum"'>entryNum desc</when>
  1837. <when test='desc=="mrNum"'>mrNum desc</when>
  1838. <when test='desc=="totleValue"'>totleValue desc</when>
  1839. <when test='desc=="averageValue"'>averageValue desc</when>
  1840. <when test='desc=="firstLevelNum"'>firstLevelNum desc</when>
  1841. <when test='desc=="secondLevelNum"'>secondLevelNum desc</when>
  1842. <when test='desc=="thirdLevelNum"'>thirdLevelNum desc</when>
  1843. <when test='desc=="firstLevelPercent"'>firstLevelPercent desc</when>
  1844. <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
  1845. <when test='desc=="thirdLevelPercent"'>thirdLevelPercent desc</when>
  1846. <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
  1847. <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
  1848. <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
  1849. <otherwise>deptName desc</otherwise>
  1850. </choose>
  1851. </if>
  1852. </select>
  1853. <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
  1854. <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
  1855. select
  1856. m1.deptId,
  1857. m1.deptName,
  1858. m1.deptClassId,
  1859. m1.deptClass,
  1860. m1.entryNum,
  1861. m2.sameNum,
  1862. m1.mrNum,
  1863. m2.sameMrNum,
  1864. m1.totleValue,
  1865. m2.sameTotleValue,
  1866. m1.averageValue,
  1867. m2.sameAvgValue,
  1868. m1.firstLevelNum,
  1869. m2.sameFirstLevelNum,
  1870. m1.secondLevelNum,
  1871. m2.sameSecondLevelNum,
  1872. m1.thirdLevelNum,
  1873. m2.sameThirdLevelNum,
  1874. m1.firstLevelPercent,
  1875. m2.sameFirstLevelPercent,
  1876. m1.secondLevelPercent,
  1877. m2.sameSecondLevelPercent,
  1878. m1.thirdLevelPercent,
  1879. m2.sameThirdLevelPercent,
  1880. m1.firstLevelPercentStr,
  1881. m2.sameFirstLevelPercentStr,
  1882. m1.secondLevelPercentStr,
  1883. m2.sameSecondLevelPercentStr,
  1884. m1.thirdLevelPercentStr,
  1885. m2.sameThirdLevelPercentStr
  1886. from (
  1887. SELECT
  1888. t1.deptId,
  1889. t1.deptName,
  1890. t1.deptClassId,
  1891. t1.deptClass,
  1892. t2.entryNum,
  1893. t1.mrNum,
  1894. t1.totleValue,
  1895. t1.averageValue,
  1896. t1.firstLevelNum,
  1897. t1.secondLevelNum,
  1898. t1.thirdLevelNum,
  1899. t1.firstLevelPercent,
  1900. t1.secondLevelPercent,
  1901. t1.thirdLevelPercent,
  1902. t1.firstLevelPercentStr,
  1903. t1.secondLevelPercentStr,
  1904. t1.thirdLevelPercentStr
  1905. FROM
  1906. (
  1907. SELECT
  1908. tt1.deptId,
  1909. tt1.deptName,
  1910. e.dept_id AS deptClassId,
  1911. e.dept_name AS deptClass,
  1912. count(*) AS mrNum,
  1913. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  1914. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  1915. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  1916. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  1917. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  1918. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  1919. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  1920. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  1921. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  1922. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  1923. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  1924. FROM
  1925. (
  1926. SELECT
  1927. a.beh_dept_id AS deptId,
  1928. a.beh_dept_name AS deptName,
  1929. d.parent_dept_id AS parentDeptId,
  1930. a.hospital_id AS hospitalId,
  1931. a.behospital_code AS behospitalCode,
  1932. c.score_res AS score,
  1933. c.LEVEL
  1934. FROM
  1935. med_behospital_info a,
  1936. med_qcresult_info c,
  1937. bas_dept_info d
  1938. WHERE
  1939. a.is_deleted = 'N'
  1940. AND c.is_deleted = 'N'
  1941. AND d.is_deleted = 'N'
  1942. AND a.hospital_id = c.hospital_id
  1943. AND a.hospital_id = d.hospital_id
  1944. AND a.behospital_code = c.behospital_code
  1945. AND a.beh_dept_id = d.dept_id
  1946. <if test="isPlacefile != null and isPlacefile != ''">
  1947. and a.is_placefile = #{isPlacefile}
  1948. </if>
  1949. AND a.qc_type_id != 0
  1950. <if test="hospitalId != null and hospitalId != ''">
  1951. AND a.hospital_id = #{hospitalId}
  1952. </if>
  1953. <if test="isPlacefile != null and isPlacefile == 0">
  1954. <if test="startDate != null and startDate != ''">
  1955. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  1956. </if>
  1957. <if test="endDate != null and endDate != ''">
  1958. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  1959. </if>
  1960. </if>
  1961. <if test="isPlacefile != null and isPlacefile == 1">
  1962. <if test="startDate != null and startDate != ''">
  1963. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  1964. </if>
  1965. <if test="endDate != null and endDate != ''">
  1966. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  1967. </if>
  1968. </if>
  1969. <if test="level != null and level != ''">
  1970. and c.level = #{level}
  1971. </if>
  1972. <if test="deptName != null and deptName != ''">
  1973. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  1974. </if>
  1975. ) tt1
  1976. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  1977. AND e.is_deleted = 'N'
  1978. AND tt1.hospitalId = e.hospital_id
  1979. <if test="deptClass != null and deptClass != ''">
  1980. WHERE e.dept_name = #{deptClass}
  1981. </if>
  1982. GROUP BY
  1983. tt1.deptId,
  1984. tt1.deptName,
  1985. e.dept_id,
  1986. e.dept_name
  1987. ) t1,
  1988. (
  1989. SELECT
  1990. tt2.deptId,
  1991. tt2.deptName,
  1992. g.dept_id AS deptClassId,
  1993. g.dept_name AS deptClass,
  1994. count( * ) AS entryNum
  1995. FROM
  1996. (
  1997. SELECT
  1998. a.beh_dept_id AS deptId,
  1999. a.beh_dept_name AS deptName,
  2000. f.parent_dept_id AS parentDeptId,
  2001. a.hospital_id AS hospitalId,
  2002. a.behospital_code AS behospitalCode
  2003. FROM
  2004. med_behospital_info a,
  2005. med_qcresult_info c,
  2006. med_qcresult_detail d,
  2007. qc_cases_entry e,
  2008. bas_dept_info f
  2009. WHERE
  2010. a.is_deleted = 'N'
  2011. AND c.is_deleted = 'N'
  2012. AND d.is_deleted = 'N'
  2013. AND e.is_deleted = 'N'
  2014. AND f.is_deleted = 'N'
  2015. AND a.hospital_id = c.hospital_id
  2016. AND a.hospital_id = d.hospital_id
  2017. AND a.hospital_id = f.hospital_id
  2018. AND a.behospital_code = c.behospital_code
  2019. AND a.behospital_code = d.behospital_code
  2020. AND d.cases_id = e.cases_id
  2021. AND d.cases_entry_id = e.id
  2022. AND a.beh_dept_id = f.dept_id
  2023. <if test="isPlacefile != null and isPlacefile != ''">
  2024. and a.is_placefile = #{isPlacefile}
  2025. </if>
  2026. AND a.qc_type_id != 0
  2027. <if test="hospitalId != null and hospitalId != ''">
  2028. AND a.hospital_id = #{hospitalId}
  2029. </if>
  2030. <if test="isPlacefile != null and isPlacefile == 0">
  2031. <if test="startDate != null and startDate != ''">
  2032. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2033. </if>
  2034. <if test="endDate != null and endDate != ''">
  2035. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2036. </if>
  2037. </if>
  2038. <if test="isPlacefile != null and isPlacefile == 1">
  2039. <if test="startDate != null and startDate != ''">
  2040. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2041. </if>
  2042. <if test="endDate != null and endDate != ''">
  2043. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2044. </if>
  2045. </if>
  2046. <if test="level != null and level != ''">
  2047. and c.level = #{level}
  2048. </if>
  2049. <if test="deptName != null and deptName != ''">
  2050. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2051. </if>
  2052. ) tt2
  2053. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2054. AND g.is_deleted = 'N'
  2055. AND tt2.hospitalId = g.hospital_id
  2056. <if test="deptClass != null and deptClass != ''">
  2057. WHERE g.dept_name = #{deptClass}
  2058. </if>
  2059. GROUP BY
  2060. tt2.deptId,
  2061. tt2.deptName,
  2062. g.dept_id,
  2063. g.dept_name
  2064. ) t2
  2065. WHERE
  2066. t1.deptId = t2.deptId
  2067. AND t1.deptName = t2.deptName)m1 left join
  2068. ( SELECT
  2069. t1.deptId,
  2070. t1.deptName,
  2071. t1.deptClassId,
  2072. t1.deptClass,
  2073. t2.entryNum as sameNum,
  2074. t1.mrNum as sameMrNum,
  2075. t1.totleValue as sameTotleValue,
  2076. t1.averageValue as sameAvgValue,
  2077. t1.firstLevelNum as sameFirstLevelNum,
  2078. t1.secondLevelNum as sameSecondLevelNum,
  2079. t1.thirdLevelNum as sameThirdLevelNum,
  2080. t1.firstLevelPercent as sameFirstLevelPercent,
  2081. t1.secondLevelPercent as sameSecondLevelPercent,
  2082. t1.thirdLevelPercent as sameThirdLevelPercent,
  2083. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2084. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2085. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2086. FROM
  2087. (
  2088. SELECT
  2089. tt1.deptId,
  2090. tt1.deptName,
  2091. e.dept_id AS deptClassId,
  2092. e.dept_name AS deptClass,
  2093. count(*) AS mrNum,
  2094. ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2095. ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2096. sum( tt1.`level` = '甲' ) AS firstLevelNum,
  2097. sum( tt1.`level` = '乙' ) AS secondLevelNum,
  2098. sum( tt1.`level` = '丙' ) AS thirdLevelNum,
  2099. ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
  2100. ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
  2101. ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
  2102. concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2103. concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2104. concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2105. FROM
  2106. (
  2107. SELECT
  2108. a.beh_dept_id AS deptId,
  2109. a.beh_dept_name AS deptName,
  2110. d.parent_dept_id AS parentDeptId,
  2111. a.hospital_id AS hospitalId,
  2112. a.behospital_code AS behospitalCode,
  2113. c.score_res AS score,
  2114. c.LEVEL
  2115. FROM
  2116. med_behospital_info a,
  2117. med_qcresult_info c,
  2118. bas_dept_info d
  2119. WHERE
  2120. a.is_deleted = 'N'
  2121. AND c.is_deleted = 'N'
  2122. AND d.is_deleted = 'N'
  2123. AND a.hospital_id = c.hospital_id
  2124. AND a.hospital_id = d.hospital_id
  2125. AND a.behospital_code = c.behospital_code
  2126. AND a.beh_dept_id = d.dept_id
  2127. <if test="isPlacefile != null and isPlacefile != ''">
  2128. and a.is_placefile = #{isPlacefile}
  2129. </if>
  2130. AND a.qc_type_id != 0
  2131. <if test="hospitalId != null and hospitalId != ''">
  2132. AND a.hospital_id = #{hospitalId}
  2133. </if>
  2134. <if test="isPlacefile != null and isPlacefile == 0">
  2135. <if test="lastStartDate != null and lastStartDate != ''">
  2136. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2137. </if>
  2138. <if test="lastEndDate != null and lastEndDate != ''">
  2139. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2140. </if>
  2141. </if>
  2142. <if test="isPlacefile != null and isPlacefile == 1">
  2143. <if test="lastStartDate != null and lastStartDate != ''">
  2144. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2145. </if>
  2146. <if test="lastEndDate != null and lastEndDate != ''">
  2147. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2148. </if>
  2149. </if>
  2150. <if test="level != null and level != ''">
  2151. and c.level = #{level}
  2152. </if>
  2153. <if test="deptName != null and deptName != ''">
  2154. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2155. </if>
  2156. ) tt1
  2157. LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
  2158. AND e.is_deleted = 'N'
  2159. AND tt1.hospitalId = e.hospital_id
  2160. <if test="deptClass != null and deptClass != ''">
  2161. WHERE e.dept_name = #{deptClass}
  2162. </if>
  2163. GROUP BY
  2164. tt1.deptId,
  2165. tt1.deptName,
  2166. e.dept_id,
  2167. e.dept_name
  2168. ) t1,
  2169. (
  2170. SELECT
  2171. tt2.deptId,
  2172. tt2.deptName,
  2173. g.dept_id AS deptClassId,
  2174. g.dept_name AS deptClass,
  2175. count( * ) AS entryNum
  2176. FROM
  2177. (
  2178. SELECT
  2179. a.beh_dept_id AS deptId,
  2180. a.beh_dept_name AS deptName,
  2181. f.parent_dept_id AS parentDeptId,
  2182. a.hospital_id AS hospitalId,
  2183. a.behospital_code AS behospitalCode
  2184. FROM
  2185. med_behospital_info a,
  2186. med_qcresult_info c,
  2187. med_qcresult_detail d,
  2188. qc_cases_entry e,
  2189. bas_dept_info f
  2190. WHERE
  2191. a.is_deleted = 'N'
  2192. AND c.is_deleted = 'N'
  2193. AND d.is_deleted = 'N'
  2194. AND e.is_deleted = 'N'
  2195. AND f.is_deleted = 'N'
  2196. AND a.hospital_id = c.hospital_id
  2197. AND a.hospital_id = d.hospital_id
  2198. AND a.hospital_id = f.hospital_id
  2199. AND a.behospital_code = c.behospital_code
  2200. AND a.behospital_code = d.behospital_code
  2201. AND d.cases_id = e.cases_id
  2202. AND d.cases_entry_id = e.id
  2203. AND a.beh_dept_id = f.dept_id
  2204. <if test="isPlacefile != null and isPlacefile != ''">
  2205. and a.is_placefile = #{isPlacefile}
  2206. </if>
  2207. AND a.qc_type_id != 0
  2208. <if test="hospitalId != null and hospitalId != ''">
  2209. AND a.hospital_id = #{hospitalId}
  2210. </if>
  2211. <if test="isPlacefile != null and isPlacefile == 0">
  2212. <if test="lastStartDate != null and lastStartDate != ''">
  2213. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2214. </if>
  2215. <if test="lastEndDate != null and lastEndDate != ''">
  2216. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2217. </if>
  2218. </if>
  2219. <if test="isPlacefile != null and isPlacefile == 1">
  2220. <if test="lastStartDate != null and lastStartDate != ''">
  2221. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2222. </if>
  2223. <if test="lastEndDate != null and lastEndDate != ''">
  2224. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2225. </if>
  2226. </if>
  2227. <if test="level != null and level != ''">
  2228. and c.level = #{level}
  2229. </if>
  2230. <if test="deptName != null and deptName != ''">
  2231. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  2232. </if>
  2233. ) tt2
  2234. LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
  2235. AND g.is_deleted = 'N'
  2236. AND tt2.hospitalId = g.hospital_id
  2237. <if test="deptClass != null and deptClass != ''">
  2238. WHERE g.dept_name = #{deptClass}
  2239. </if>
  2240. GROUP BY
  2241. tt2.deptId,
  2242. tt2.deptName,
  2243. g.dept_id,
  2244. g.dept_name
  2245. ) t2
  2246. WHERE
  2247. t1.deptId = t2.deptId
  2248. AND t1.deptName = t2.deptName)m2
  2249. on
  2250. m1.deptId = m2.deptId
  2251. and m1.deptName = m2.deptName
  2252. <if test="asc != null and asc !=''">
  2253. order by
  2254. <choose>
  2255. <when test='asc=="deptId"'>m1.deptId asc</when>
  2256. <when test='asc=="deptName"'>m1.deptName asc</when>
  2257. <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
  2258. <when test='asc=="deptClass"'>m1.deptClass asc</when>
  2259. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2260. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2261. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2262. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2263. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2264. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2265. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2266. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2267. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2268. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2269. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2270. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2271. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2272. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2273. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2274. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2275. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2276. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2277. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2278. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2279. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2280. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2281. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2282. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2283. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2284. <otherwise>deptName asc</otherwise>
  2285. </choose>
  2286. </if>
  2287. <if test="desc != null and desc!=''">
  2288. order by
  2289. <choose>
  2290. <when test='desc=="deptId"'>m1.deptId desc</when>
  2291. <when test='desc=="deptName"'>m1.deptName desc</when>
  2292. <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
  2293. <when test='desc=="deptClass"'>m1.deptClass desc</when>
  2294. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2295. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2296. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2297. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2298. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2299. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2300. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2301. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2302. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2303. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2304. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2305. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2306. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2307. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2308. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2309. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2310. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2311. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2312. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2313. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2314. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2315. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2316. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2317. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2318. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2319. <otherwise>deptName desc</otherwise>
  2320. </choose>
  2321. </if>
  2322. </select>
  2323. <!-- 各科室缺陷占比-科室 -->
  2324. <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
  2325. resultType="com.diagbot.dto.LevelStsByDeptDTO">
  2326. SELECT
  2327. m1.doctorId,
  2328. m1.doctorName,
  2329. m1.entryNum,
  2330. m2.sameNum,
  2331. m1.mrNum,
  2332. m2.sameMrNum,
  2333. m1.totleValue,
  2334. m2.sameTotleValue,
  2335. m1.averageValue,
  2336. m2.sameAvgValue,
  2337. m1.firstLevelNum,
  2338. m2.sameFirstLevelNum,
  2339. m1.secondLevelNum,
  2340. m2.sameSecondLevelNum,
  2341. m1.thirdLevelNum,
  2342. m2.sameThirdLevelNum,
  2343. m1.firstLevelPercent,
  2344. m2.sameFirstLevelPercent,
  2345. m1.secondLevelPercent,
  2346. m2.sameSecondLevelPercent,
  2347. m1.thirdLevelPercent,
  2348. m2.sameThirdLevelPercent,
  2349. m1.firstLevelPercentStr,
  2350. m2.sameFirstLevelPercentStr,
  2351. m1.secondLevelPercentStr,
  2352. m2.sameSecondLevelPercentStr,
  2353. m1.thirdLevelPercentStr,
  2354. m2.sameThirdLevelPercentStr
  2355. FROM
  2356. (
  2357. SELECT
  2358. t1.doctorId,
  2359. t1.doctorName,
  2360. t2.entryNum,
  2361. t1.mrNum,
  2362. t1.totleValue,
  2363. t1.averageValue,
  2364. t1.firstLevelNum,
  2365. t1.secondLevelNum,
  2366. t1.thirdLevelNum,
  2367. t1.firstLevelPercent,
  2368. t1.secondLevelPercent,
  2369. t1.thirdLevelPercent,
  2370. t1.firstLevelPercentStr,
  2371. t1.secondLevelPercentStr,
  2372. t1.thirdLevelPercentStr
  2373. FROM
  2374. (
  2375. SELECT
  2376. a.doctor_id AS doctorId,
  2377. a.doctor_name AS doctorName,
  2378. count(*) AS mrNum,
  2379. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2380. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2381. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2382. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2383. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2384. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2385. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2386. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2387. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2388. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2389. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2390. FROM
  2391. med_behospital_info a,
  2392. med_qcresult_info c,
  2393. sys_user_dept e
  2394. WHERE
  2395. a.is_deleted = 'N'
  2396. AND c.is_deleted = 'N'
  2397. AND e.is_deleted = 'N'
  2398. AND a.hospital_id = c.hospital_id
  2399. AND a.behospital_code = c.behospital_code
  2400. AND a.beh_dept_id = e.dept_id
  2401. <if test="isPlacefile != null and isPlacefile != ''">
  2402. and a.is_placefile = #{isPlacefile}
  2403. </if>
  2404. AND a.qc_type_id != 0
  2405. <if test="hospitalId != null and hospitalId != ''">
  2406. AND a.hospital_id = #{hospitalId}
  2407. </if>
  2408. <if test="isPlacefile != null and isPlacefile == 0">
  2409. <if test="startDate != null and startDate != ''">
  2410. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2411. </if>
  2412. <if test="endDate != null and endDate != ''">
  2413. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2414. </if>
  2415. </if>
  2416. <if test="isPlacefile != null and isPlacefile == 1">
  2417. <if test="startDate != null and startDate != ''">
  2418. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2419. </if>
  2420. <if test="endDate != null and endDate != ''">
  2421. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2422. </if>
  2423. </if>
  2424. <if test="level != null and level != ''">
  2425. and c.level = #{level}
  2426. </if>
  2427. <if test="doctorName != null and doctorName != ''">
  2428. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  2429. </if>
  2430. <if test="userId!=null and userId !=''">
  2431. AND e.user_id = #{userId}
  2432. </if>
  2433. <if test="deptName != null and deptName != ''">
  2434. and a.beh_dept_name = #{deptName}
  2435. </if>
  2436. GROUP BY
  2437. a.doctor_id,
  2438. a.doctor_name
  2439. ) t1,
  2440. (
  2441. SELECT
  2442. a.doctor_id AS doctorId,
  2443. a.doctor_name AS doctorName,
  2444. count( * ) AS entryNum
  2445. FROM
  2446. med_behospital_info a,
  2447. med_qcresult_info c,
  2448. med_qcresult_detail d,
  2449. qc_cases_entry e,
  2450. sys_user_dept f
  2451. WHERE
  2452. a.is_deleted = 'N'
  2453. AND c.is_deleted = 'N'
  2454. AND d.is_deleted = 'N'
  2455. AND e.is_deleted = 'N'
  2456. AND f.is_deleted = 'N'
  2457. AND a.hospital_id = c.hospital_id
  2458. AND a.hospital_id = d.hospital_id
  2459. AND a.behospital_code = c.behospital_code
  2460. AND a.behospital_code = d.behospital_code
  2461. AND d.cases_id = e.cases_id
  2462. AND d.cases_entry_id = e.id
  2463. AND a.beh_dept_id = f.dept_id
  2464. <if test="isPlacefile != null and isPlacefile != ''">
  2465. and a.is_placefile = #{isPlacefile}
  2466. </if>
  2467. AND a.qc_type_id != 0
  2468. <if test="hospitalId != null and hospitalId != ''">
  2469. AND a.hospital_id = #{hospitalId}
  2470. </if>
  2471. <if test="isPlacefile != null and isPlacefile == 0">
  2472. <if test="startDate != null and startDate != ''">
  2473. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  2474. </if>
  2475. <if test="endDate != null and endDate != ''">
  2476. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  2477. </if>
  2478. </if>
  2479. <if test="isPlacefile != null and isPlacefile == 1">
  2480. <if test="startDate != null and startDate != ''">
  2481. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  2482. </if>
  2483. <if test="endDate != null and endDate != ''">
  2484. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  2485. </if>
  2486. </if>
  2487. <if test="level != null and level != ''">
  2488. and c.level = #{level}
  2489. </if>
  2490. <if test="doctorName != null and doctorName != ''">
  2491. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  2492. </if>
  2493. <if test="userId!=null and userId !=''">
  2494. AND f.user_id = #{userId}
  2495. </if>
  2496. <if test="deptName != null and deptName != ''">
  2497. and a.beh_dept_name = #{deptName}
  2498. </if>
  2499. GROUP BY
  2500. a.doctor_id,
  2501. a.doctor_name
  2502. ) t2
  2503. WHERE
  2504. t1.doctorId = t2.doctorId
  2505. AND t1.doctorName = t2.doctorName
  2506. )m1 left join
  2507. ( SELECT
  2508. t1.doctorId,
  2509. t1.doctorName,
  2510. t2.entryNum as sameNum,
  2511. t1.mrNum as sameMrNum,
  2512. t1.totleValue as sameTotleValue,
  2513. t1.averageValue as sameAvgValue,
  2514. t1.firstLevelNum as sameFirstLevelNum,
  2515. t1.secondLevelNum as sameSecondLevelNum,
  2516. t1.thirdLevelNum as sameThirdLevelNum,
  2517. t1.firstLevelPercent as sameFirstLevelPercent,
  2518. t1.secondLevelPercent as sameSecondLevelPercent,
  2519. t1.thirdLevelPercent as sameThirdLevelPercent,
  2520. t1.firstLevelPercentStr as sameFirstLevelPercentStr,
  2521. t1.secondLevelPercentStr as sameSecondLevelPercentStr,
  2522. t1.thirdLevelPercentStr as sameThirdLevelPercentStr
  2523. FROM
  2524. (
  2525. SELECT
  2526. a.doctor_id AS doctorId,
  2527. a.doctor_name AS doctorName,
  2528. count(*) AS mrNum,
  2529. ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  2530. ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  2531. SUM( c.`level` = '甲' ) AS firstLevelNum,
  2532. SUM( c.`level` = '乙' ) AS secondLevelNum,
  2533. SUM( c.`level` = '丙' ) AS thirdLevelNum,
  2534. ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
  2535. ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
  2536. ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
  2537. concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
  2538. concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
  2539. concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
  2540. FROM
  2541. med_behospital_info a,
  2542. med_qcresult_info c,
  2543. sys_user_dept e
  2544. WHERE
  2545. a.is_deleted = 'N'
  2546. AND c.is_deleted = 'N'
  2547. AND e.is_deleted = 'N'
  2548. AND a.hospital_id = c.hospital_id
  2549. AND a.behospital_code = c.behospital_code
  2550. AND a.beh_dept_id = e.dept_id
  2551. <if test="isPlacefile != null and isPlacefile != ''">
  2552. and a.is_placefile = #{isPlacefile}
  2553. </if>
  2554. AND a.qc_type_id != 0
  2555. <if test="hospitalId != null and hospitalId != ''">
  2556. AND a.hospital_id = #{hospitalId}
  2557. </if>
  2558. <if test="isPlacefile != null and isPlacefile == 0">
  2559. <if test="lastStartDate != null and lastStartDate != ''">
  2560. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2561. </if>
  2562. <if test="lastEndDate != null and lastEndDate != ''">
  2563. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2564. </if>
  2565. </if>
  2566. <if test="isPlacefile != null and isPlacefile == 1">
  2567. <if test="lastStartDate != null and lastStartDate != ''">
  2568. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2569. </if>
  2570. <if test="lastEndDate != null and lastEndDate != ''">
  2571. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2572. </if>
  2573. </if>
  2574. <if test="level != null and level != ''">
  2575. and c.level = #{level}
  2576. </if>
  2577. <if test="doctorName != null and doctorName != ''">
  2578. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  2579. </if>
  2580. <if test="userId!=null and userId !=''">
  2581. AND e.user_id = #{userId}
  2582. </if>
  2583. <if test="deptName != null and deptName != ''">
  2584. and a.beh_dept_name = #{deptName}
  2585. </if>
  2586. GROUP BY
  2587. a.doctor_id,
  2588. a.doctor_name
  2589. ) t1,
  2590. (
  2591. SELECT
  2592. a.doctor_id AS doctorId,
  2593. a.doctor_name AS doctorName,
  2594. count( * ) AS entryNum
  2595. FROM
  2596. med_behospital_info a,
  2597. med_qcresult_info c,
  2598. med_qcresult_detail d,
  2599. qc_cases_entry e,
  2600. sys_user_dept f
  2601. WHERE
  2602. a.is_deleted = 'N'
  2603. AND c.is_deleted = 'N'
  2604. AND d.is_deleted = 'N'
  2605. AND e.is_deleted = 'N'
  2606. AND f.is_deleted = 'N'
  2607. AND a.hospital_id = c.hospital_id
  2608. AND a.hospital_id = d.hospital_id
  2609. AND a.behospital_code = c.behospital_code
  2610. AND a.behospital_code = d.behospital_code
  2611. AND d.cases_id = e.cases_id
  2612. AND d.cases_entry_id = e.id
  2613. AND a.beh_dept_id = f.dept_id
  2614. <if test="isPlacefile != null and isPlacefile != ''">
  2615. and a.is_placefile = #{isPlacefile}
  2616. </if>
  2617. AND a.qc_type_id != 0
  2618. <if test="hospitalId != null and hospitalId != ''">
  2619. AND a.hospital_id = #{hospitalId}
  2620. </if>
  2621. <if test="isPlacefile != null and isPlacefile == 0">
  2622. <if test="lastStartDate != null and lastStartDate != ''">
  2623. <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
  2624. </if>
  2625. <if test="lastEndDate != null and lastEndDate != ''">
  2626. <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
  2627. </if>
  2628. </if>
  2629. <if test="isPlacefile != null and isPlacefile == 1">
  2630. <if test="lastStartDate != null and lastStartDate != ''">
  2631. <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
  2632. </if>
  2633. <if test="lastEndDate != null and lastEndDate != ''">
  2634. <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
  2635. </if>
  2636. </if>
  2637. <if test="level != null and level != ''">
  2638. and c.level = #{level}
  2639. </if>
  2640. <if test="doctorName != null and doctorName != ''">
  2641. and a.doctor_name like CONCAT('%',#{doctorName},'%')
  2642. </if>
  2643. <if test="userId!=null and userId !=''">
  2644. AND f.user_id = #{userId}
  2645. </if>
  2646. <if test="deptName != null and deptName != ''">
  2647. and a.beh_dept_name = #{deptName}
  2648. </if>
  2649. GROUP BY
  2650. a.doctor_id,
  2651. a.doctor_name
  2652. ) t2
  2653. WHERE
  2654. t1.doctorId = t2.doctorId
  2655. AND t1.doctorName = t2.doctorName
  2656. )m2
  2657. on
  2658. m1.doctorId = m2.doctorId
  2659. AND m1.doctorName = m2.doctorName
  2660. <if test="asc != null and asc !=''">
  2661. order by
  2662. <choose>
  2663. <when test='asc=="doctorId"'>m1.doctorId asc</when>
  2664. <when test='asc=="doctorName"'>m1.doctorName asc</when>
  2665. <when test='asc=="name"'>m1.doctorName asc</when>
  2666. <when test='asc=="entryNum"'>m1.entryNum asc</when>
  2667. <when test='asc=="sameNum"'>m2.sameNum asc</when>
  2668. <when test='asc=="mrNum"'>m1.mrNum asc</when>
  2669. <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
  2670. <when test='asc=="totleValue"'>m1.totleValue asc</when>
  2671. <when test='asc=="averageValue"'>m1.averageValue asc</when>
  2672. <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
  2673. <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
  2674. <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
  2675. <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
  2676. <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
  2677. <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
  2678. <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
  2679. <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
  2680. <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
  2681. <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
  2682. <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
  2683. <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
  2684. <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
  2685. <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
  2686. <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
  2687. <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
  2688. <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
  2689. <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
  2690. <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
  2691. <otherwise>doctorName asc</otherwise>
  2692. </choose>
  2693. </if>
  2694. <if test="desc != null and desc!=''">
  2695. order by
  2696. <choose>
  2697. <when test='desc=="doctorId"'>m1.doctorId desc</when>
  2698. <when test='desc=="doctorName"'>m1.doctorName desc</when>
  2699. <when test='desc=="entryNum"'>m1.entryNum desc</when>
  2700. <when test='desc=="sameNum"'>m2.sameNum desc</when>
  2701. <when test='desc=="mrNum"'>m1.mrNum desc</when>
  2702. <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
  2703. <when test='desc=="totleValue"'>m1.totleValue desc</when>
  2704. <when test='desc=="averageValue"'>m1.averageValue desc</when>
  2705. <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
  2706. <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
  2707. <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
  2708. <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
  2709. <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
  2710. <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
  2711. <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
  2712. <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
  2713. <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
  2714. <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
  2715. <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
  2716. <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
  2717. <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
  2718. <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
  2719. <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
  2720. <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
  2721. <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
  2722. <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
  2723. <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
  2724. <otherwise>doctorName desc</otherwise>
  2725. </choose>
  2726. </if>
  2727. </select>
  2728. <resultMap id="ExportExcelMapByDept" type="com.diagbot.dto.ExportExcelByDeptDTO">
  2729. <result column="behDeptName" property="behDeptName"/>
  2730. <result column="wardName" property="wardName"/>
  2731. <result column="medoup_name" property="medoupName"/>
  2732. <result column="medoupName" property="medoupName"/>
  2733. <result column="doctorName" property="doctorName"/>
  2734. <result column="avgScore" property="avgScore"/>
  2735. <collection property="excelBehospitalDTOS"
  2736. ofType="com.diagbot.dto.ExportExcelBehByDeptDTO">
  2737. <result column="patName" property="patName"/>
  2738. <result column="behospitalCode" property="behospitalCode"/>
  2739. <result column="fileCode" property="fileCode"/>
  2740. <result column="behospitalDate" property="behospitalDate"/>
  2741. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  2742. <result column="score" property="score"/>
  2743. <result column="scoreBn" property="scoreBn"/>
  2744. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  2745. <result column="caseName" property="caseName"/>
  2746. <collection property="exportExcelMsgDTOS"
  2747. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  2748. <result column="msg" property="msg"/>
  2749. </collection>
  2750. </collection>
  2751. </collection>
  2752. </resultMap>
  2753. <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
  2754. <result column="behDeptName" property="behDeptName"/>
  2755. <result column="avgScore" property="avgScore"/>
  2756. <collection property="excelBehospitalDTOS"
  2757. ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
  2758. <result column="doctorName" property="doctorName"/>
  2759. <result column="patName" property="patName"/>
  2760. <result column="behospitalCode" property="behospitalCode"/>
  2761. <result column="fileCode" property="fileCode"/>
  2762. <result column="behospitalDate" property="behospitalDate"/>
  2763. <result column="leaveHospitalDate" property="leaveHospitalDate"/>
  2764. <result column="score" property="score"/>
  2765. <result column="scoreBn" property="scoreBn"/>
  2766. <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
  2767. <result column="caseName" property="caseName"/>
  2768. <collection property="exportExcelMsgDTOS"
  2769. ofType="com.diagbot.dto.ExportExcelMsgDTO">
  2770. <result column="msg" property="msg"/>
  2771. </collection>
  2772. </collection>
  2773. </collection>
  2774. </resultMap>
  2775. <select id="exportExcel" resultMap="ExportExcelMap">
  2776. SELECT DISTINCT
  2777. t1.beh_dept_name AS behDeptName,
  2778. t1.beh_doctor_name AS doctorName,
  2779. t1.`name` AS patName,
  2780. t1.behospital_code AS behospitalCode,
  2781. t1.behospital_date AS behospitalDate,
  2782. t1.leave_hospital_date AS leaveHospitalDate,
  2783. t2.score_res AS score,
  2784. "1" AS avgScore,
  2785. t4.`name` AS caseName,
  2786. t3.msg AS msg
  2787. FROM
  2788. med_behospital_info t1,
  2789. med_qcresult_info t2,
  2790. med_qcresult_detail t3,
  2791. qc_cases t4
  2792. WHERE
  2793. t1.is_deleted = 'N'
  2794. AND t2.is_deleted = 'N'
  2795. AND t3.is_deleted = 'N'
  2796. AND t4.is_deleted = 'N'
  2797. <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
  2798. <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
  2799. AND t1.hospital_id = t2.hospital_id
  2800. AND t1.behospital_code = t2.behospital_code
  2801. AND t1.hospital_id = t3.hospital_id
  2802. AND t1.behospital_code = t3.behospital_code
  2803. AND t3.cases_id = t4.id
  2804. ORDER BY
  2805. t1.beh_dept_id ASC,
  2806. t1.leave_hospital_date DESC,
  2807. t1.behospital_code ASC,
  2808. t4.`name` ASC
  2809. </select>
  2810. <!-- 质控评分导出到excel-->
  2811. <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
  2812. SELECT * FROM (
  2813. SELECT tp.*,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  2814. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  2815. g.check_type AS ch_type,
  2816. h.check_type AS mr_type,
  2817. g.check_name AS ch_name,
  2818. h.check_name AS mr_name,
  2819. g.check_time AS ch_time,
  2820. h.check_time AS mr_time
  2821. FROM (
  2822. SELECT
  2823. t1.behDeptId,
  2824. t1.behDeptName,
  2825. t1.doctorName,
  2826. t1.patName,
  2827. t1.fileCode,
  2828. t1.behospitalCode,
  2829. t1.hospitalId,
  2830. t1.behospitalDate,
  2831. t1.leaveHospitalDate,
  2832. t1.score,
  2833. <if test="radioCheck !=null and radioCheck == 1">
  2834. t1.msg,
  2835. t1.caseName,
  2836. </if>
  2837. t1.scoreBn,
  2838. t2.avgScore
  2839. FROM
  2840. (
  2841. SELECT
  2842. a.doctor_name AS doctorName,
  2843. a.`name` AS patName,
  2844. a.`file_code` AS fileCode,
  2845. a.behospital_code AS behospitalCode,
  2846. a.behospital_date AS behospitalDate,
  2847. a.leave_hospital_date AS leaveHospitalDate,
  2848. b.score_res AS score,
  2849. e.score_res as scoreBn,
  2850. <if test="radioCheck !=null and radioCheck == 1">
  2851. c.msg AS msg,
  2852. d.NAME AS caseName,
  2853. </if>
  2854. a.beh_dept_id AS behDeptId,
  2855. a.beh_dept_name AS behDeptName,
  2856. a.hospital_id AS hospitalId
  2857. FROM
  2858. med_behospital_info a
  2859. RIGHT JOIN
  2860. med_qcresult_info b
  2861. ON a.hospital_id = b.hospital_id
  2862. AND a.is_deleted = 'N'
  2863. AND b.is_deleted = 'N'
  2864. AND a.behospital_code = b.behospital_code
  2865. <if test="radioCheck !=null and radioCheck == 1">
  2866. LEFT JOIN
  2867. med_qcresult_detail c
  2868. ON c.is_deleted = 'N'
  2869. AND b.behospital_code = c.behospital_code
  2870. AND b.hospital_id = c.hospital_id
  2871. LEFT JOIN
  2872. qc_cases d
  2873. on d.is_deleted = 'N'
  2874. AND c.cases_id = d.id
  2875. </if>
  2876. LEFT JOIN med_qcresult_cases e
  2877. on b.behospital_code = e.behospital_code
  2878. and b.hospital_id = e.hospital_id
  2879. AND e.is_deleted = 'N'
  2880. and e.cases_id = 243
  2881. WHERE
  2882. 1=1
  2883. <if test="isPlacefile != null and isPlacefile != ''">
  2884. and a.is_placefile = #{isPlacefile}
  2885. </if>
  2886. <![CDATA[AND a.qc_type_id <>0 ]]>
  2887. <if test="hospitalId != null and hospitalId != ''">
  2888. AND a.hospital_id = #{hospitalId}
  2889. </if>
  2890. <if test="diagnose != null and diagnose != ''">
  2891. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  2892. </if>
  2893. <if test="behosDateStart != null">
  2894. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  2895. </if>
  2896. <if test="behosDateEnd != null">
  2897. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  2898. </if>
  2899. <if test="leaveHosDateStart != null ">
  2900. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2901. </if>
  2902. <if test="leaveHosDateEnd != null ">
  2903. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2904. </if>
  2905. <if test="behospitalCode != null and behospitalCode != ''">
  2906. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2907. </if>
  2908. <if test="level != null and level != ''">
  2909. AND b.level = #{level}
  2910. </if>
  2911. <if test="doctorName != null and doctorName != ''">
  2912. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2913. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2914. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2915. </if>
  2916. <if test="doctorCode != null and doctorCode != ''">
  2917. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2918. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2919. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2920. </if>
  2921. <if test="deptName != null and deptName != ''">
  2922. and a.beh_dept_name = #{deptName}
  2923. </if>
  2924. <if test="name != null and name != ''">
  2925. AND a.name like CONCAT('%',#{name},'%')
  2926. </if>
  2927. ) t1,
  2928. (
  2929. SELECT
  2930. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  2931. a.beh_dept_id AS behDeptId,
  2932. a.beh_dept_name AS behDeptName
  2933. FROM
  2934. med_behospital_info a,
  2935. med_qcresult_info b
  2936. WHERE
  2937. a.is_deleted = 'N'
  2938. AND b.is_deleted = 'N'
  2939. AND a.hospital_id = b.hospital_id
  2940. AND a.behospital_code = b.behospital_code
  2941. <if test="isPlacefile != null and isPlacefile != ''">
  2942. and a.is_placefile = #{isPlacefile}
  2943. </if>
  2944. <![CDATA[AND a.qc_type_id <>0 ]]>
  2945. <if test="hospitalId != null and hospitalId != ''">
  2946. AND a.hospital_id = #{hospitalId}
  2947. </if>
  2948. <if test="diagnose != null and diagnose != ''">
  2949. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  2950. </if>
  2951. <if test="behosDateStart != null">
  2952. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  2953. </if>
  2954. <if test="behosDateEnd != null">
  2955. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  2956. </if>
  2957. <if test="leaveHosDateStart != null ">
  2958. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  2959. </if>
  2960. <if test="leaveHosDateEnd != null ">
  2961. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  2962. </if>
  2963. <if test="behospitalCode != null and behospitalCode != ''">
  2964. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  2965. </if>
  2966. <if test="level != null and level != ''">
  2967. AND b.level = #{level}
  2968. </if>
  2969. <if test="doctorName != null and doctorName != ''">
  2970. AND (a.doctor_name like CONCAT('%',#{doctorName},'%')
  2971. OR a.beh_doctor_name like CONCAT('%',#{doctorName},'%')
  2972. OR a.director_doctor_name like CONCAT('%',#{doctorName},'%'))
  2973. </if>
  2974. <if test="doctorCode != null and doctorCode != ''">
  2975. AND (a.doctor_id like CONCAT('%',#{doctorCode},'%')
  2976. OR a.beh_doctor_id like CONCAT('%',#{doctorCode},'%')
  2977. OR a.director_doctor_id like CONCAT('%',#{doctorCode},'%'))
  2978. </if>
  2979. <if test="deptName != null and deptName != ''">
  2980. and a.beh_dept_name = #{deptName}
  2981. </if>
  2982. <if test="name != null and name != ''">
  2983. AND a.name like CONCAT('%',#{name},'%')
  2984. </if>
  2985. GROUP BY
  2986. a.beh_dept_id,
  2987. a.beh_dept_name
  2988. ) t2
  2989. WHERE
  2990. t1.behDeptId = t2.behDeptId
  2991. AND t1.behDeptName = t2.behDeptName
  2992. ORDER BY
  2993. t1.behDeptName,
  2994. t1.doctorName,
  2995. t1.patName,
  2996. <if test="radioCheck !=null and radioCheck == 1">
  2997. t1.caseName,
  2998. </if>
  2999. t1.behospitalCode
  3000. )tp
  3001. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type in(0,2) ) g
  3002. ON tp.behospitalCode = g.behospital_code
  3003. AND tp.hospitalId = g.hospital_id
  3004. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  3005. ON tp.behospitalCode = h.behospital_code
  3006. AND tp.hospitalId = h.hospital_id
  3007. ) tu
  3008. WHERE tu.behospitalCode IS NOT NULL
  3009. <if test="checkStatus != null ">
  3010. and tu.check_status = #{checkStatus}
  3011. </if>
  3012. <if test="mrStatus != null ">
  3013. AND tu.mr_status = #{mrStatus}
  3014. </if>
  3015. <if test="chName != null and chName !=''">
  3016. AND tu.ch_name like CONCAT('%',#{chName},'%')
  3017. </if>
  3018. <if test="mrName != null and mrName !=''">
  3019. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  3020. </if>
  3021. <if test="chTimeStart != null">
  3022. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  3023. </if>
  3024. <if test="chTimeEnd != null">
  3025. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  3026. </if>
  3027. <if test="mrTimeStart != null">
  3028. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  3029. </if>
  3030. <if test="mrTimeEnd != null">
  3031. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  3032. </if>
  3033. </select>
  3034. <!-- 各科室缺陷占比科室导出-->
  3035. <select id="levelStatisticsExportByDept" resultMap="ExportExcelMapByDept" parameterType="com.diagbot.vo.ExportQcresultVO">
  3036. SELECT * FROM (
  3037. SELECT tp.*,t3.name as medoup_name,CASE WHEN ISNULL(g.status) THEN 0 ELSE g.status END check_status,
  3038. CASE WHEN ISNULL(h.status) THEN 0 ELSE h.status END mr_status,
  3039. g.check_type AS ch_type,
  3040. h.check_type AS mr_type,
  3041. g.check_name AS ch_name,
  3042. h.check_name AS mr_name,
  3043. g.check_time AS ch_time,
  3044. h.check_time AS mr_time
  3045. FROM (
  3046. SELECT
  3047. t1.behDeptId,
  3048. t1.behDeptName,
  3049. t1.doctorName,
  3050. t1.doctor_id as doctorId,
  3051. t1.patName,
  3052. t1.wardName,
  3053. t1.behospitalCode,
  3054. t1.fileCode,
  3055. t1.hospitalId,
  3056. t1.behospitalDate,
  3057. t1.leaveHospitalDate,
  3058. t1.score,
  3059. t2.avgScore,
  3060. <if test="radioCheck !=null and radioCheck == 1">
  3061. c.msg AS msg,
  3062. t1.caseName,
  3063. </if>
  3064. e.score_res as scoreBn
  3065. FROM
  3066. (
  3067. SELECT
  3068. a.doctor_name AS doctorName,
  3069. a.doctor_id,
  3070. a.`name` AS patName,
  3071. a.ward_name as wardName,
  3072. a.file_code as fileCode,
  3073. a.behospital_code AS behospitalCode,
  3074. a.hospital_id AS hospital_id,
  3075. d.id,
  3076. a.behospital_date AS behospitalDate,
  3077. a.leave_hospital_date AS leaveHospitalDate,
  3078. b.score_res AS score,
  3079. <if test="radioCheck !=null and radioCheck == 1">
  3080. d.NAME AS caseName,
  3081. </if>
  3082. a.beh_dept_id AS behDeptId,
  3083. a.beh_dept_name AS behDeptName,
  3084. a.hospital_id AS hospitalId
  3085. FROM
  3086. med_behospital_info a,
  3087. med_qcresult_info b,
  3088. qc_cases d,
  3089. sys_user_dept e
  3090. WHERE
  3091. a.is_deleted = 'N'
  3092. AND b.is_deleted = 'N'
  3093. AND d.is_deleted = 'N'
  3094. AND e.is_deleted = 'N'
  3095. AND a.hospital_id = b.hospital_id
  3096. AND a.hospital_id = e.hospital_id
  3097. AND a.behospital_code = b.behospital_code
  3098. AND a.beh_dept_id = e.dept_id
  3099. <if test="diagnose != null and diagnose != ''">
  3100. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  3101. </if>
  3102. <if test="isPlacefile != null and isPlacefile != ''">
  3103. and a.is_placefile = #{isPlacefile}
  3104. </if>
  3105. <if test="wardName != null and wardName != ''">
  3106. AND a.ward_name = #{wardName}
  3107. </if>
  3108. <![CDATA[AND a.qc_type_id <>0 ]]>
  3109. <if test="hospitalId != null and hospitalId != ''">
  3110. AND a.hospital_id = #{hospitalId}
  3111. </if>
  3112. <if test="userId != null ">
  3113. AND e.user_id = #{userId}
  3114. </if>
  3115. <if test="behosDateStart != null">
  3116. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  3117. </if>
  3118. <if test="behosDateEnd != null">
  3119. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  3120. </if>
  3121. <if test="leaveHosDateStart != null ">
  3122. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  3123. </if>
  3124. <if test="leaveHosDateEnd != null ">
  3125. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  3126. </if>
  3127. <if test="behospitalCode != null and behospitalCode != ''">
  3128. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  3129. </if>
  3130. <if test="level != null and level != ''">
  3131. AND b.level = #{level}
  3132. </if>
  3133. <if test="doctorName != null and doctorName != ''">
  3134. AND a.doctor_name = #{doctorName}
  3135. </if>
  3136. <if test="doctorCode != null and doctorCode != ''">
  3137. AND a.doctor_id = #{doctorCode}
  3138. </if>
  3139. <if test="deptName != null and deptName != ''">
  3140. and a.beh_dept_name = #{deptName}
  3141. </if>
  3142. <if test="deptId != null and deptId != ''">
  3143. and a.beh_dept_id = #{deptId}
  3144. </if>
  3145. <if test="name != null and name != ''">
  3146. AND a.name like CONCAT('%',#{name},'%')
  3147. </if>
  3148. ) t1
  3149. LEFT JOIN med_qcresult_cases e
  3150. on t1.behospitalCode = e.behospital_code
  3151. and t1.hospital_id = e.hospital_id
  3152. AND e.is_deleted = 'N'
  3153. and e.cases_id = 243
  3154. LEFT JOIN med_qcresult_detail c
  3155. on t1.behospitalCode = c.behospital_code
  3156. and t1.hospital_id = c.hospital_id
  3157. AND c.cases_id = t1.id
  3158. AND c.is_deleted = 'N',
  3159. (
  3160. SELECT
  3161. ROUND( AVG( b.score_res ), 2 ) AS avgScore,
  3162. a.beh_dept_id AS behDeptId,
  3163. a.beh_dept_name AS behDeptName,
  3164. a.doctor_id AS doctorId,
  3165. a.doctor_name AS doctorName
  3166. FROM
  3167. med_behospital_info a,
  3168. med_qcresult_info b,
  3169. sys_user_dept c
  3170. WHERE
  3171. a.is_deleted = 'N'
  3172. AND b.is_deleted = 'N'
  3173. AND c.is_deleted = 'N'
  3174. AND a.hospital_id = b.hospital_id
  3175. AND a.hospital_id = c.hospital_id
  3176. AND a.behospital_code = b.behospital_code
  3177. AND a.beh_dept_id = c.dept_id
  3178. <if test="diagnose != null and diagnose != ''">
  3179. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  3180. </if>
  3181. <if test="wardName != null and wardName != ''">
  3182. AND a.ward_name = #{wardName}
  3183. </if>
  3184. <if test="isPlacefile != null and isPlacefile != ''">
  3185. and a.is_placefile = #{isPlacefile}
  3186. </if>
  3187. <![CDATA[AND a.qc_type_id <>0 ]]>
  3188. <if test="hospitalId != null and hospitalId != ''">
  3189. AND a.hospital_id = #{hospitalId}
  3190. </if>
  3191. <if test="userId != null ">
  3192. AND c.user_id = #{userId}
  3193. </if>
  3194. <if test="behosDateStart != null">
  3195. <![CDATA[ and a.behospital_date >= #{behosDateStart}]]>
  3196. </if>
  3197. <if test="behosDateEnd != null">
  3198. <![CDATA[ and a.behospital_date < #{behosDateEnd}]]>
  3199. </if>
  3200. <if test="leaveHosDateStart != null ">
  3201. <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
  3202. </if>
  3203. <if test="leaveHosDateEnd != null ">
  3204. <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
  3205. </if>
  3206. <if test="behospitalCode != null and behospitalCode != ''">
  3207. AND a.behospital_code like CONCAT('%',#{behospitalCode},'%')
  3208. </if>
  3209. <if test="level != null and level != ''">
  3210. AND b.level = #{level}
  3211. </if>
  3212. <if test="doctorName != null and doctorName != ''">
  3213. AND a.doctor_name = #{doctorName}
  3214. </if>
  3215. <if test="doctorCode != null and doctorCode != ''">
  3216. and a.doctor_id = #{doctorCode}
  3217. </if>
  3218. <if test="deptName != null and deptName != ''">
  3219. and a.beh_dept_name = #{deptName}
  3220. </if>
  3221. <if test="deptId != null and deptId != ''">
  3222. and a.beh_dept_id = #{deptId}
  3223. </if>
  3224. <if test="name != null and name != ''">
  3225. AND a.name like CONCAT('%',#{name},'%')
  3226. </if>
  3227. GROUP BY
  3228. a.beh_dept_id,
  3229. a.beh_dept_name,
  3230. a.doctor_id,
  3231. a.doctor_name
  3232. ) t2
  3233. WHERE
  3234. t1.behDeptId = t2.behDeptId
  3235. AND t1.behDeptName = t2.behDeptName
  3236. AND t1.doctor_id = t2.doctorId
  3237. AND t1.doctorName = t2.doctorName
  3238. ORDER BY
  3239. t1.behDeptName,
  3240. t1.doctorName,
  3241. t1.patName,
  3242. <if test="radioCheck !=null and radioCheck == 1">
  3243. t1.caseName,
  3244. </if>
  3245. t1.behospitalCode
  3246. )tp
  3247. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N' AND check_type = 0 ) g
  3248. ON tp.behospitalCode = g.behospital_code
  3249. AND tp.hospitalId = g.hospital_id
  3250. LEFT JOIN (SELECT * FROM med_check_info WHERE is_deleted = 'N'AND check_type = 1 ) h
  3251. ON tp.behospitalCode = h.behospital_code
  3252. AND tp.hospitalId = h.hospital_id
  3253. LEFT JOIN bas_doctor_info t2 ON tp.doctorId = t2.doctor_id
  3254. AND tp.hospitalId = t2.hospital_id
  3255. AND t2.is_deleted = 'N'
  3256. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  3257. AND t3.is_deleted = 'N'
  3258. where 1=1
  3259. <if test="medoupName != null and medoupName != ''">
  3260. AND t3.name = #{medoupName}
  3261. </if>
  3262. ) tu
  3263. WHERE tu.behospitalCode IS NOT NULL
  3264. <if test="checkStatus != null ">
  3265. and tu.check_status = #{checkStatus}
  3266. </if>
  3267. <if test="mrStatus != null ">
  3268. AND tu.mr_status = #{mrStatus}
  3269. </if>
  3270. <if test="chName != null and chName !=''">
  3271. AND tu.ch_name like CONCAT('%',#{chName},'%')
  3272. </if>
  3273. <if test="mrName != null and mrName !=''">
  3274. AND tu.mr_name like CONCAT('%',#{mrName},'%')
  3275. </if>
  3276. <if test="chTimeStart != null">
  3277. <![CDATA[ and tu.ch_time >= #{chTimeStart}]]>
  3278. </if>
  3279. <if test="chTimeEnd != null">
  3280. <![CDATA[ and tu.ch_time < #{chTimeEnd}]]>
  3281. </if>
  3282. <if test="mrTimeStart != null">
  3283. <![CDATA[ and tu.mr_time >= #{mrTimeStart}]]>
  3284. </if>
  3285. <if test="mrTimeEnd != null">
  3286. <![CDATA[ and tu.mr_time < #{mrTimeEnd}]]>
  3287. </if>
  3288. </select>
  3289. <!-- 条目缺陷质控评分页(内页)-->
  3290. <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
  3291. SELECT t.*
  3292. FROM
  3293. (SELECT DISTINCT
  3294. t1.hospital_id AS hospitalId,
  3295. t1.behospital_code AS behospitalCode,
  3296. t1.bed_code AS bedCode,
  3297. t1.LEVEL AS LEVEL,
  3298. t1.grade_type AS gradeType,
  3299. t1.score_res AS scoreRes,
  3300. t1.scoreBn,
  3301. t1.NAME AS NAME,
  3302. t1.sex AS sex,
  3303. t1.beh_dept_id AS behDeptId,
  3304. t1.beh_dept_name AS behDeptName,
  3305. t1.doctor_id AS doctorId,
  3306. t1.doctor_name AS doctorName,
  3307. t1.beh_doctor_id AS behDoctorId,
  3308. t1.beh_doctor_name AS behDoctorName,
  3309. t1.director_doctor_id AS directorDoctorId,
  3310. t1.director_doctor_name AS directorDoctorName,
  3311. t1.birthday AS birthday,
  3312. t1.behospital_date AS behospitalDate,
  3313. t1.leave_hospital_date AS leaveHospitalDate,
  3314. t1.placefile_date AS placefileDate,
  3315. t1.gmt_create AS gradeTime,
  3316. t1.diagnose,
  3317. t1.ward_name AS wardName,
  3318. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  3319. t1.file_code AS fileCode,
  3320. t1.checkStatus,
  3321. t1.mrStatus,
  3322. t1.chName,
  3323. t1.mrName,
  3324. t1.chTime,
  3325. t1.mrTime
  3326. FROM
  3327. (
  3328. SELECT DISTINCT
  3329. tt1.*
  3330. FROM
  3331. (SELECT
  3332. be.*,
  3333. ifnull(mci.status,0) AS checkStatus,
  3334. ifnull(hm_mci.status,0) AS mrStatus,
  3335. mci.check_name as chName,
  3336. e.score_res as scoreBn,
  3337. hm_mci.check_name as mrName,
  3338. mci.gmt_create as chTime,
  3339. hm_mci.gmt_create as mrTime
  3340. FROM
  3341. (
  3342. SELECT DISTINCT
  3343. a.hospital_id,
  3344. a.behospital_code,
  3345. a.bed_code,
  3346. a.file_code,
  3347. b.LEVEL,
  3348. b.grade_type,
  3349. b.score_res,
  3350. a.NAME,
  3351. a.sex,
  3352. a.beh_dept_id,
  3353. a.beh_dept_name,
  3354. a.birthday,
  3355. a.behospital_date,
  3356. a.leave_hospital_date,
  3357. a.doctor_id,
  3358. a.doctor_name,
  3359. a.beh_doctor_id,
  3360. a.beh_doctor_name,
  3361. a.director_doctor_id,
  3362. a.director_doctor_name,
  3363. a.diagnose,
  3364. a.placefile_date,
  3365. a.ward_name,
  3366. b.gmt_create
  3367. FROM
  3368. med_behospital_info a,
  3369. med_qcresult_info b,
  3370. med_qcresult_detail c,
  3371. qc_cases_entry d
  3372. WHERE
  3373. a.is_deleted = 'N'
  3374. AND b.is_deleted = 'N'
  3375. AND c.is_deleted = 'N'
  3376. AND d.is_deleted = 'N'
  3377. AND a.hospital_id = b.hospital_id
  3378. AND a.hospital_id = c.hospital_id
  3379. AND a.behospital_code = b.behospital_code
  3380. AND a.behospital_code = c.behospital_code
  3381. AND c.cases_id = d.cases_id
  3382. AND c.cases_entry_id = d.id
  3383. AND a.qc_type_id != 0
  3384. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  3385. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  3386. </if>
  3387. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  3388. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  3389. </if>
  3390. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  3391. <if test="qcResultShortPageVO.startDate != null ">
  3392. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  3393. </if>
  3394. <if test="qcResultShortPageVO.endDate != null ">
  3395. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  3396. </if>
  3397. </if>
  3398. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  3399. <if test="qcResultShortPageVO.startDate != null ">
  3400. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  3401. </if>
  3402. <if test="qcResultShortPageVO.endDate != null">
  3403. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  3404. </if>
  3405. </if>
  3406. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  3407. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  3408. </if>
  3409. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  3410. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  3411. </if>
  3412. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  3413. AND b.`level` = #{qcResultShortPageVO.level}
  3414. </if>
  3415. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  3416. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  3417. </if>
  3418. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  3419. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  3420. </if>
  3421. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  3422. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  3423. </if>
  3424. <if test="qcResultShortPageVO.casesEntryId != null ">
  3425. AND d.id = #{qcResultShortPageVO.casesEntryId}
  3426. </if>
  3427. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  3428. AND d.cases_name = #{qcResultShortPageVO.casesName}
  3429. </if>
  3430. <if test="qcResultShortPageVO.casesId != null">
  3431. AND d.cases_id = #{qcResultShortPageVO.casesId}
  3432. </if>
  3433. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  3434. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3435. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  3436. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  3437. </if>
  3438. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3439. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3440. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  3441. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  3442. </if>
  3443. <if test="qcResultShortPageVO.isReject != null">
  3444. AND c.is_reject = #{qcResultShortPageVO.isReject}
  3445. </if>
  3446. <if test="qcResultShortPageVO.ruleType != null">
  3447. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  3448. </if>
  3449. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  3450. AND TIMESTAMPDIFF(
  3451. DAY,
  3452. DATE( a.behospital_date ),
  3453. DATE( a.leave_hospital_date ))> 30
  3454. </if>
  3455. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  3456. AND TIMESTAMPDIFF(
  3457. DAY,
  3458. DATE( a.behospital_date ),
  3459. DATE( a.leave_hospital_date ))> 31
  3460. </if>
  3461. )be
  3462. left join med_check_info mci
  3463. on mci.is_deleted = 'N'
  3464. and mci.check_type = 0
  3465. and be.hospital_id = mci.hospital_id
  3466. and be.behospital_code = mci.behospital_code
  3467. left join med_check_info hm_mci
  3468. on hm_mci.is_deleted = 'N'
  3469. and hm_mci.check_type = 1
  3470. and be.hospital_id = hm_mci.hospital_id
  3471. and be.behospital_code = hm_mci.behospital_code
  3472. LEFT JOIN med_qcresult_cases e
  3473. on be.behospital_code = e.behospital_code
  3474. and be.hospital_id = e.hospital_id
  3475. AND e.is_deleted = 'N'
  3476. and e.cases_id = 243
  3477. )tt1
  3478. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  3479. ,med_medical_record tt2
  3480. WHERE
  3481. tt2.is_deleted = 'N'
  3482. AND tt1.hospital_id = tt2.hospital_id
  3483. AND tt1.behospital_code = tt2.behospital_code
  3484. AND tt2.mode_id = 30
  3485. </if>
  3486. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  3487. ,med_crisis_info tt2
  3488. WHERE
  3489. tt2.is_deleted = 'N'
  3490. AND tt1.hospital_id = tt2.hospital_id
  3491. AND tt1.behospital_code = tt2.behospital_code
  3492. </if>
  3493. ) t1
  3494. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  3495. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  3496. AND t1.behospital_code = t2.behospital_code
  3497. AND t2.is_deleted = 'N'
  3498. </if>
  3499. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  3500. , med_home_page t2
  3501. , med_home_operation_info t3
  3502. WHERE t1.hospital_id = t2.hospital_id
  3503. AND t1.behospital_code = t2.behospital_code
  3504. AND t2.home_page_id = t3.home_page_id
  3505. AND t2.is_deleted = 'N'
  3506. AND t3.is_deleted = 'N'
  3507. </if>
  3508. ) t
  3509. where 1=1
  3510. <if test="qcResultShortPageVO.checkStatus != null">
  3511. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  3512. </if>
  3513. <if test="qcResultShortPageVO.mrStatus != null">
  3514. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  3515. </if>
  3516. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  3517. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  3518. </if>
  3519. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  3520. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  3521. </if>
  3522. <if test="qcResultShortPageVO.chTimeStart != null ">
  3523. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  3524. </if>
  3525. <if test="qcResultShortPageVO.chTimeEnd != null ">
  3526. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  3527. </if>
  3528. <if test="qcResultShortPageVO.mrTimeStart != null ">
  3529. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  3530. </if>
  3531. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  3532. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  3533. </if>
  3534. </select>
  3535. <!-- 条目缺陷质控评分页-科室(内页)-->
  3536. <select id="qcResultShortByDeptPage" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  3537. SELECT t.*
  3538. FROM
  3539. (SELECT DISTINCT
  3540. t1.hospital_id AS hospitalId,
  3541. t1.behospital_code AS behospitalCode,
  3542. t1.bed_code AS bedCode,
  3543. t1.LEVEL AS LEVEL,
  3544. t1.grade_type AS gradeType,
  3545. t1.score_res AS scoreRes,
  3546. t1.scoreBn,
  3547. t1.medoupName,
  3548. t1.NAME AS NAME,
  3549. t1.sex AS sex,
  3550. t1.beh_dept_id AS behDeptId,
  3551. t1.beh_dept_name AS behDeptName,
  3552. t1.doctor_id AS doctorId,
  3553. t1.doctor_name AS doctorName,
  3554. t1.beh_doctor_id AS behDoctorId,
  3555. t1.beh_doctor_name AS behDoctorName,
  3556. t1.director_doctor_id AS directorDoctorId,
  3557. t1.director_doctor_name AS directorDoctorName,
  3558. t1.birthday AS birthday,
  3559. t1.behospital_date AS behospitalDate,
  3560. t1.leave_hospital_date AS leaveHospitalDate,
  3561. t1.placefile_date AS placefileDate,
  3562. t1.gmt_create AS gradeTime,
  3563. t1.diagnose,
  3564. t1.ward_name AS wardName,
  3565. CONCAT( ifnull(t2.age,''),ifnull(t2.age_unit,'') )as age,
  3566. t1.file_code AS fileCode,
  3567. t1.checkStatus,
  3568. t1.mrStatus,
  3569. t1.chName,
  3570. t1.mrName,
  3571. t1.chTime,
  3572. t1.mrTime
  3573. FROM
  3574. (
  3575. SELECT DISTINCT
  3576. tt1.*
  3577. FROM
  3578. (SELECT
  3579. be.*,
  3580. t3.name as medoupName,
  3581. ifnull(mci.status,0) AS checkStatus,
  3582. ifnull(hm_mci.status,0) AS mrStatus,
  3583. mci.check_name as chName,
  3584. e.score_res as scoreBn,
  3585. hm_mci.check_name as mrName,
  3586. mci.check_time as chTime,
  3587. hm_mci.gmt_create as mrTime
  3588. FROM
  3589. (
  3590. SELECT DISTINCT
  3591. a.hospital_id,
  3592. a.behospital_code,
  3593. a.bed_code,
  3594. a.file_code,
  3595. b.LEVEL,
  3596. b.grade_type,
  3597. b.score_res,
  3598. a.NAME,
  3599. a.sex,
  3600. a.beh_dept_id,
  3601. a.beh_dept_name,
  3602. a.birthday,
  3603. a.behospital_date,
  3604. a.leave_hospital_date,
  3605. a.doctor_id,
  3606. a.doctor_name,
  3607. a.beh_doctor_id,
  3608. a.beh_doctor_name,
  3609. a.director_doctor_id,
  3610. a.director_doctor_name,
  3611. a.diagnose,
  3612. a.placefile_date,
  3613. a.ward_name,
  3614. b.gmt_create
  3615. FROM
  3616. med_behospital_info a,
  3617. med_qcresult_info b,
  3618. med_qcresult_detail c,
  3619. qc_cases_entry d,
  3620. sys_user_dept e
  3621. WHERE
  3622. a.is_deleted = 'N'
  3623. AND b.is_deleted = 'N'
  3624. AND c.is_deleted = 'N'
  3625. AND d.is_deleted = 'N'
  3626. AND e.is_deleted = 'N'
  3627. AND a.hospital_id = b.hospital_id
  3628. AND a.hospital_id = c.hospital_id
  3629. AND a.hospital_id = e.hospital_id
  3630. AND a.behospital_code = b.behospital_code
  3631. AND a.behospital_code = c.behospital_code
  3632. AND a.beh_dept_id = e.dept_id
  3633. AND c.cases_id = d.cases_id
  3634. AND c.cases_entry_id = d.id
  3635. AND a.qc_type_id != 0
  3636. <if test="qcResultShortPageVO.userId!=null">
  3637. AND e.user_id = #{qcResultShortPageVO.userId}
  3638. </if>
  3639. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  3640. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  3641. </if>
  3642. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  3643. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  3644. </if>
  3645. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  3646. <if test="qcResultShortPageVO.startDate != null ">
  3647. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  3648. </if>
  3649. <if test="qcResultShortPageVO.endDate != null ">
  3650. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  3651. </if>
  3652. </if>
  3653. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  3654. <if test="qcResultShortPageVO.startDate != null ">
  3655. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  3656. </if>
  3657. <if test="qcResultShortPageVO.endDate != null">
  3658. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  3659. </if>
  3660. </if>
  3661. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  3662. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  3663. </if>
  3664. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  3665. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  3666. </if>
  3667. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  3668. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  3669. </if>
  3670. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  3671. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  3672. </if>
  3673. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  3674. AND b.`level` = #{qcResultShortPageVO.level}
  3675. </if>
  3676. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  3677. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  3678. </if>
  3679. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  3680. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  3681. </if>
  3682. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  3683. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  3684. </if>
  3685. <if test="qcResultShortPageVO.casesEntryId != null ">
  3686. AND d.id = #{qcResultShortPageVO.casesEntryId}
  3687. </if>
  3688. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  3689. AND d.cases_name = #{qcResultShortPageVO.casesName}
  3690. </if>
  3691. <if test="qcResultShortPageVO.casesId != null">
  3692. AND d.cases_id = #{qcResultShortPageVO.casesId}
  3693. </if>
  3694. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  3695. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  3696. </if>
  3697. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  3698. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  3699. </if>
  3700. <if test="qcResultShortPageVO.isReject != null">
  3701. AND c.is_reject = #{qcResultShortPageVO.isReject}
  3702. </if>
  3703. <if test="qcResultShortPageVO.ruleType != null">
  3704. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  3705. </if>
  3706. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  3707. AND TIMESTAMPDIFF(
  3708. DAY,
  3709. DATE( a.behospital_date ),
  3710. DATE( a.leave_hospital_date ))> 30
  3711. </if>
  3712. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  3713. AND TIMESTAMPDIFF(
  3714. DAY,
  3715. DATE( a.behospital_date ),
  3716. DATE( a.leave_hospital_date ))> 31
  3717. </if>
  3718. )be
  3719. left join med_check_info mci
  3720. on mci.is_deleted = 'N'
  3721. and mci.check_type = 0
  3722. and be.hospital_id = mci.hospital_id
  3723. and be.behospital_code = mci.behospital_code
  3724. left join med_check_info hm_mci
  3725. on hm_mci.is_deleted = 'N'
  3726. and hm_mci.check_type = 1
  3727. and be.hospital_id = hm_mci.hospital_id
  3728. and be.behospital_code = hm_mci.behospital_code
  3729. LEFT JOIN med_qcresult_cases e
  3730. on be.behospital_code = e.behospital_code
  3731. and be.hospital_id = e.hospital_id
  3732. AND e.is_deleted = 'N'
  3733. and e.cases_id = 243
  3734. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  3735. and be.hospital_id = t2.hospital_id
  3736. AND t2.is_deleted = 'N'
  3737. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  3738. AND t3.is_deleted = 'N'
  3739. )tt1
  3740. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  3741. ,med_medical_record tt2
  3742. WHERE
  3743. tt2.is_deleted = 'N'
  3744. AND tt1.hospital_id = tt2.hospital_id
  3745. AND tt1.behospital_code = tt2.behospital_code
  3746. AND tt2.mode_id = 30
  3747. </if>
  3748. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  3749. ,med_crisis_info tt2
  3750. WHERE
  3751. tt2.is_deleted = 'N'
  3752. AND tt1.hospital_id = tt2.hospital_id
  3753. AND tt1.behospital_code = tt2.behospital_code
  3754. </if>
  3755. ) t1
  3756. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  3757. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  3758. AND t1.behospital_code = t2.behospital_code
  3759. AND t2.is_deleted = 'N'
  3760. </if>
  3761. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  3762. , med_home_page t2
  3763. , med_home_operation_info t3
  3764. WHERE t1.hospital_id = t2.hospital_id
  3765. AND t1.behospital_code = t2.behospital_code
  3766. AND t2.home_page_id = t3.home_page_id
  3767. AND t2.is_deleted = 'N'
  3768. AND t3.is_deleted = 'N'
  3769. </if>
  3770. ) t
  3771. where
  3772. 1=1
  3773. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  3774. and t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  3775. </if>
  3776. <if test="qcResultShortPageVO.checkStatus != null">
  3777. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  3778. </if>
  3779. <if test="qcResultShortPageVO.mrStatus != null">
  3780. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  3781. </if>
  3782. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  3783. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  3784. </if>
  3785. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  3786. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  3787. </if>
  3788. <if test="qcResultShortPageVO.chTimeStart != null ">
  3789. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  3790. </if>
  3791. <if test="qcResultShortPageVO.chTimeEnd != null ">
  3792. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  3793. </if>
  3794. <if test="qcResultShortPageVO.mrTimeStart != null ">
  3795. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  3796. </if>
  3797. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  3798. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  3799. </if>
  3800. </select>
  3801. <update id="updateBatchByKey">
  3802. <foreach collection="list" item="item" separator=";">
  3803. update med_behospital_info
  3804. <set>
  3805. <if test="item.name != null">
  3806. name = #{item.name},
  3807. </if>
  3808. <if test="item.sex != null">
  3809. sex = #{item.sex},
  3810. </if>
  3811. <if test="item.birthday != null">
  3812. birthday = #{item.birthday},
  3813. </if>
  3814. <if test="item.fileCode != null">
  3815. file_code = #{item.fileCode},
  3816. </if>
  3817. <if test="item.qcTypeId != null">
  3818. qc_type_id = #{item.qcTypeId},
  3819. </if>
  3820. <if test="item.wardCode != null">
  3821. ward_code = #{item.wardCode},
  3822. </if>
  3823. <if test="item.wardName != null">
  3824. ward_name = #{item.wardName},
  3825. </if>
  3826. <if test="item.behDeptId != null">
  3827. beh_dept_id = #{item.behDeptId},
  3828. </if>
  3829. <if test="item.behDeptName != null">
  3830. beh_dept_name = #{item.behDeptName},
  3831. </if>
  3832. <if test="item.bedCode != null">
  3833. bed_code = #{item.bedCode},
  3834. </if>
  3835. <if test="item.bedName != null">
  3836. bed_name = #{item.bedName},
  3837. </if>
  3838. <if test="item.insuranceName != null">
  3839. insurance_name = #{item.insuranceName},
  3840. </if>
  3841. <if test="item.jobType != null">
  3842. job_type = #{item.jobType},
  3843. </if>
  3844. <if test="item.behospitalDate != null">
  3845. behospital_date = #{item.behospitalDate},
  3846. </if>
  3847. <if test="item.leaveHospitalDate != null">
  3848. leave_hospital_date = #{item.leaveHospitalDate},
  3849. </if>
  3850. <if test="item.diagnoseIcd != null">
  3851. diagnose_icd = #{item.diagnoseIcd},
  3852. </if>
  3853. <if test="item.diagnose != null">
  3854. diagnose = #{item.diagnose},
  3855. </if>
  3856. <if test="item.behDoctorId != null">
  3857. beh_doctor_id = #{item.behDoctorId},
  3858. </if>
  3859. <if test="item.behDoctorName != null">
  3860. beh_doctor_name = #{item.behDoctorName},
  3861. </if>
  3862. <if test="item.doctorId != null">
  3863. doctor_id = #{item.doctorId},
  3864. </if>
  3865. <if test="item.doctorName != null">
  3866. doctor_name = #{item.doctorName},
  3867. </if>
  3868. <if test="item.directorDoctorId != null">
  3869. director_doctor_id = #{item.directorDoctorId},
  3870. </if>
  3871. <if test="item.directorDoctorName != null">
  3872. director_doctor_name = #{item.directorDoctorName},
  3873. </if>
  3874. <!-- <if test="item.placefileDate != null">-->
  3875. <!-- placefile_date = #{item.placefileDate},-->
  3876. <!-- </if>-->
  3877. <!-- <if test="item.isPlacefile != null">-->
  3878. <!-- is_placefile = #{item.isPlacefile},-->
  3879. <!-- </if>-->
  3880. <if test="item.gmtModified != null">
  3881. gmt_modified = #{item.gmtModified},
  3882. </if>
  3883. <if test="item.modifier != null">
  3884. modifier = #{item.modifier},
  3885. </if>
  3886. </set>
  3887. where behospital_code = #{item.behospitalCode} and hospital_id = #{item.hospitalId}
  3888. </foreach>
  3889. </update>
  3890. <!-- 关键条目缺陷统计报表-->
  3891. <select id="entryStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStatisticsDTO">
  3892. SELECT
  3893. deptId,
  3894. deptName,
  3895. consultationMRNum,
  3896. consultationNum,
  3897. 2511 AS consultationEntryId,
  3898. '普通会诊未在24小时内完成' AS consultationEntryName,
  3899. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  3900. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  3901. operationMRNum,
  3902. 2594 AS operationNameEntryId,
  3903. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  3904. operationNameNum,
  3905. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  3906. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  3907. 2973 AS operationTimeEntryId,
  3908. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  3909. operationTimeNum,
  3910. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  3911. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  3912. 2930 AS operation15MinuteEntryId,
  3913. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  3914. operation15MinuteNum,
  3915. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  3916. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  3917. 2419 AS crisisEntryId,
  3918. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  3919. crisisMRNum,
  3920. crisisNum,
  3921. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  3922. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  3923. 2495 AS stageSummaryEntryId,
  3924. '无阶段小结' AS stageSummaryEntryName,
  3925. stageSummaryMRNum,
  3926. stageSummaryNum,
  3927. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  3928. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  3929. beHosGT31DaysMRNum
  3930. FROM
  3931. (
  3932. SELECT
  3933. tt.deptId,
  3934. tt.deptName,
  3935. sum( tt.consultationNum ) AS consultationNum,
  3936. sum( tt.consultationMRNum ) AS consultationMRNum,
  3937. sum( tt.operationNameNum ) AS operationNameNum,
  3938. sum( tt.operationTimeNum ) AS operationTimeNum,
  3939. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  3940. sum( tt.operationMRNum ) AS operationMRNum,
  3941. sum( tt.crisisNum ) AS crisisNum,
  3942. sum( tt.crisisMRNum ) AS crisisMRNum,
  3943. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  3944. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  3945. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  3946. FROM
  3947. (
  3948. (
  3949. SELECT
  3950. c.beh_dept_id AS deptId,
  3951. c.beh_dept_name AS deptName,
  3952. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  3953. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  3954. 0 AS operationNameNum,
  3955. 0 AS operationTimeNum,
  3956. 0 AS operation15MinuteNum,
  3957. 0 AS operationMRNum,
  3958. 0 AS crisisNum,
  3959. 0 AS crisisMRNum,
  3960. 0 AS stageSummaryNum,
  3961. 0 AS stageSummaryMRNum,
  3962. 0 AS beHosGT31DaysMRNum
  3963. FROM
  3964. (
  3965. SELECT DISTINCT
  3966. a.hospital_id,
  3967. a.behospital_code,
  3968. a.beh_dept_name,
  3969. a.beh_dept_id
  3970. FROM
  3971. med_behospital_info a,
  3972. med_medical_record b
  3973. WHERE
  3974. a.is_deleted = 'N'
  3975. AND b.is_deleted = 'N'
  3976. AND a.hospital_id = b.hospital_id
  3977. AND a.behospital_code = b.behospital_code
  3978. AND b.mode_id = 30
  3979. <if test="isPlacefile != null and isPlacefile != ''">
  3980. and a.is_placefile = #{isPlacefile}
  3981. </if>
  3982. AND a.qc_type_id != 0
  3983. <if test="hospitalId != null and hospitalId != ''">
  3984. AND a.hospital_id = #{hospitalId}
  3985. </if>
  3986. <if test="isPlacefile != null and isPlacefile == 0">
  3987. <if test="startDate != null ">
  3988. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  3989. </if>
  3990. <if test="endDate != null ">
  3991. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  3992. </if>
  3993. </if>
  3994. <if test="isPlacefile != null and isPlacefile == 1">
  3995. <if test="startDate != null ">
  3996. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  3997. </if>
  3998. <if test="endDate != null ">
  3999. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4000. </if>
  4001. </if>
  4002. <if test="deptName != null and deptName != ''">
  4003. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  4004. </if>
  4005. ) c
  4006. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  4007. AND c.hospital_id = d.hospital_id
  4008. AND c.behospital_code = d.behospital_code
  4009. GROUP BY
  4010. c.beh_dept_id,
  4011. c.beh_dept_name
  4012. ) UNION
  4013. (
  4014. SELECT
  4015. d.beh_dept_id AS deptId,
  4016. d.beh_dept_name AS deptName,
  4017. 0 AS consultationNum,
  4018. 0 AS consultationMRNum,
  4019. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  4020. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  4021. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  4022. count( DISTINCT d.behospital_code ) AS operationMRNum,
  4023. 0 AS crisisNum,
  4024. 0 AS crisisMRNum,
  4025. 0 AS stageSummaryNum,
  4026. 0 AS stageSummaryMRNum,
  4027. 0 AS beHosGT31DaysMRNum
  4028. FROM
  4029. (
  4030. SELECT DISTINCT
  4031. a.hospital_id,
  4032. a.behospital_code,
  4033. a.beh_dept_name,
  4034. a.beh_dept_id
  4035. FROM
  4036. med_behospital_info a,
  4037. med_home_page b,
  4038. med_home_operation_info c
  4039. WHERE
  4040. a.is_deleted = 'N'
  4041. AND b.is_deleted = 'N'
  4042. AND c.is_deleted = 'N'
  4043. AND a.hospital_id = b.hospital_id
  4044. AND a.hospital_id = c.hospital_id
  4045. AND a.behospital_code = b.behospital_code
  4046. AND b.home_page_id = c.home_page_id
  4047. <if test="isPlacefile != null and isPlacefile != ''">
  4048. and a.is_placefile = #{isPlacefile}
  4049. </if>
  4050. AND a.qc_type_id != 0
  4051. <if test="hospitalId != null and hospitalId != ''">
  4052. AND a.hospital_id = #{hospitalId}
  4053. </if>
  4054. <if test="isPlacefile != null and isPlacefile == 0">
  4055. <if test="startDate != null ">
  4056. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4057. </if>
  4058. <if test="endDate != null ">
  4059. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4060. </if>
  4061. </if>
  4062. <if test="isPlacefile != null and isPlacefile == 1">
  4063. <if test="startDate != null ">
  4064. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4065. </if>
  4066. <if test="endDate != null ">
  4067. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4068. </if>
  4069. </if>
  4070. <if test="deptName != null and deptName != ''">
  4071. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  4072. </if>
  4073. ) d
  4074. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  4075. AND d.hospital_id = e.hospital_id
  4076. AND d.behospital_code = e.behospital_code
  4077. GROUP BY
  4078. d.beh_dept_id,
  4079. d.beh_dept_name
  4080. ) UNION
  4081. (
  4082. SELECT
  4083. c.beh_dept_id AS deptId,
  4084. c.beh_dept_name AS deptName,
  4085. 0 AS consultationNum,
  4086. 0 AS consultationMRNum,
  4087. 0 AS operationNameNum,
  4088. 0 AS operationTimeNum,
  4089. 0 AS operation15MinuteNum,
  4090. 0 AS operationMRNum,
  4091. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  4092. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  4093. 0 AS stageSummaryNum,
  4094. 0 AS stageSummaryMRNum,
  4095. 0 AS beHosGT31DaysMRNum
  4096. FROM
  4097. (
  4098. SELECT DISTINCT
  4099. a.hospital_id,
  4100. a.behospital_code,
  4101. a.beh_dept_name,
  4102. a.beh_dept_id
  4103. FROM
  4104. med_behospital_info a,
  4105. med_crisis_info b
  4106. WHERE
  4107. a.is_deleted = 'N'
  4108. AND b.is_deleted = 'N'
  4109. AND a.hospital_id = b.hospital_id
  4110. AND a.behospital_code = b.behospital_code
  4111. <if test="isPlacefile != null and isPlacefile != ''">
  4112. and a.is_placefile = #{isPlacefile}
  4113. </if>
  4114. AND a.qc_type_id != 0
  4115. <if test="hospitalId != null and hospitalId != ''">
  4116. AND a.hospital_id = #{hospitalId}
  4117. </if>
  4118. <if test="isPlacefile != null and isPlacefile == 0">
  4119. <if test="startDate != null ">
  4120. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4121. </if>
  4122. <if test="endDate != null ">
  4123. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4124. </if>
  4125. </if>
  4126. <if test="isPlacefile != null and isPlacefile == 1">
  4127. <if test="startDate != null ">
  4128. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4129. </if>
  4130. <if test="endDate != null ">
  4131. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4132. </if>
  4133. </if>
  4134. <if test="deptName != null and deptName != ''">
  4135. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  4136. </if>
  4137. ) c
  4138. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  4139. AND c.hospital_id = d.hospital_id
  4140. AND c.behospital_code = d.behospital_code
  4141. GROUP BY
  4142. c.beh_dept_id,
  4143. c.beh_dept_name
  4144. ) UNION
  4145. (
  4146. SELECT
  4147. b.beh_dept_id AS deptId,
  4148. b.beh_dept_name AS deptName,
  4149. 0 AS consultationNum,
  4150. 0 AS consultationMRNum,
  4151. 0 AS operationNameNum,
  4152. 0 AS operationTimeNum,
  4153. 0 AS operation15MinuteNum,
  4154. 0 AS operationMRNum,
  4155. 0 AS crisisNum,
  4156. 0 AS crisisMRNum,
  4157. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  4158. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  4159. 0 AS beHosGT31DaysMRNum
  4160. FROM
  4161. (
  4162. SELECT DISTINCT
  4163. a.hospital_id,
  4164. a.behospital_code,
  4165. a.beh_dept_name,
  4166. a.beh_dept_id
  4167. FROM
  4168. med_behospital_info a
  4169. WHERE
  4170. a.is_deleted = 'N'
  4171. AND TIMESTAMPDIFF(
  4172. DAY,
  4173. DATE( behospital_date ),
  4174. DATE( leave_hospital_date ))> 30
  4175. <if test="isPlacefile != null and isPlacefile != ''">
  4176. and a.is_placefile = #{isPlacefile}
  4177. </if>
  4178. AND a.qc_type_id != 0
  4179. <if test="hospitalId != null and hospitalId != ''">
  4180. AND a.hospital_id = #{hospitalId}
  4181. </if>
  4182. <if test="isPlacefile != null and isPlacefile == 0">
  4183. <if test="startDate != null ">
  4184. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4185. </if>
  4186. <if test="endDate != null ">
  4187. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4188. </if>
  4189. </if>
  4190. <if test="isPlacefile != null and isPlacefile == 1">
  4191. <if test="startDate != null ">
  4192. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4193. </if>
  4194. <if test="endDate != null ">
  4195. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4196. </if>
  4197. </if>
  4198. <if test="deptName != null and deptName != ''">
  4199. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  4200. </if>
  4201. ) b
  4202. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  4203. AND b.hospital_id = c.hospital_id
  4204. AND b.behospital_code = c.behospital_code
  4205. GROUP BY
  4206. b.beh_dept_id,
  4207. b.beh_dept_name
  4208. ) UNION
  4209. (
  4210. SELECT
  4211. b.beh_dept_id AS deptId,
  4212. b.beh_dept_name AS deptName,
  4213. 0 AS consultationNum,
  4214. 0 AS consultationMRNum,
  4215. 0 AS operationNameNum,
  4216. 0 AS operationTimeNum,
  4217. 0 AS operation15MinuteNum,
  4218. 0 AS operationMRNum,
  4219. 0 AS crisisNum,
  4220. 0 AS crisisMRNum,
  4221. 0 AS stageSummaryNum,
  4222. 0 AS stageSummaryMRNum,
  4223. count(*) AS beHosGT31DaysMRNum
  4224. FROM
  4225. (
  4226. SELECT DISTINCT
  4227. a.hospital_id,
  4228. a.behospital_code,
  4229. a.beh_dept_name,
  4230. a.beh_dept_id
  4231. FROM
  4232. med_behospital_info a,
  4233. med_qcresult_info b,
  4234. med_qcresult_detail c,
  4235. qc_cases_entry d
  4236. WHERE
  4237. a.is_deleted = 'N'
  4238. AND b.is_deleted = 'N'
  4239. AND c.is_deleted = 'N'
  4240. AND d.is_deleted = 'N'
  4241. AND a.hospital_id = b.hospital_id
  4242. AND a.hospital_id = c.hospital_id
  4243. AND a.behospital_code = b.behospital_code
  4244. AND a.behospital_code = c.behospital_code
  4245. AND c.cases_id = d.cases_id
  4246. AND c.cases_entry_id = d.id
  4247. AND TIMESTAMPDIFF(
  4248. DAY,
  4249. DATE( behospital_date ),
  4250. DATE( leave_hospital_date ))> 31
  4251. <if test="isPlacefile != null and isPlacefile != ''">
  4252. and a.is_placefile = #{isPlacefile}
  4253. </if>
  4254. AND a.qc_type_id != 0
  4255. <if test="hospitalId != null and hospitalId != ''">
  4256. AND a.hospital_id = #{hospitalId}
  4257. </if>
  4258. <if test="isPlacefile != null and isPlacefile == 0">
  4259. <if test="startDate != null ">
  4260. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4261. </if>
  4262. <if test="endDate != null ">
  4263. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4264. </if>
  4265. </if>
  4266. <if test="isPlacefile != null and isPlacefile == 1">
  4267. <if test="startDate != null ">
  4268. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4269. </if>
  4270. <if test="endDate != null ">
  4271. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4272. </if>
  4273. </if>
  4274. <if test="deptName != null and deptName != ''">
  4275. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  4276. </if>
  4277. ) b
  4278. GROUP BY
  4279. b.beh_dept_id,
  4280. b.beh_dept_name
  4281. )
  4282. ) tt
  4283. GROUP BY
  4284. tt.deptId,
  4285. tt.deptName
  4286. ) t
  4287. <if test="asc != null and asc !=''">
  4288. order by
  4289. <choose>
  4290. <when test='asc=="deptId"'>deptId asc</when>
  4291. <when test='asc=="deptName"'>deptName asc</when>
  4292. <when test='asc=="consultationNum"'>consultationNum asc</when>
  4293. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  4294. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  4295. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  4296. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  4297. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  4298. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  4299. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  4300. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  4301. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  4302. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  4303. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  4304. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  4305. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  4306. <when test='asc=="crisisNum"'>crisisNum asc</when>
  4307. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  4308. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  4309. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  4310. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  4311. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  4312. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  4313. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  4314. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  4315. <otherwise>deptName asc</otherwise>
  4316. </choose>
  4317. </if>
  4318. <if test="desc != null and desc!=''">
  4319. order by
  4320. <choose>
  4321. <when test='desc=="deptId"'>deptId desc</when>
  4322. <when test='desc=="deptName"'>deptName desc</when>
  4323. <when test='desc=="consultationNum"'>consultationNum desc</when>
  4324. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  4325. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  4326. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  4327. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  4328. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  4329. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  4330. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  4331. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  4332. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  4333. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  4334. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  4335. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  4336. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  4337. <when test='desc=="crisisNum"'>crisisNum desc</when>
  4338. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  4339. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  4340. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  4341. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  4342. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  4343. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  4344. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  4345. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  4346. <otherwise>deptName desc</otherwise>
  4347. </choose>
  4348. </if>
  4349. </select>
  4350. <!-- 关键条目缺陷统计报表-->
  4351. <select id="sjcfStatistics" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.SjcfStatisticsDTO">
  4352. SELECT
  4353. deptId,
  4354. deptName,
  4355. MRNum scbc8xsMRNum,
  4356. scbc8xsNum,
  4357. 2686 AS scbc8xsEntryId,
  4358. '首次病程未在患者入院8小时内完成' AS scbc8xsEntryName,
  4359. ROUND( IFNULL( scbc8xsNum / MRNum, 0 ), 4 ) AS scbc8xsPercent,
  4360. CONCAT( ROUND( IFNULL( scbc8xsNum / MRNum, 0 ) * 100, 2 ), '%' ) AS scbc8xsPercentStr,
  4361. MRNum zzsccf48xsMRNum,
  4362. zzsccf48xsNum,
  4363. 2656 AS zzsccf48xsEntryId,
  4364. '主治医师首次查房未在患者入院48小时内完成' AS zzsccf48xsEntryName,
  4365. ROUND( IFNULL( zzsccf48xsNum / MRNum, 0 ), 4 ) AS zzsccf48xsPercent,
  4366. CONCAT( ROUND( IFNULL( zzsccf48xsNum / MRNum, 0 ) * 100, 2 ), '%' ) AS zzsccf48xsPercentStr,
  4367. MRNum fzzsccf72xsMRNum,
  4368. fzzsccf72xsNum,
  4369. 2657 AS fzzsccf72xsEntryId,
  4370. '副主任医师/主任医师首次查房未在患者入院72h内完成' AS fzzsccf72xsEntryName,
  4371. ROUND( IFNULL( fzzsccf72xsNum / MRNum, 0 ), 4 ) AS fzzsccf72xsPercent,
  4372. CONCAT( ROUND( IFNULL( fzzsccf72xsNum / MRNum, 0 ) * 100, 2 ), '%' ) AS fzzsccf72xsPercentStr,
  4373. MRNum mzf2cMRNum,
  4374. mzf2cNum,
  4375. 2655 AS mzf2cEntryId,
  4376. '每周无2次副主任医师/主任医师查房记录' AS mzf2cEntryName,
  4377. ROUND( IFNULL( mzf2cNum / MRNum, 0 ), 4 ) AS mzf2cPercent,
  4378. CONCAT( ROUND( IFNULL( mzf2cNum / MRNum, 0 ) * 100, 2 ), '%' ) AS mzf2cPercentStr,
  4379. MRNum mzw3cMRNum,
  4380. mzw3cNum,
  4381. 2686 AS mzw3cEntryId,
  4382. '每周无3次主治医师查房记录' AS mzw3cEntryName,
  4383. ROUND( IFNULL( mzw3cNum / MRNum, 0 ), 4 ) AS mzw3cPercent,
  4384. CONCAT( ROUND( IFNULL( mzw3cNum / MRNum, 0 ) * 100, 2 ), '%' ) AS mzw3cPercentStr
  4385. FROM (
  4386. SELECT
  4387. tt.deptId,
  4388. tt.deptName,
  4389. sum( tt.scbc8xsNum ) AS scbc8xsNum,
  4390. sum( tt.zzsccf48xsNum ) AS zzsccf48xsNum,
  4391. sum( tt.fzzsccf72xsNum ) AS fzzsccf72xsNum,
  4392. sum( tt.mzf2cNum ) AS mzf2cNum,
  4393. sum( tt.mzw3cNum ) AS mzw3cNum,
  4394. sum( tt.MRNum ) AS MRNum
  4395. FROM(
  4396. SELECT
  4397. c.beh_dept_id AS deptId,
  4398. c.beh_dept_name AS deptName,
  4399. sum( d.cases_entry_id = 2686 ) AS scbc8xsNum,
  4400. sum( d.cases_entry_id = 2656 ) AS zzsccf48xsNum,
  4401. sum( d.cases_entry_id = 2657 ) AS fzzsccf72xsNum,
  4402. sum( d.cases_entry_id = 2655 ) AS mzf2cNum,
  4403. sum( d.cases_entry_id = 2654 ) AS mzw3cNum,
  4404. count( DISTINCT c.behospital_code ) AS MRNum
  4405. FROM(
  4406. SELECT DISTINCT
  4407. a.hospital_id,
  4408. a.behospital_code,
  4409. a.beh_dept_name,
  4410. a.beh_dept_id
  4411. FROM med_behospital_info a
  4412. WHERE a.is_deleted = 'N' and a.qc_type_id != 0
  4413. <if test="isPlacefile != null and isPlacefile != ''">
  4414. and a.is_placefile = #{isPlacefile}
  4415. </if>
  4416. <if test="hospitalId != null and hospitalId != ''">
  4417. AND a.hospital_id = #{hospitalId}
  4418. </if>
  4419. <if test="isPlacefile != null and isPlacefile == 0">
  4420. <if test="startDate != null ">
  4421. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4422. </if>
  4423. <if test="endDate != null ">
  4424. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4425. </if>
  4426. </if>
  4427. <if test="isPlacefile != null and isPlacefile == 1">
  4428. <if test="startDate != null ">
  4429. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4430. </if>
  4431. <if test="endDate != null ">
  4432. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4433. </if>
  4434. </if>
  4435. <if test="deptName != null and deptName != ''">
  4436. AND a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  4437. </if>
  4438. ) c
  4439. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N' AND c.hospital_id = d.hospital_id AND c.behospital_code = d.behospital_code
  4440. GROUP BY c.beh_dept_id, c.beh_dept_name
  4441. ) tt GROUP BY deptId, deptName
  4442. )t
  4443. <if test="asc != null and asc !=''">
  4444. order by
  4445. <choose>
  4446. <when test='asc=="deptId"'>deptId asc</when>
  4447. <when test='asc=="deptName"'>deptName asc</when>
  4448. <when test='asc=="scbc8xsNum"'>scbc8xsNum asc</when>
  4449. <when test='asc=="scbc8xsPercent"'>scbc8xsPercent asc</when>
  4450. <when test='asc=="scbc8xsPercentStr"'>scbc8xsPercentStr asc</when>
  4451. <when test='asc=="scbc8xsMRNum"'>scbc8xsMRNum asc</when>
  4452. <when test='asc=="scbc8xsNum"'>scbc8xsNum asc</when>
  4453. <when test='asc=="zzsccf48xsMRNum"'>zzsccf48xsMRNum asc</when>
  4454. <when test='asc=="zzsccf48xsPercent"'>zzsccf48xsPercent asc</when>
  4455. <when test='asc=="zzsccf48xsPercentStr"'>zzsccf48xsPercentStr asc</when>
  4456. <when test='asc=="fzzsccf72xsMRNum"'>fzzsccf72xsMRNum asc</when>
  4457. <when test='asc=="fzzsccf72xsNum"'>fzzsccf72xsNum asc</when>
  4458. <when test='asc=="fzzsccf72xsPercent"'>fzzsccf72xsPercent asc</when>
  4459. <when test='asc=="fzzsccf72xsPercentStr"'>fzzsccf72xsPercentStr asc</when>
  4460. <when test='asc=="mzf2cMRNum"'>mzf2cMRNum asc</when>
  4461. <when test='asc=="mzf2cNum"'>mzf2cNum asc</when>
  4462. <when test='asc=="mzf2cPercent"'>mzf2cPercent asc</when>
  4463. <when test='asc=="mzf2cPercentStr"'>mzf2cPercentStr asc</when>
  4464. <when test='asc=="mzw3cMRNum"'>mzw3cMRNum asc</when>
  4465. <when test='asc=="mzw3cNum"'>mzw3cNum asc</when>
  4466. <when test='asc=="mzw3cPercent"'>mzw3cPercent asc</when>
  4467. <when test='asc=="mzw3cPercentStr"'>mzw3cPercentStr asc</when>
  4468. <otherwise>deptName asc</otherwise>
  4469. </choose>
  4470. </if>
  4471. <if test="desc != null and desc!=''">
  4472. order by
  4473. <choose>
  4474. <when test='desc=="deptId"'>deptId desc</when>
  4475. <when test='desc=="deptName"'>deptName desc</when>
  4476. <when test='asc=="scbc8xsNum"'>scbc8xsNum desc</when>
  4477. <when test='asc=="scbc8xsPercent"'>scbc8xsPercent desc</when>
  4478. <when test='asc=="scbc8xsPercentStr"'>scbc8xsPercentStr desc</when>
  4479. <when test='asc=="scbc8xsMRNum"'>scbc8xsMRNum desc</when>
  4480. <when test='asc=="scbc8xsNum"'>scbc8xsNum desc</when>
  4481. <when test='asc=="zzsccf48xsMRNum"'>zzsccf48xsMRNum desc</when>
  4482. <when test='asc=="zzsccf48xsPercent"'>zzsccf48xsPercent desc</when>
  4483. <when test='asc=="zzsccf48xsPercentStr"'>zzsccf48xsPercentStr desc</when>
  4484. <when test='asc=="fzzsccf72xsMRNum"'>fzzsccf72xsMRNum desc</when>
  4485. <when test='asc=="fzzsccf72xsNum"'>fzzsccf72xsNum desc</when>
  4486. <when test='asc=="fzzsccf72xsPercent"'>fzzsccf72xsPercent desc</when>
  4487. <when test='asc=="fzzsccf72xsPercentStr"'>fzzsccf72xsPercentStr desc</when>
  4488. <when test='asc=="mzf2cMRNum"'>mzf2cMRNum desc</when>
  4489. <when test='asc=="mzf2cNum"'>mzf2cNum desc</when>
  4490. <when test='asc=="mzf2cPercent"'>mzf2cPercent desc</when>
  4491. <when test='asc=="mzf2cPercentStr"'>mzf2cPercentStr desc</when>
  4492. <when test='asc=="mzw3cMRNum"'>mzw3cMRNum desc</when>
  4493. <when test='asc=="mzw3cNum"'>mzw3cNum desc</when>
  4494. <when test='asc=="mzw3cPercent"'>mzw3cPercent desc</when>
  4495. <when test='asc=="mzw3cPercentStr"'>mzw3cPercentStr desc</when>
  4496. <otherwise>deptName desc</otherwise>
  4497. </choose>
  4498. </if>
  4499. </select>
  4500. <!-- 关键条目缺陷统计报表-科室-->
  4501. <select id="entryStatisticsByDept" parameterType="com.diagbot.vo.EntryStatisticsVO" resultType="com.diagbot.dto.EntryStasByDeptDTO">
  4502. SELECT
  4503. deptId,
  4504. deptName,
  4505. doctorName,
  4506. doctorId,
  4507. consultationMRNum,
  4508. consultationNum,
  4509. 2511 AS consultationEntryId,
  4510. '普通会诊未在24小时内完成' AS consultationEntryName,
  4511. ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
  4512. CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
  4513. operationMRNum,
  4514. 2594 AS operationNameEntryId,
  4515. '首页手术名称与手术记录不一致' AS operationNameEntryName,
  4516. operationNameNum,
  4517. ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
  4518. CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
  4519. 2973 AS operationTimeEntryId,
  4520. '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
  4521. operationTimeNum,
  4522. ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
  4523. CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
  4524. 2930 AS operation15MinuteEntryId,
  4525. '术后首次病程未即刻完成' AS operation15MinuteEntryName,
  4526. operation15MinuteNum,
  4527. ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
  4528. CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
  4529. 2419 AS crisisEntryId,
  4530. '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
  4531. crisisMRNum,
  4532. crisisNum,
  4533. ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
  4534. CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
  4535. 2495 AS stageSummaryEntryId,
  4536. '无阶段小结' AS stageSummaryEntryName,
  4537. stageSummaryMRNum,
  4538. stageSummaryNum,
  4539. ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
  4540. CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr,
  4541. beHosGT31DaysMRNum
  4542. FROM
  4543. (
  4544. SELECT
  4545. tt.deptId,
  4546. tt.deptName,
  4547. tt.doctorId,
  4548. tt.doctorName,
  4549. sum( tt.consultationNum ) AS consultationNum,
  4550. sum( tt.consultationMRNum ) AS consultationMRNum,
  4551. sum( tt.operationNameNum ) AS operationNameNum,
  4552. sum( tt.operationTimeNum ) AS operationTimeNum,
  4553. sum( tt.operation15MinuteNum ) AS operation15MinuteNum,
  4554. sum( tt.operationMRNum ) AS operationMRNum,
  4555. sum( tt.crisisNum ) AS crisisNum,
  4556. sum( tt.crisisMRNum ) AS crisisMRNum,
  4557. sum( tt.stageSummaryNum ) AS stageSummaryNum,
  4558. sum( tt.stageSummaryMRNum ) AS stageSummaryMRNum,
  4559. sum( tt.beHosGT31DaysMRNum ) AS beHosGT31DaysMRNum
  4560. FROM
  4561. (
  4562. (
  4563. SELECT
  4564. c.beh_dept_id AS deptId,
  4565. c.beh_dept_name AS deptName,
  4566. c.doctorId,
  4567. c.doctorName,
  4568. sum( d.cases_entry_id = 2511 ) AS consultationNum,
  4569. count( DISTINCT c.behospital_code ) AS consultationMRNum,
  4570. 0 AS operationNameNum,
  4571. 0 AS operationTimeNum,
  4572. 0 AS operation15MinuteNum,
  4573. 0 AS operationMRNum,
  4574. 0 AS crisisNum,
  4575. 0 AS crisisMRNum,
  4576. 0 AS stageSummaryNum,
  4577. 0 AS stageSummaryMRNum,
  4578. 0 AS beHosGT31DaysMRNum
  4579. FROM
  4580. (
  4581. SELECT DISTINCT
  4582. a.hospital_id,
  4583. a.behospital_code,
  4584. a.beh_dept_name,
  4585. a.beh_dept_id,
  4586. a.doctor_id as doctorId,
  4587. a.doctor_name as doctorName
  4588. FROM
  4589. med_behospital_info a,
  4590. med_medical_record b,
  4591. sys_user_dept c
  4592. WHERE
  4593. a.is_deleted = 'N'
  4594. AND b.is_deleted = 'N'
  4595. AND c.is_deleted = 'N'
  4596. AND a.hospital_id = b.hospital_id
  4597. AND a.hospital_id = c.hospital_id
  4598. AND a.behospital_code = b.behospital_code
  4599. AND a.beh_dept_id = c.dept_id
  4600. AND b.mode_id = 30
  4601. <if test="userId!=null">
  4602. AND c.user_id = #{userId}
  4603. </if>
  4604. <if test="isPlacefile != null and isPlacefile != ''">
  4605. and a.is_placefile = #{isPlacefile}
  4606. </if>
  4607. AND a.qc_type_id != 0
  4608. <if test="hospitalId != null and hospitalId != ''">
  4609. AND a.hospital_id = #{hospitalId}
  4610. </if>
  4611. <if test="isPlacefile != null and isPlacefile == 0">
  4612. <if test="startDate != null ">
  4613. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4614. </if>
  4615. <if test="endDate != null ">
  4616. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4617. </if>
  4618. </if>
  4619. <if test="isPlacefile != null and isPlacefile == 1">
  4620. <if test="startDate != null ">
  4621. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4622. </if>
  4623. <if test="endDate != null ">
  4624. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4625. </if>
  4626. </if>
  4627. <if test="doctorName != null and doctorName != ''">
  4628. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4629. </if>
  4630. <if test="deptName != null and deptName != ''">
  4631. AND a.beh_dept_name = #{deptName}
  4632. </if>
  4633. ) c
  4634. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  4635. AND c.hospital_id = d.hospital_id
  4636. AND c.behospital_code = d.behospital_code
  4637. GROUP BY
  4638. c.doctorId,
  4639. c.doctorName
  4640. having
  4641. sum( d.cases_entry_id = 2511 ) is not null and sum( d.cases_entry_id = 2511 ) != 0
  4642. ) UNION
  4643. (
  4644. SELECT
  4645. d.beh_dept_id AS deptId,
  4646. d.beh_dept_name AS deptName,
  4647. d.doctor_id as doctorId,
  4648. d.doctor_name as doctorName,
  4649. 0 AS consultationNum,
  4650. 0 AS consultationMRNum,
  4651. sum( e.cases_entry_id = 2594 ) AS operationNameNum,
  4652. sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
  4653. sum( e.cases_entry_id = 2930 ) AS operation15MinuteNum,
  4654. count( DISTINCT d.behospital_code ) AS operationMRNum,
  4655. 0 AS crisisNum,
  4656. 0 AS crisisMRNum,
  4657. 0 AS stageSummaryNum,
  4658. 0 AS stageSummaryMRNum,
  4659. 0 AS beHosGT31DaysMRNum
  4660. FROM
  4661. (
  4662. SELECT DISTINCT
  4663. a.hospital_id,
  4664. a.behospital_code,
  4665. a.beh_dept_name,
  4666. a.beh_dept_id,
  4667. a.doctor_id,
  4668. a.doctor_name
  4669. FROM
  4670. med_behospital_info a,
  4671. med_home_page b,
  4672. med_home_operation_info c,
  4673. sys_user_dept d
  4674. WHERE
  4675. a.is_deleted = 'N'
  4676. AND b.is_deleted = 'N'
  4677. AND c.is_deleted = 'N'
  4678. AND d.is_deleted = 'N'
  4679. AND a.hospital_id = b.hospital_id
  4680. AND a.hospital_id = c.hospital_id
  4681. AND a.hospital_id = d.hospital_id
  4682. AND a.behospital_code = b.behospital_code
  4683. AND b.home_page_id = c.home_page_id
  4684. AND a.beh_dept_id = d.dept_id
  4685. <if test="userId!=null">
  4686. AND d.user_id = #{userId}
  4687. </if>
  4688. <if test="isPlacefile != null and isPlacefile != ''">
  4689. and a.is_placefile = #{isPlacefile}
  4690. </if>
  4691. AND a.qc_type_id != 0
  4692. <if test="hospitalId != null and hospitalId != ''">
  4693. AND a.hospital_id = #{hospitalId}
  4694. </if>
  4695. <if test="isPlacefile != null and isPlacefile == 0">
  4696. <if test="startDate != null ">
  4697. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4698. </if>
  4699. <if test="endDate != null ">
  4700. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4701. </if>
  4702. </if>
  4703. <if test="isPlacefile != null and isPlacefile == 1">
  4704. <if test="startDate != null ">
  4705. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4706. </if>
  4707. <if test="endDate != null ">
  4708. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4709. </if>
  4710. </if>
  4711. <if test="doctorName != null and doctorName != ''">
  4712. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4713. </if>
  4714. <if test="deptName != null and deptName != ''">
  4715. AND a.beh_dept_name = #{deptName}
  4716. </if>
  4717. ) d
  4718. LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
  4719. AND d.hospital_id = e.hospital_id
  4720. AND d.behospital_code = e.behospital_code
  4721. GROUP BY
  4722. d.doctor_id,
  4723. d.doctor_name
  4724. having sum( e.cases_entry_id = 2594 ) is not null and sum( e.cases_entry_id = 2594 ) != 0
  4725. and sum( e.cases_entry_id = 2973 ) is not null and sum( e.cases_entry_id = 2973 ) != 0
  4726. and sum( e.cases_entry_id = 2930 )is not null and sum( e.cases_entry_id = 2930 ) != 0
  4727. ) UNION
  4728. (
  4729. SELECT
  4730. c.beh_dept_id AS deptId,
  4731. c.beh_dept_name AS deptName,
  4732. c.doctor_id as doctorId,
  4733. c.doctor_name as doctorName,
  4734. 0 AS consultationNum,
  4735. 0 AS consultationMRNum,
  4736. 0 AS operationNameNum,
  4737. 0 AS operationTimeNum,
  4738. 0 AS operation15MinuteNum,
  4739. 0 AS operationMRNum,
  4740. sum( d.cases_entry_id = 2419 ) AS crisisNum,
  4741. count( DISTINCT c.behospital_code ) AS crisisMRNum,
  4742. 0 AS stageSummaryNum,
  4743. 0 AS stageSummaryMRNum,
  4744. 0 AS beHosGT31DaysMRNum
  4745. FROM
  4746. (
  4747. SELECT DISTINCT
  4748. a.hospital_id,
  4749. a.behospital_code,
  4750. a.beh_dept_name,
  4751. a.beh_dept_id,
  4752. a.doctor_id,
  4753. a.doctor_name
  4754. FROM
  4755. med_behospital_info a,
  4756. med_crisis_info b,
  4757. sys_user_dept c
  4758. WHERE
  4759. a.is_deleted = 'N'
  4760. AND b.is_deleted = 'N'
  4761. AND c.is_deleted = 'N'
  4762. AND a.hospital_id = b.hospital_id
  4763. AND a.hospital_id = c.hospital_id
  4764. AND a.behospital_code = b.behospital_code
  4765. AND a.beh_dept_id = c.dept_id
  4766. <if test="userId!=null">
  4767. AND c.user_id = #{userId}
  4768. </if>
  4769. <if test="isPlacefile != null and isPlacefile != ''">
  4770. and a.is_placefile = #{isPlacefile}
  4771. </if>
  4772. AND a.qc_type_id != 0
  4773. <if test="hospitalId != null and hospitalId != ''">
  4774. AND a.hospital_id = #{hospitalId}
  4775. </if>
  4776. <if test="isPlacefile != null and isPlacefile == 0">
  4777. <if test="startDate != null ">
  4778. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4779. </if>
  4780. <if test="endDate != null ">
  4781. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4782. </if>
  4783. </if>
  4784. <if test="isPlacefile != null and isPlacefile == 1">
  4785. <if test="startDate != null ">
  4786. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4787. </if>
  4788. <if test="endDate != null ">
  4789. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4790. </if>
  4791. </if>
  4792. <if test="doctorName != null and doctorName != ''">
  4793. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4794. </if>
  4795. <if test="deptName != null and deptName != ''">
  4796. AND a.beh_dept_name = #{deptName}
  4797. </if>
  4798. ) c
  4799. LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
  4800. AND c.hospital_id = d.hospital_id
  4801. AND c.behospital_code = d.behospital_code
  4802. GROUP BY
  4803. c.doctor_id,
  4804. c.doctor_name
  4805. having sum( d.cases_entry_id = 2419 ) is not null and sum( d.cases_entry_id = 2419 ) != 0
  4806. ) UNION
  4807. (
  4808. SELECT
  4809. b.beh_dept_id AS deptId,
  4810. b.beh_dept_name AS deptName,
  4811. b.doctor_id as doctorId,
  4812. b.doctor_name as doctorName,
  4813. 0 AS consultationNum,
  4814. 0 AS consultationMRNum,
  4815. 0 AS operationNameNum,
  4816. 0 AS operationTimeNum,
  4817. 0 AS operation15MinuteNum,
  4818. 0 AS operationMRNum,
  4819. 0 AS crisisNum,
  4820. 0 AS crisisMRNum,
  4821. sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
  4822. count( DISTINCT b.behospital_code ) AS stageSummaryMRNum,
  4823. 0 AS beHosGT31DaysMRNum
  4824. FROM
  4825. (
  4826. SELECT DISTINCT
  4827. a.hospital_id,
  4828. a.behospital_code,
  4829. a.beh_dept_name,
  4830. a.beh_dept_id,
  4831. a.doctor_id,
  4832. a.doctor_name
  4833. FROM
  4834. med_behospital_info a,
  4835. sys_user_dept b
  4836. WHERE
  4837. a.is_deleted = 'N'
  4838. AND b.is_deleted = 'N'
  4839. AND a.hospital_id = b.hospital_id
  4840. AND a.beh_dept_id = b.dept_id
  4841. AND TIMESTAMPDIFF(
  4842. DAY,
  4843. DATE( behospital_date ),
  4844. DATE( leave_hospital_date ))> 30
  4845. <if test="userId!=null">
  4846. AND b.user_id = #{userId}
  4847. </if>
  4848. <if test="isPlacefile != null and isPlacefile != ''">
  4849. and a.is_placefile = #{isPlacefile}
  4850. </if>
  4851. AND a.qc_type_id != 0
  4852. <if test="hospitalId != null and hospitalId != ''">
  4853. AND a.hospital_id = #{hospitalId}
  4854. </if>
  4855. <if test="isPlacefile != null and isPlacefile == 0">
  4856. <if test="startDate != null ">
  4857. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4858. </if>
  4859. <if test="endDate != null ">
  4860. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4861. </if>
  4862. </if>
  4863. <if test="isPlacefile != null and isPlacefile == 1">
  4864. <if test="startDate != null ">
  4865. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4866. </if>
  4867. <if test="endDate != null ">
  4868. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4869. </if>
  4870. </if>
  4871. <if test="doctorName != null and doctorName != ''">
  4872. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4873. </if>
  4874. <if test="deptName != null and deptName != ''">
  4875. AND a.beh_dept_name = #{deptName}
  4876. </if>
  4877. ) b
  4878. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  4879. AND b.hospital_id = c.hospital_id
  4880. AND b.behospital_code = c.behospital_code
  4881. GROUP BY
  4882. b.doctor_id,
  4883. b.doctor_name
  4884. having sum(c.cases_entry_id = 2495) is not null and sum(c.cases_entry_id = 2495) != 0
  4885. ) UNION
  4886. (
  4887. SELECT
  4888. b.beh_dept_id AS deptId,
  4889. b.beh_dept_name AS deptName,
  4890. b.doctor_id as doctorId,
  4891. b.doctor_name as doctorName,
  4892. 0 AS consultationNum,
  4893. 0 AS consultationMRNum,
  4894. 0 AS operationNameNum,
  4895. 0 AS operationTimeNum,
  4896. 0 AS operation15MinuteNum,
  4897. 0 AS operationMRNum,
  4898. 0 AS crisisNum,
  4899. 0 AS crisisMRNum,
  4900. 0 AS stageSummaryNum,
  4901. 0 AS stageSummaryMRNum,
  4902. count(*) AS beHosGT31DaysMRNum
  4903. FROM
  4904. (
  4905. SELECT DISTINCT
  4906. a.hospital_id,
  4907. a.behospital_code,
  4908. a.beh_dept_name,
  4909. a.beh_dept_id,
  4910. a.doctor_id,
  4911. a.doctor_name
  4912. FROM
  4913. med_behospital_info a,
  4914. med_qcresult_info b,
  4915. med_qcresult_detail c,
  4916. qc_cases_entry d,
  4917. sys_user_dept e
  4918. WHERE
  4919. a.is_deleted = 'N'
  4920. AND b.is_deleted = 'N'
  4921. AND c.is_deleted = 'N'
  4922. AND d.is_deleted = 'N'
  4923. AND e.is_deleted = 'N'
  4924. AND a.hospital_id = b.hospital_id
  4925. AND a.hospital_id = c.hospital_id
  4926. AND a.hospital_id = e.hospital_id
  4927. AND a.behospital_code = b.behospital_code
  4928. AND a.behospital_code = c.behospital_code
  4929. AND c.cases_id = d.cases_id
  4930. AND c.cases_entry_id = d.id
  4931. AND a.beh_dept_id = e.dept_id
  4932. AND TIMESTAMPDIFF(
  4933. DAY,
  4934. DATE( behospital_date ),
  4935. DATE( leave_hospital_date ))> 31
  4936. <if test="userId!=null">
  4937. AND e.user_id = #{userId}
  4938. </if>
  4939. <if test="isPlacefile != null and isPlacefile != ''">
  4940. and a.is_placefile = #{isPlacefile}
  4941. </if>
  4942. AND a.qc_type_id != 0
  4943. <if test="hospitalId != null and hospitalId != ''">
  4944. AND a.hospital_id = #{hospitalId}
  4945. </if>
  4946. <if test="isPlacefile != null and isPlacefile == 0">
  4947. <if test="startDate != null ">
  4948. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  4949. </if>
  4950. <if test="endDate != null ">
  4951. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  4952. </if>
  4953. </if>
  4954. <if test="isPlacefile != null and isPlacefile == 1">
  4955. <if test="startDate != null ">
  4956. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  4957. </if>
  4958. <if test="endDate != null ">
  4959. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  4960. </if>
  4961. </if>
  4962. <if test="doctorName != null and doctorName != ''">
  4963. AND a.doctor_name like CONCAT('%', #{doctorName}, '%')
  4964. </if>
  4965. <if test="deptName != null and deptName != ''">
  4966. AND a.beh_dept_name = #{deptName}
  4967. </if>
  4968. ) b
  4969. GROUP BY
  4970. b.doctor_id,
  4971. b.doctor_name
  4972. )
  4973. ) tt
  4974. GROUP BY
  4975. tt.doctorName
  4976. ) t
  4977. <if test="asc != null and asc !=''">
  4978. order by
  4979. <choose>
  4980. <when test='asc=="deptId"'>deptId asc</when>
  4981. <when test='asc=="deptName"'>deptName asc</when>
  4982. <when test='asc=="doctorName"'>doctorName asc</when>
  4983. <when test='asc=="consultationNum"'>consultationNum asc</when>
  4984. <when test='asc=="consultationPercent"'>consultationPercent asc</when>
  4985. <when test='asc=="consultationPercentStr"'>consultationPercent asc</when>
  4986. <when test='asc=="consultationMRNum"'>consultationMRNum asc</when>
  4987. <when test='asc=="operationNameNum"'>operationNameNum asc</when>
  4988. <when test='asc=="operationNamePercent"'>operationNamePercent asc</when>
  4989. <when test='asc=="operationNamePercentStr"'>operationNamePercent asc</when>
  4990. <when test='asc=="operationTimeNum"'>operationTimeNum asc</when>
  4991. <when test='asc=="operationTimePercent"'>operationTimePercent asc</when>
  4992. <when test='asc=="operationTimePercentStr"'>operationTimePercent asc</when>
  4993. <when test='asc=="operation15MinuteNum"'>operation15MinuteNum asc</when>
  4994. <when test='asc=="operation15MinutePercent"'>operation15MinutePercent asc</when>
  4995. <when test='asc=="operation15MinutePercentStr"'>operation15MinutePercent asc</when>
  4996. <when test='asc=="operationMRNum"'>operationMRNum asc</when>
  4997. <when test='asc=="crisisNum"'>crisisNum asc</when>
  4998. <when test='asc=="crisisPercent"'>crisisPercent asc</when>
  4999. <when test='asc=="crisisPercentStr"'>crisisPercent asc</when>
  5000. <when test='asc=="crisisMRNum"'>crisisMRNum asc</when>
  5001. <when test='asc=="stageSummaryNum"'>stageSummaryNum asc</when>
  5002. <when test='asc=="stageSummaryPercent"'>stageSummaryPercent asc</when>
  5003. <when test='asc=="stageSummaryPercentStr"'>stageSummaryPercent asc</when>
  5004. <when test='asc=="stageSummaryMRNum"'>stageSummaryMRNum asc</when>
  5005. <when test='asc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum asc</when>
  5006. <otherwise>doctorName asc</otherwise>
  5007. </choose>
  5008. </if>
  5009. <if test="desc != null and desc!=''">
  5010. order by
  5011. <choose>
  5012. <when test='desc=="deptId"'>deptId desc</when>
  5013. <when test='desc=="doctorName"'>doctorName desc</when>
  5014. <when test='desc=="deptName"'>deptName desc</when>
  5015. <when test='desc=="consultationNum"'>consultationNum desc</when>
  5016. <when test='desc=="consultationPercent"'>consultationPercent desc</when>
  5017. <when test='desc=="consultationPercentStr"'>consultationPercent desc</when>
  5018. <when test='desc=="consultationMRNum"'>consultationMRNum desc</when>
  5019. <when test='desc=="operationNameNum"'>operationNameNum desc</when>
  5020. <when test='desc=="operationNamePercent"'>operationNamePercent desc</when>
  5021. <when test='desc=="operationNamePercentStr"'>operationNamePercent desc</when>
  5022. <when test='desc=="operationTimeNum"'>operationTimeNum desc</when>
  5023. <when test='desc=="operationTimePercent"'>operationTimePercent desc</when>
  5024. <when test='desc=="operationTimePercentStr"'>operationTimePercent desc</when>
  5025. <when test='desc=="operation15MinuteNum"'>operation15MinuteNum desc</when>
  5026. <when test='desc=="operation15MinutePercent"'>operation15MinutePercent desc</when>
  5027. <when test='desc=="operation15MinutePercentStr"'>operation15MinutePercent desc</when>
  5028. <when test='desc=="operationMRNum"'>operationMRNum desc</when>
  5029. <when test='desc=="crisisNum"'>crisisNum desc</when>
  5030. <when test='desc=="crisisPercent"'>crisisPercent desc</when>
  5031. <when test='desc=="crisisPercentStr"'>crisisPercent desc</when>
  5032. <when test='desc=="crisisMRNum"'>crisisMRNum desc</when>
  5033. <when test='desc=="stageSummaryNum"'>stageSummaryNum desc</when>
  5034. <when test='desc=="stageSummaryPercent"'>stageSummaryPercent desc</when>
  5035. <when test='desc=="stageSummaryPercentStr"'>stageSummaryPercent desc</when>
  5036. <when test='desc=="stageSummaryMRNum"'>stageSummaryMRNum desc</when>
  5037. <when test='desc=="beHosGT31DaysMRNum"'>beHosGT31DaysMRNum desc</when>
  5038. <otherwise>doctorName desc</otherwise>
  5039. </choose>
  5040. </if>
  5041. </select>
  5042. <!-- 非医嘱离院病人记录-->
  5043. <select id="nonAdviceCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  5044. SELECT
  5045. count(*)
  5046. FROM
  5047. med_behospital_info a,
  5048. med_home_page b
  5049. WHERE
  5050. a.is_deleted = 'N'
  5051. AND b.is_deleted = 'N'
  5052. AND a.hospital_id = b.hospital_id
  5053. AND a.behospital_code = b.behospital_code
  5054. AND b.leave_hospital_type = '非医嘱离院'
  5055. <if test="isPlacefile != null and isPlacefile != ''">
  5056. and a.is_placefile = #{isPlacefile}
  5057. </if>
  5058. AND a.qc_type_id != 0
  5059. <if test="hospitalId != null and hospitalId != ''">
  5060. AND a.hospital_id = #{hospitalId}
  5061. </if>
  5062. <if test="isPlacefile != null and isPlacefile == 0">
  5063. <if test="startDate != null and startDate != ''">
  5064. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5065. </if>
  5066. <if test="endDate != null and endDate != ''">
  5067. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5068. </if>
  5069. </if>
  5070. <if test="isPlacefile != null and isPlacefile == 1">
  5071. <if test="startDate != null and startDate != ''">
  5072. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5073. </if>
  5074. <if test="endDate != null and endDate != ''">
  5075. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5076. </if>
  5077. </if>
  5078. </select>
  5079. <!-- 31天内再入院记录-->
  5080. <select id="get31DaysBehospitalCount" resultType="int" parameterType="com.diagbot.vo.FilterVO">
  5081. SELECT
  5082. count(*)
  5083. FROM
  5084. (
  5085. SELECT
  5086. r1.file_code,
  5087. r1.diagnose,
  5088. r1.behospital_code AS behospitalCode,
  5089. r1.behospital_date AS behospitalDate,
  5090. r1.leave_hospital_date AS leaveHospitalDate,
  5091. r2.behospital_code AS lastBehospitalCode,
  5092. r2.behospital_date AS lastBehospitalDate,
  5093. r2.leave_hospital_date AS lastLeaveHospitalDate,
  5094. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  5095. FROM
  5096. (
  5097. SELECT
  5098. ( @rownum := @rownum + 1 ) AS rownum,
  5099. t1.file_code,
  5100. t1.diagnose,
  5101. t1.behospital_code,
  5102. t1.behospital_date,
  5103. t1.leave_hospital_date
  5104. FROM
  5105. (
  5106. SELECT
  5107. tt1.file_code,
  5108. tt1.diagnose,
  5109. tt2.behospital_code,
  5110. tt2.behospital_date,
  5111. tt2.leave_hospital_date
  5112. FROM
  5113. (
  5114. SELECT
  5115. a.file_code,
  5116. a.diagnose
  5117. FROM
  5118. med_behospital_info a
  5119. WHERE
  5120. a.is_deleted = 'N'
  5121. <if test="isPlacefile != null and isPlacefile != ''">
  5122. and a.is_placefile = #{isPlacefile}
  5123. </if>
  5124. AND a.qc_type_id != 0
  5125. AND IFNULL( a.diagnose, '' )!= ''
  5126. AND IFNULL( a.file_code, '' )!= ''
  5127. <if test="hospitalId != null and hospitalId != ''">
  5128. AND a.hospital_id = #{hospitalId}
  5129. </if>
  5130. <if test="isPlacefile != null and isPlacefile == 0">
  5131. <if test="startDate != null and startDate != ''">
  5132. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5133. </if>
  5134. <if test="endDate != null and endDate != ''">
  5135. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5136. </if>
  5137. </if>
  5138. <if test="isPlacefile != null and isPlacefile == 1">
  5139. <if test="startDate != null and startDate != ''">
  5140. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5141. </if>
  5142. <if test="endDate != null and endDate != ''">
  5143. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5144. </if>
  5145. </if>
  5146. GROUP BY
  5147. a.file_code,
  5148. a.diagnose
  5149. HAVING
  5150. count(*)> 1
  5151. ) tt1,
  5152. med_behospital_info tt2
  5153. WHERE
  5154. tt2.is_deleted = 'N'
  5155. <if test="isPlacefile != null and isPlacefile != ''">
  5156. and tt2.is_placefile = #{isPlacefile}
  5157. </if>
  5158. AND tt2.qc_type_id != 0
  5159. AND tt1.file_code = tt2.file_code
  5160. AND tt1.diagnose = tt2.diagnose
  5161. <if test="hospitalId != null and hospitalId != ''">
  5162. AND tt2.hospital_id = #{hospitalId}
  5163. </if>
  5164. <if test="isPlacefile != null and isPlacefile == 0">
  5165. <if test="startDate != null and startDate != ''">
  5166. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  5167. </if>
  5168. <if test="endDate != null and endDate != ''">
  5169. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  5170. </if>
  5171. </if>
  5172. <if test="isPlacefile != null and isPlacefile == 1">
  5173. <if test="startDate != null and startDate != ''">
  5174. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  5175. </if>
  5176. <if test="endDate != null and endDate != ''">
  5177. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  5178. </if>
  5179. </if>
  5180. ORDER BY
  5181. tt1.file_code,
  5182. tt1.diagnose,
  5183. tt2.behospital_date DESC
  5184. ) t1,
  5185. ( SELECT @rownum := 0 ) r
  5186. ) r1
  5187. LEFT JOIN (
  5188. SELECT
  5189. ( @INDEX := @INDEX + 1 ) AS rownum,
  5190. t2.file_code,
  5191. t2.diagnose,
  5192. t2.behospital_code,
  5193. t2.behospital_date,
  5194. t2.leave_hospital_date
  5195. FROM
  5196. (
  5197. SELECT
  5198. tt1.file_code,
  5199. tt1.diagnose,
  5200. tt2.behospital_code,
  5201. tt2.behospital_date,
  5202. tt2.leave_hospital_date
  5203. FROM
  5204. (
  5205. SELECT
  5206. a.file_code,
  5207. a.diagnose
  5208. FROM
  5209. med_behospital_info a
  5210. WHERE
  5211. a.is_deleted = 'N'
  5212. <if test="isPlacefile != null and isPlacefile != ''">
  5213. and a.is_placefile = #{isPlacefile}
  5214. </if>
  5215. AND a.qc_type_id != 0
  5216. AND IFNULL( a.diagnose, '' )!= ''
  5217. AND IFNULL( a.file_code, '' )!= ''
  5218. <if test="hospitalId != null and hospitalId != ''">
  5219. AND a.hospital_id = #{hospitalId}
  5220. </if>
  5221. <if test="isPlacefile != null and isPlacefile == 0">
  5222. <if test="startDate != null and startDate != ''">
  5223. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5224. </if>
  5225. <if test="endDate != null and endDate != ''">
  5226. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5227. </if>
  5228. </if>
  5229. <if test="isPlacefile != null and isPlacefile == 1">
  5230. <if test="startDate != null and startDate != ''">
  5231. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5232. </if>
  5233. <if test="endDate != null and endDate != ''">
  5234. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5235. </if>
  5236. </if>
  5237. GROUP BY
  5238. a.file_code,
  5239. a.diagnose
  5240. HAVING
  5241. count(*)> 1
  5242. ) tt1,
  5243. med_behospital_info tt2
  5244. WHERE
  5245. tt2.is_deleted = 'N'
  5246. <if test="isPlacefile != null and isPlacefile != ''">
  5247. and tt2.is_placefile = #{isPlacefile}
  5248. </if>
  5249. AND tt2.qc_type_id != 0
  5250. AND tt1.file_code = tt2.file_code
  5251. AND tt1.diagnose = tt2.diagnose
  5252. <if test="hospitalId != null and hospitalId != ''">
  5253. AND tt2.hospital_id = #{hospitalId}
  5254. </if>
  5255. <if test="isPlacefile != null and isPlacefile == 0">
  5256. <if test="startDate != null and startDate != ''">
  5257. <![CDATA[ AND tt2.behospital_date >= #{startDate}]]>
  5258. </if>
  5259. <if test="endDate != null and endDate != ''">
  5260. <![CDATA[ AND tt2.behospital_date <= #{endDate}]]>
  5261. </if>
  5262. </if>
  5263. <if test="isPlacefile != null and isPlacefile == 1">
  5264. <if test="startDate != null and startDate != ''">
  5265. <![CDATA[ AND tt2.leave_hospital_date >= #{startDate}]]>
  5266. </if>
  5267. <if test="endDate != null and endDate != ''">
  5268. <![CDATA[ AND tt2.leave_hospital_date <= #{endDate}]]>
  5269. </if>
  5270. </if>
  5271. ORDER BY
  5272. tt1.file_code,
  5273. tt1.diagnose,
  5274. tt2.behospital_date DESC
  5275. ) t2,(
  5276. SELECT
  5277. @INDEX := 0
  5278. ) r
  5279. ) r2 ON r1.file_code = r2.file_code
  5280. AND r1.rownum = r2.rownum - 1
  5281. ) t
  5282. WHERE
  5283. t.diffDays IS NOT NULL
  5284. AND t.diffDays BETWEEN 0
  5285. AND 31
  5286. </select>
  5287. <!-- 病案首页质控病历数统计-全院(首页)-->
  5288. <select id="homePageQcPercent" resultType="com.diagbot.dto.HomePageNumDTO" parameterType="com.diagbot.vo.FilterVO">
  5289. SELECT
  5290. count( * ) AS mrNum,
  5291. ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
  5292. ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
  5293. SUM( c.`level` = '合格' ) AS firstLevelNum,
  5294. SUM( c.`level` = '不合格' ) AS secondLevelNum,
  5295. ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
  5296. ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
  5297. concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
  5298. concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
  5299. FROM
  5300. med_behospital_info a,
  5301. med_qcresult_cases c
  5302. WHERE
  5303. a.is_deleted = 'N'
  5304. AND c.is_deleted = 'N'
  5305. AND a.hospital_id = c.hospital_id
  5306. AND a.behospital_code = c.behospital_code
  5307. AND c.cases_id = 243
  5308. <if test="isPlacefile != null and isPlacefile != ''">
  5309. and a.is_placefile = #{isPlacefile}
  5310. </if>
  5311. AND a.qc_type_id != 0
  5312. <if test="hospitalId != null and hospitalId != ''">
  5313. AND a.hospital_id = #{hospitalId}
  5314. </if>
  5315. <if test="isPlacefile != null and isPlacefile == 0">
  5316. <if test="startDate != null and startDate != ''">
  5317. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5318. </if>
  5319. <if test="endDate != null and endDate != ''">
  5320. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5321. </if>
  5322. </if>
  5323. <if test="isPlacefile != null and isPlacefile == 1">
  5324. <if test="startDate != null and startDate != ''">
  5325. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5326. </if>
  5327. <if test="endDate != null and endDate != ''">
  5328. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5329. </if>
  5330. </if>
  5331. </select>
  5332. <!-- 病案首页完整率统计-全院(首页)-->
  5333. <select id="hmEmptyEntryPercent" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageNumDTO">
  5334. SELECT
  5335. h1.emptyNum,
  5336. h1.mrNum,
  5337. h2.entryNum,
  5338. h1.mrNum * h2.entryNum AS entryTotleNum,
  5339. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum ), 4 ) AS emptyPercent,
  5340. CONCAT(
  5341. ROUND( ( h1.mrNum * h2.entryNum - h1.emptyNum ) / ( h1.mrNum * h2.entryNum )* 100, 2 ),
  5342. '%'
  5343. ) AS emptyPercentStr
  5344. FROM
  5345. (
  5346. SELECT
  5347. sum( d.rule_type = 1 ) AS emptyNum,
  5348. count( DISTINCT a.behospital_code ) AS mrNum
  5349. FROM
  5350. med_behospital_info a,
  5351. med_qcresult_cases b,
  5352. med_qcresult_detail c,
  5353. qc_cases_entry d
  5354. WHERE
  5355. a.is_deleted = 'N'
  5356. AND b.is_deleted = 'N'
  5357. AND c.is_deleted = 'N'
  5358. AND d.is_deleted = 'N'
  5359. AND a.hospital_id = b.hospital_id
  5360. AND a.hospital_id = c.hospital_id
  5361. AND a.behospital_code = b.behospital_code
  5362. AND a.behospital_code = c.behospital_code
  5363. AND b.cases_id = c.cases_id
  5364. AND c.cases_id = d.cases_id
  5365. AND c.cases_entry_id = d.id
  5366. <if test="isPlacefile != null and isPlacefile != ''">
  5367. and a.is_placefile = #{isPlacefile}
  5368. </if>
  5369. AND d.cases_id = 243
  5370. AND a.qc_type_id != 0
  5371. <if test="hospitalId != null and hospitalId != ''">
  5372. AND a.hospital_id = #{hospitalId}
  5373. </if>
  5374. <if test="isPlacefile != null and isPlacefile == 0">
  5375. <if test="startDate != null and startDate != ''">
  5376. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5377. </if>
  5378. <if test="endDate != null and endDate != ''">
  5379. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5380. </if>
  5381. </if>
  5382. <if test="isPlacefile != null and isPlacefile == 1">
  5383. <if test="startDate != null and startDate != ''">
  5384. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5385. </if>
  5386. <if test="endDate != null and endDate != ''">
  5387. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5388. </if>
  5389. </if>
  5390. ) h1,(
  5391. SELECT
  5392. count(*) AS entryNum
  5393. FROM
  5394. qc_cases_entry
  5395. WHERE
  5396. is_deleted = 'N'
  5397. AND cases_id = 243
  5398. ) h2
  5399. </select>
  5400. <!-- 离院病人评分详情页-->
  5401. <select id="getAge" resultType="java.util.Map">
  5402. SELECT
  5403. a.behospital_code as behospitalCode,
  5404. CONCAT( ifnull(a.age,'') ,ifnull(a.age_unit,'') )as age
  5405. FROM
  5406. med_home_page a
  5407. WHERE
  5408. a.is_deleted = 'N'
  5409. AND a.hospital_id = #{hospitalId}
  5410. AND a.behospital_code IN
  5411. <foreach collection="behospitalCodes" open="(" separator="," close=")" item="item">
  5412. '${item}'
  5413. </foreach>
  5414. </select>
  5415. <!-- 离院病人评分详情页-->
  5416. <select id="leaveHosMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  5417. SELECT
  5418. t.*
  5419. FROM
  5420. (SELECT DISTINCT
  5421. t1.hospital_id AS hospitalId,
  5422. t1.behospital_code AS behospitalCode,
  5423. t1.bed_code AS bedCode,
  5424. t1.LEVEL AS LEVEL,
  5425. t1.grade_type AS gradeType,
  5426. t1.score_res AS scoreRes,
  5427. t1.scoreBn,
  5428. t1.NAME AS NAME,
  5429. t1.sex AS sex,
  5430. t1.beh_dept_id AS behDeptId,
  5431. t1.beh_dept_name AS behDeptName,
  5432. t1.doctor_id AS doctorId,
  5433. t1.doctor_name AS doctorName,
  5434. t1.beh_doctor_id AS behDoctorId,
  5435. t1.beh_doctor_name AS behDoctorName,
  5436. t1.director_doctor_id AS directorDoctorId,
  5437. t1.director_doctor_name AS directorDoctorName,
  5438. t1.birthday AS birthday,
  5439. t1.behospital_date AS behospitalDate,
  5440. t1.leave_hospital_date AS leaveHospitalDate,
  5441. t1.placefile_date AS placefileDate,
  5442. t1.gmt_create AS gradeTime,
  5443. t1.diagnose,
  5444. t1.ward_name AS wardName,
  5445. t1.checkStatus,
  5446. t1.mrStatus,
  5447. t1.chName,
  5448. t1.mrName,
  5449. t1.chTime,
  5450. t1.mrTime,
  5451. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  5452. t1.file_code AS fileCode
  5453. FROM
  5454. (
  5455. SELECT be.*,
  5456. ifnull(mci.status,0) AS checkStatus,
  5457. ifnull(hm_mci.status,0) AS mrStatus,
  5458. mci.check_name as chName,
  5459. e.score_res as scoreBn,
  5460. hm_mci.check_name as mrName,
  5461. mci.gmt_create as chTime,
  5462. hm_mci.gmt_create as mrTime
  5463. FROM
  5464. (
  5465. SELECT DISTINCT
  5466. tt1.*
  5467. FROM
  5468. (
  5469. SELECT
  5470. b.*,
  5471. ifnull(c.LEVEL,'未评分') as LEVEL ,
  5472. c.grade_type,
  5473. c.score_res,
  5474. c.gmt_create
  5475. FROM
  5476. (
  5477. SELECT DISTINCT
  5478. a.hospital_id,
  5479. a.behospital_code,
  5480. a.bed_code,
  5481. a.NAME,
  5482. a.sex,
  5483. a.beh_dept_id,
  5484. a.beh_dept_name,
  5485. a.birthday,
  5486. a.behospital_date,
  5487. a.leave_hospital_date,
  5488. a.doctor_id,
  5489. a.doctor_name,
  5490. a.beh_doctor_id,
  5491. a.beh_doctor_name,
  5492. a.director_doctor_id,
  5493. a.director_doctor_name,
  5494. a.diagnose,
  5495. a.placefile_date,
  5496. a.ward_name,
  5497. a.file_code
  5498. FROM
  5499. med_behospital_info a
  5500. WHERE
  5501. a.is_deleted = 'N'
  5502. AND a.qc_type_id != 0
  5503. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  5504. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  5505. </if>
  5506. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  5507. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  5508. </if>
  5509. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  5510. <if test="qcResultShortPageVO.startDate != null ">
  5511. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  5512. </if>
  5513. <if test="qcResultShortPageVO.endDate != null ">
  5514. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  5515. </if>
  5516. </if>
  5517. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  5518. <if test="qcResultShortPageVO.startDate != null ">
  5519. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  5520. </if>
  5521. <if test="qcResultShortPageVO.endDate != null">
  5522. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  5523. </if>
  5524. </if>
  5525. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  5526. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  5527. </if>
  5528. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  5529. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  5530. </if>
  5531. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  5532. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  5533. </if>
  5534. <if test="qcResultShortPageVO.fileCode != null and qcResultShortPageVO.fileCode != ''">
  5535. AND a.file_code LIKE CONCAT( '%', #{qcResultShortPageVO.fileCode}, '%' )
  5536. </if>
  5537. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  5538. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  5539. </if>
  5540. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  5541. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5542. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  5543. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  5544. </if>
  5545. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  5546. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5547. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  5548. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  5549. </if>
  5550. ) b
  5551. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  5552. AND b.hospital_id = c.hospital_id
  5553. AND b.behospital_code = c.behospital_code
  5554. ) tt1
  5555. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  5556. ,med_medical_record tt2,
  5557. qc_mode tt3
  5558. WHERE
  5559. tt2.is_deleted = 'N'
  5560. AND tt3.is_deleted = 'N'
  5561. AND tt1.hospital_id = tt2.hospital_id
  5562. AND tt1.behospital_code = tt2.behospital_code
  5563. AND tt2.mode_id = tt3.id
  5564. AND tt3.`name` = '手术记录'
  5565. </if>
  5566. ) be
  5567. left join med_check_info mci
  5568. on mci.is_deleted = 'N'
  5569. and mci.check_type = 0
  5570. and be.hospital_id = mci.hospital_id
  5571. and be.behospital_code = mci.behospital_code
  5572. left join med_check_info hm_mci
  5573. on hm_mci.is_deleted = 'N'
  5574. and hm_mci.check_type = 1
  5575. and be.hospital_id = hm_mci.hospital_id
  5576. and be.behospital_code = hm_mci.behospital_code
  5577. LEFT JOIN med_qcresult_cases e
  5578. on be.behospital_code = e.behospital_code
  5579. and be.hospital_id = e.hospital_id
  5580. AND e.is_deleted = 'N'
  5581. and e.cases_id = 243
  5582. )t1
  5583. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  5584. ,med_home_page t2
  5585. WHERE
  5586. t2.is_deleted = 'N'
  5587. AND t1.hospital_id = t2.hospital_id
  5588. AND t1.behospital_code = t2.behospital_code
  5589. AND (
  5590. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  5591. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  5592. )
  5593. </if>
  5594. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  5595. , med_medical_record b,
  5596. med_medical_record_content c,
  5597. med_home_page t2
  5598. WHERE
  5599. b.is_deleted = 'N'
  5600. and c.is_deleted = 'N'
  5601. and t2.is_deleted = 'N'
  5602. and t1.hospital_id = b.hospital_id
  5603. and t1.hospital_id = c.hospital_id
  5604. and t1.hospital_id = t2.hospital_id
  5605. AND t1.behospital_code = b.behospital_code
  5606. AND t1.behospital_code = t2.behospital_code
  5607. AND b.rec_id = c.rec_id
  5608. and b.mode_id = '24'
  5609. </if>
  5610. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  5611. ,med_home_page t2
  5612. WHERE
  5613. t2.is_deleted = 'N'
  5614. AND t1.hospital_id = t2.hospital_id
  5615. AND t1.behospital_code = t2.behospital_code
  5616. AND t2.leave_hospital_type = '非医嘱离院'
  5617. </if>
  5618. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  5619. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  5620. AND t1.hospital_id = t2.hospital_id
  5621. AND t1.behospital_code = t2.behospital_code
  5622. </if>
  5623. )t
  5624. where 1=1
  5625. <if test="qcResultShortPageVO.checkStatus != null">
  5626. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  5627. </if>
  5628. <if test="qcResultShortPageVO.mrStatus != null">
  5629. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  5630. </if>
  5631. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  5632. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  5633. </if>
  5634. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  5635. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  5636. </if>
  5637. <if test="qcResultShortPageVO.chTimeStart != null ">
  5638. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  5639. </if>
  5640. <if test="qcResultShortPageVO.chTimeEnd != null ">
  5641. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  5642. </if>
  5643. <if test="qcResultShortPageVO.mrTimeStart != null ">
  5644. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  5645. </if>
  5646. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  5647. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  5648. </if>
  5649. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  5650. AND t.`level` = #{qcResultShortPageVO.level}
  5651. </if>
  5652. </select>
  5653. <!-- 病案首页改善率统计(首页)-->
  5654. <select id="homePageImproveCount" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  5655. SELECT
  5656. t2.homePageMRNum,
  5657. t1.improveNum,
  5658. round( t1.improveNum / t2.homePageMRNum, 4 ) AS improvePercent,
  5659. Concat( round( t1.improveNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  5660. t1.improveToPassNum,
  5661. round( t1.improveToPassNum / t2.homePageMRNum, 4 ) AS improveToPassPercent,
  5662. Concat( round( t1.improveToPassNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  5663. t1.improveToFullNum,
  5664. round( t1.improveToFullNum / t2.homePageMRNum, 4 ) AS improveToFullPercent,
  5665. Concat( round( t1.improveToFullNum / t2.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  5666. FROM
  5667. (
  5668. SELECT
  5669. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  5670. sum( d.score_res = 20 ) AS improveToFullNum,
  5671. count(*) AS improveNum
  5672. FROM
  5673. med_behospital_info a,
  5674. med_home_page b,
  5675. med_qcresult_info c,
  5676. med_qcresult_cases d,
  5677. (
  5678. SELECT
  5679. m4.*
  5680. FROM
  5681. med_behospital_info m1,
  5682. med_home_page m2,
  5683. med_qcresult_info m3,
  5684. med_qcresult_cases m4
  5685. WHERE
  5686. m1.is_deleted = 'N'
  5687. AND m2.is_deleted = 'N'
  5688. AND m3.is_deleted = 'Y'
  5689. AND m4.is_deleted = 'Y'
  5690. AND m1.hospital_id = m2.hospital_id
  5691. AND m1.hospital_id = m3.hospital_id
  5692. AND m1.hospital_id = m4.hospital_id
  5693. AND m1.behospital_code = m2.behospital_code
  5694. AND m1.behospital_code = m3.behospital_code
  5695. AND m1.behospital_code = m4.behospital_code
  5696. AND m3.gmt_create = m4.gmt_create
  5697. AND m3.have_home_page = 1
  5698. AND m4.cases_id = 243
  5699. <if test="isPlacefile != null and isPlacefile != ''">
  5700. and m1.is_placefile = #{isPlacefile}
  5701. </if>
  5702. AND m1.qc_type_id != 0
  5703. <if test="hospitalId != null and hospitalId != ''">
  5704. AND m1.hospital_id = #{hospitalId}
  5705. </if>
  5706. <if test="isPlacefile != null and isPlacefile == 0">
  5707. <if test="startDate != null and startDate != ''">
  5708. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  5709. </if>
  5710. <if test="endDate != null and endDate != ''">
  5711. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  5712. </if>
  5713. </if>
  5714. <if test="isPlacefile != null and isPlacefile == 1">
  5715. <if test="startDate != null and startDate != ''">
  5716. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  5717. </if>
  5718. <if test="endDate != null and endDate != ''">
  5719. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  5720. </if>
  5721. </if>
  5722. GROUP BY
  5723. m1.behospital_code
  5724. ORDER BY
  5725. m1.behospital_code,
  5726. m4.gmt_create
  5727. ) e
  5728. WHERE
  5729. a.is_deleted = 'N'
  5730. AND b.is_deleted = 'N'
  5731. AND c.is_deleted = 'N'
  5732. AND d.is_deleted = 'N'
  5733. AND a.hospital_id = b.hospital_id
  5734. AND a.hospital_id = c.hospital_id
  5735. AND a.hospital_id = d.hospital_id
  5736. AND a.hospital_id = e.hospital_id
  5737. AND a.behospital_code = b.behospital_code
  5738. AND a.behospital_code = c.behospital_code
  5739. AND a.behospital_code = d.behospital_code
  5740. AND a.behospital_code = e.behospital_code
  5741. AND d.cases_id = 243
  5742. AND d.score_res > e.score_res
  5743. <if test="isPlacefile != null and isPlacefile != ''">
  5744. and a.is_placefile = #{isPlacefile}
  5745. </if>
  5746. AND a.qc_type_id != 0
  5747. <if test="hospitalId != null and hospitalId != ''">
  5748. AND a.hospital_id = #{hospitalId}
  5749. </if>
  5750. <if test="isPlacefile != null and isPlacefile == 0">
  5751. <if test="startDate != null and startDate != ''">
  5752. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5753. </if>
  5754. <if test="endDate != null and endDate != ''">
  5755. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5756. </if>
  5757. </if>
  5758. <if test="isPlacefile != null and isPlacefile == 1">
  5759. <if test="startDate != null and startDate != ''">
  5760. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5761. </if>
  5762. <if test="endDate != null and endDate != ''">
  5763. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5764. </if>
  5765. </if>
  5766. ) t1,
  5767. (
  5768. SELECT
  5769. count( DISTINCT a.behospital_code ) AS homePageMRNum
  5770. FROM
  5771. med_behospital_info a,
  5772. med_home_page b,
  5773. med_qcresult_info c
  5774. WHERE
  5775. a.is_deleted = 'N'
  5776. AND b.is_deleted = 'N'
  5777. AND a.hospital_id = b.hospital_id
  5778. AND a.hospital_id = c.hospital_id
  5779. AND a.behospital_code = b.behospital_code
  5780. AND a.behospital_code = c.behospital_code
  5781. AND a.qc_type_id != 0
  5782. <if test="isPlacefile != null and isPlacefile != ''">
  5783. and a.is_placefile = #{isPlacefile}
  5784. </if>
  5785. <if test="hospitalId != null and hospitalId != ''">
  5786. AND a.hospital_id = #{hospitalId}
  5787. </if>
  5788. <if test="isPlacefile != null and isPlacefile == 0">
  5789. <if test="startDate != null and startDate != ''">
  5790. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5791. </if>
  5792. <if test="endDate != null and endDate != ''">
  5793. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5794. </if>
  5795. </if>
  5796. <if test="isPlacefile != null and isPlacefile == 1">
  5797. <if test="startDate != null and startDate != ''">
  5798. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5799. </if>
  5800. <if test="endDate != null and endDate != ''">
  5801. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5802. </if>
  5803. </if>
  5804. ) t2
  5805. </select>
  5806. <!-- 质控核查统计(内页)-->
  5807. <select id="qcCheckStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.HomePageImproveDTO">
  5808. SELECT
  5809. t.*
  5810. FROM
  5811. (SELECT
  5812. mr.beh_dept_id AS deptId,
  5813. mr.beh_dept_name AS deptName,
  5814. IFNULL( mr.mrNum, 0 ) AS mrNum,
  5815. ck.checkedNum AS checkedNum,
  5816. ROUND( ck.checkedNum / mr.mrNum, 4 ) AS checkedPercent,
  5817. CONCAT( ROUND( ck.checkedNum / mr.mrNum * 100, 2 ), '%' ) AS checkedPercentStr,
  5818. hmmr_t.homePageMRNum,
  5819. improve_t.improveNum,
  5820. round( improve_t.improveNum / hmmr_t.homePageMRNum, 4 ) AS improvePercent,
  5821. Concat( round( improve_t.improveNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improvePercentStr,
  5822. improve_t.improveToPassNum,
  5823. round( improve_t.improveToPassNum / hmmr_t.homePageMRNum, 4 ) AS improveToPassPercent,
  5824. Concat( round( improve_t.improveToPassNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToPassPercentStr,
  5825. improve_t.improveToFullNum,
  5826. round( improve_t.improveToFullNum / hmmr_t.homePageMRNum, 4 ) AS improveToFullPercent,
  5827. Concat( round( improve_t.improveToFullNum / hmmr_t.homePageMRNum * 100, 2 ), '%' ) AS improveToFullPercentStr
  5828. FROM
  5829. (
  5830. SELECT
  5831. a.beh_dept_id,
  5832. a.beh_dept_name,
  5833. count(*) AS mrNum
  5834. FROM
  5835. med_behospital_info a,
  5836. med_qcresult_info b
  5837. WHERE
  5838. a.is_deleted = 'N'
  5839. AND b.is_deleted = 'N'
  5840. AND a.hospital_id = b.hospital_id
  5841. AND a.behospital_code = b.behospital_code
  5842. AND a.qc_type_id != 0
  5843. <if test="isPlacefile != null and isPlacefile != ''">
  5844. and a.is_placefile = #{isPlacefile}
  5845. </if>
  5846. <if test="hospitalId != null and hospitalId != ''">
  5847. AND a.hospital_id = #{hospitalId}
  5848. </if>
  5849. <if test="isPlacefile != null and isPlacefile == 0">
  5850. <if test="startDate != null and startDate != ''">
  5851. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5852. </if>
  5853. <if test="endDate != null and endDate != ''">
  5854. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5855. </if>
  5856. </if>
  5857. <if test="isPlacefile != null and isPlacefile == 1">
  5858. <if test="startDate != null and startDate != ''">
  5859. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5860. </if>
  5861. <if test="endDate != null and endDate != ''">
  5862. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5863. </if>
  5864. </if>
  5865. <if test="deptName != null and deptName != ''">
  5866. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5867. </if>
  5868. GROUP BY
  5869. a.beh_dept_id,
  5870. a.beh_dept_name
  5871. ) mr
  5872. LEFT JOIN (
  5873. SELECT
  5874. a.beh_dept_id,
  5875. a.beh_dept_name,
  5876. count(*) AS checkedNum
  5877. FROM
  5878. med_behospital_info a,
  5879. med_qcresult_info b,
  5880. med_check_info c
  5881. WHERE
  5882. a.is_deleted = 'N'
  5883. AND b.is_deleted = 'N'
  5884. AND c.is_deleted = 'N'
  5885. AND a.hospital_id = b.hospital_id
  5886. AND a.hospital_id = c.hospital_id
  5887. AND a.behospital_code = b.behospital_code
  5888. AND a.behospital_code = c.behospital_code
  5889. AND a.qc_type_id != 0
  5890. AND ifnull(c.`status`,0) = 1
  5891. AND c.check_type in (0,2)
  5892. <if test="isPlacefile != null and isPlacefile != ''">
  5893. and a.is_placefile = #{isPlacefile}
  5894. </if>
  5895. <if test="hospitalId != null and hospitalId != ''">
  5896. AND a.hospital_id = #{hospitalId}
  5897. </if>
  5898. <if test="isPlacefile != null and isPlacefile == 0">
  5899. <if test="startDate != null and startDate != ''">
  5900. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5901. </if>
  5902. <if test="endDate != null and endDate != ''">
  5903. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5904. </if>
  5905. </if>
  5906. <if test="isPlacefile != null and isPlacefile == 1">
  5907. <if test="startDate != null and startDate != ''">
  5908. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5909. </if>
  5910. <if test="endDate != null and endDate != ''">
  5911. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5912. </if>
  5913. </if>
  5914. <if test="deptName != null and deptName != ''">
  5915. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5916. </if>
  5917. GROUP BY
  5918. a.beh_dept_id,
  5919. a.beh_dept_name
  5920. ) ck ON mr.beh_dept_id = ck.beh_dept_id
  5921. AND mr.beh_dept_name = ck.beh_dept_name
  5922. LEFT JOIN (
  5923. SELECT
  5924. a.beh_dept_id,
  5925. a.beh_dept_name,
  5926. count( DISTINCT a.behospital_code ) AS homePageMRNum
  5927. FROM
  5928. med_behospital_info a,
  5929. med_home_page b,
  5930. med_qcresult_info c
  5931. WHERE
  5932. a.is_deleted = 'N'
  5933. AND b.is_deleted = 'N'
  5934. AND a.hospital_id = b.hospital_id
  5935. AND a.hospital_id = c.hospital_id
  5936. AND a.behospital_code = b.behospital_code
  5937. AND a.behospital_code = c.behospital_code
  5938. AND a.qc_type_id != 0
  5939. <if test="isPlacefile != null and isPlacefile != ''">
  5940. and a.is_placefile = #{isPlacefile}
  5941. </if>
  5942. <if test="hospitalId != null and hospitalId != ''">
  5943. AND a.hospital_id = #{hospitalId}
  5944. </if>
  5945. <if test="isPlacefile != null and isPlacefile == 0">
  5946. <if test="startDate != null and startDate != ''">
  5947. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  5948. </if>
  5949. <if test="endDate != null and endDate != ''">
  5950. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  5951. </if>
  5952. </if>
  5953. <if test="isPlacefile != null and isPlacefile == 1">
  5954. <if test="startDate != null and startDate != ''">
  5955. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  5956. </if>
  5957. <if test="endDate != null and endDate != ''">
  5958. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  5959. </if>
  5960. </if>
  5961. <if test="deptName != null and deptName != ''">
  5962. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  5963. </if>
  5964. GROUP BY
  5965. a.beh_dept_id,
  5966. a.beh_dept_name
  5967. ) hmmr_t ON mr.beh_dept_id = hmmr_t.beh_dept_id
  5968. AND mr.beh_dept_name = hmmr_t.beh_dept_name
  5969. LEFT JOIN (
  5970. SELECT
  5971. a.beh_dept_id,
  5972. a.beh_dept_name,
  5973. <![CDATA[sum( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 ) AS improveToPassNum,]]>
  5974. sum( d.score_res = 20 ) AS improveToFullNum,
  5975. count(*) AS improveNum
  5976. FROM
  5977. med_behospital_info a,
  5978. med_home_page b,
  5979. med_qcresult_info c,
  5980. med_qcresult_cases d,
  5981. (
  5982. SELECT
  5983. m4.*
  5984. FROM
  5985. med_behospital_info m1,
  5986. med_home_page m2,
  5987. med_qcresult_info m3,
  5988. med_qcresult_cases m4
  5989. WHERE
  5990. m1.is_deleted = 'N'
  5991. AND m2.is_deleted = 'N'
  5992. AND m3.is_deleted = 'Y'
  5993. AND m4.is_deleted = 'Y'
  5994. AND m1.hospital_id = m2.hospital_id
  5995. AND m1.hospital_id = m3.hospital_id
  5996. AND m1.hospital_id = m4.hospital_id
  5997. AND m1.behospital_code = m2.behospital_code
  5998. AND m1.behospital_code = m3.behospital_code
  5999. AND m1.behospital_code = m4.behospital_code
  6000. AND m3.gmt_create = m4.gmt_create
  6001. AND m3.have_home_page = 1
  6002. AND m4.cases_id = 243
  6003. <if test="isPlacefile != null and isPlacefile != ''">
  6004. and m1.is_placefile = #{isPlacefile}
  6005. </if>
  6006. AND m1.qc_type_id != 0
  6007. <if test="hospitalId != null and hospitalId != ''">
  6008. AND m1.hospital_id = #{hospitalId}
  6009. </if>
  6010. <if test="isPlacefile != null and isPlacefile == 0">
  6011. <if test="startDate != null and startDate != ''">
  6012. <![CDATA[ AND m1.behospital_date >= #{startDate}]]>
  6013. </if>
  6014. <if test="endDate != null and endDate != ''">
  6015. <![CDATA[ AND m1.behospital_date <= #{endDate}]]>
  6016. </if>
  6017. </if>
  6018. <if test="isPlacefile != null and isPlacefile == 1">
  6019. <if test="startDate != null and startDate != ''">
  6020. <![CDATA[ AND m1.leave_hospital_date >= #{startDate}]]>
  6021. </if>
  6022. <if test="endDate != null and endDate != ''">
  6023. <![CDATA[ AND m1.leave_hospital_date <= #{endDate}]]>
  6024. </if>
  6025. </if>
  6026. <if test="deptName != null and deptName != ''">
  6027. and m1.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6028. </if>
  6029. GROUP BY
  6030. m1.behospital_code
  6031. ORDER BY
  6032. m1.behospital_code,
  6033. m4.gmt_create
  6034. ) e
  6035. WHERE
  6036. a.is_deleted = 'N'
  6037. AND b.is_deleted = 'N'
  6038. AND c.is_deleted = 'N'
  6039. AND d.is_deleted = 'N'
  6040. AND a.hospital_id = b.hospital_id
  6041. AND a.hospital_id = c.hospital_id
  6042. AND a.hospital_id = d.hospital_id
  6043. AND a.hospital_id = e.hospital_id
  6044. AND a.behospital_code = b.behospital_code
  6045. AND a.behospital_code = c.behospital_code
  6046. AND a.behospital_code = d.behospital_code
  6047. AND a.behospital_code = e.behospital_code
  6048. AND d.cases_id = 243
  6049. AND d.score_res > e.score_res
  6050. <if test="hospitalId != null and hospitalId != ''">
  6051. AND a.hospital_id = #{hospitalId}
  6052. </if>
  6053. <if test="isPlacefile != null and isPlacefile == 0">
  6054. <if test="startDate != null and startDate != ''">
  6055. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  6056. </if>
  6057. <if test="endDate != null and endDate != ''">
  6058. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  6059. </if>
  6060. </if>
  6061. <if test="isPlacefile != null and isPlacefile == 1">
  6062. <if test="startDate != null and startDate != ''">
  6063. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  6064. </if>
  6065. <if test="endDate != null and endDate != ''">
  6066. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  6067. </if>
  6068. </if>
  6069. <if test="deptName != null and deptName != ''">
  6070. and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
  6071. </if>
  6072. GROUP BY
  6073. a.beh_dept_id,
  6074. a.beh_dept_name
  6075. ) improve_t ON mr.beh_dept_id = improve_t.beh_dept_id
  6076. AND mr.beh_dept_name = improve_t.beh_dept_name
  6077. ) t
  6078. <if test="asc != null and asc !=''">
  6079. order by
  6080. <choose>
  6081. <when test='asc=="deptId"'>deptId asc</when>
  6082. <when test='asc=="deptName"'>deptName asc</when>
  6083. <when test='asc=="mrNum"'>mrNum asc</when>
  6084. <when test='asc=="checkedNum"'>checkedNum asc</when>
  6085. <when test='asc=="checkedPercent"'>checkedPercent asc</when>
  6086. <when test='asc=="checkedPercentStr"'>checkedPercent asc</when>
  6087. <when test='asc=="homePageMRNum"'>homePageMRNum asc</when>
  6088. <when test='asc=="improveNum"'>improveNum asc</when>
  6089. <when test='asc=="improvePercent"'>improvePercent asc</when>
  6090. <when test='asc=="improvePercentStr"'>improvePercent asc</when>
  6091. <when test='asc=="improveToPassNum"'>improveToPassNum asc</when>
  6092. <when test='asc=="improveToPassPercent"'>improveToPassPercent asc</when>
  6093. <when test='asc=="improveToPassPercentStr"'>improveToPassPercent asc</when>
  6094. <when test='asc=="improveToFullNum"'>improveToFullNum asc</when>
  6095. <when test='asc=="improveToFullPercent"'>improveToFullPercent asc</when>
  6096. <when test='asc=="improveToFullPercentStr"'>improveToFullPercent asc</when>
  6097. <otherwise>deptName asc</otherwise>
  6098. </choose>
  6099. </if>
  6100. <if test="desc != null and desc!=''">
  6101. order by
  6102. <choose>
  6103. <when test='desc=="deptId"'>deptId desc</when>
  6104. <when test='desc=="deptName"'>deptName desc</when>
  6105. <when test='desc=="mrNum"'>mrNum desc</when>
  6106. <when test='desc=="checkedNum"'>checkedNum desc</when>
  6107. <when test='desc=="checkedPercent"'>checkedPercent desc</when>
  6108. <when test='desc=="checkedPercentStr"'>checkedPercent desc</when>
  6109. <when test='desc=="homePageMRNum"'>homePageMRNum desc</when>
  6110. <when test='desc=="improveNum"'>improveNum desc</when>
  6111. <when test='desc=="improvePercent"'>improvePercent desc</when>
  6112. <when test='desc=="improvePercentStr"'>improvePercent desc</when>
  6113. <when test='desc=="improveToPassNum"'>improveToPassNum desc</when>
  6114. <when test='desc=="improveToPassPercent"'>improveToPassPercent desc</when>
  6115. <when test='desc=="improveToPassPercentStr"'>improveToPassPercent desc</when>
  6116. <when test='desc=="improveToFullNum"'>improveToFullNum desc</when>
  6117. <when test='desc=="improveToFullPercent"'>improveToFullPercent desc</when>
  6118. <when test='desc=="improveToFullPercentStr"'>improveToFullPercent desc</when>
  6119. <otherwise>deptName desc</otherwise>
  6120. </choose>
  6121. </if>
  6122. </select>
  6123. <!-- 离院病人评分详情页导出-->
  6124. <select id="leaveHosMRPageExport" resultMap="ExportExcelMap">
  6125. SELECT
  6126. f1.behDeptId,
  6127. f1.behDeptName,
  6128. f1.doctorName,
  6129. f1.patName,
  6130. f1.behospitalCode,
  6131. f1.hospitalId,
  6132. f1.behospitalDate,
  6133. f1.leaveHospitalDate,
  6134. f1.score,
  6135. f2.avgScore,
  6136. f1.scoreBn,
  6137. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  6138. f1.msg,
  6139. f1.caseName,
  6140. </if>
  6141. f1.checkStatus,
  6142. f1.mrStatus,
  6143. f1.chName,
  6144. f1.mrName,
  6145. f1.chTime,
  6146. f1.mrTime
  6147. FROM
  6148. (SELECT
  6149. t.doctorName,
  6150. t.`name` AS patName,
  6151. t.behospitalCode AS behospitalCode,
  6152. t.behospitalDate AS behospitalDate,
  6153. t.leaveHospitalDate AS leaveHospitalDate,
  6154. qi.score_res AS score,
  6155. t.scoreBn,
  6156. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  6157. qd.msg AS msg,
  6158. qc.NAME AS caseName,
  6159. </if>
  6160. t.behDeptId,
  6161. t.behDeptName,
  6162. t.hospitalId,
  6163. t.checkStatus,
  6164. t.mrStatus,
  6165. t.chName,
  6166. t.mrName,
  6167. t.chTime,
  6168. t.mrTime
  6169. FROM
  6170. (SELECT DISTINCT
  6171. t1.hospital_id AS hospitalId,
  6172. t1.behospital_code AS behospitalCode,
  6173. t1.bed_code AS bedCode,
  6174. t1.LEVEL AS LEVEL,
  6175. t1.grade_type AS gradeType,
  6176. t1.score_res AS scoreRes,
  6177. t1.scoreBn,
  6178. t1.NAME AS NAME,
  6179. t1.sex AS sex,
  6180. t1.beh_dept_id AS behDeptId,
  6181. t1.beh_dept_name AS behDeptName,
  6182. t1.doctor_id AS doctorId,
  6183. t1.doctor_name AS doctorName,
  6184. t1.beh_doctor_id AS behDoctorId,
  6185. t1.beh_doctor_name AS behDoctorName,
  6186. t1.director_doctor_id AS directorDoctorId,
  6187. t1.director_doctor_name AS directorDoctorName,
  6188. t1.birthday AS birthday,
  6189. t1.behospital_date AS behospitalDate,
  6190. t1.leave_hospital_date AS leaveHospitalDate,
  6191. t1.placefile_date AS placefileDate,
  6192. t1.gmt_create AS gradeTime,
  6193. t1.diagnose,
  6194. t1.ward_name AS wardName,
  6195. t1.checkStatus,
  6196. t1.mrStatus,
  6197. t1.chName,
  6198. t1.mrName,
  6199. t1.chTime,
  6200. t1.mrTime,
  6201. t2.age,
  6202. t1.file_code AS fileCode
  6203. FROM
  6204. (
  6205. SELECT be.*,
  6206. ifnull(mci.status,0) AS checkStatus,
  6207. ifnull(hm_mci.status,0) AS mrStatus,
  6208. mci.check_name as chName,
  6209. e.score_res as scoreBn,
  6210. hm_mci.check_name as mrName,
  6211. mci.gmt_create as chTime,
  6212. hm_mci.gmt_create as mrTime
  6213. FROM
  6214. (
  6215. SELECT DISTINCT
  6216. tt1.*
  6217. FROM
  6218. (
  6219. SELECT
  6220. b.*,
  6221. ifnull(c.LEVEL,'未评分') as LEVEL ,
  6222. c.grade_type,
  6223. c.score_res,
  6224. c.gmt_create
  6225. FROM
  6226. (
  6227. SELECT DISTINCT
  6228. a.hospital_id,
  6229. a.behospital_code,
  6230. a.bed_code,
  6231. a.NAME,
  6232. a.sex,
  6233. a.beh_dept_id,
  6234. a.beh_dept_name,
  6235. a.birthday,
  6236. a.behospital_date,
  6237. a.leave_hospital_date,
  6238. a.doctor_id,
  6239. a.doctor_name,
  6240. a.beh_doctor_id,
  6241. a.beh_doctor_name,
  6242. a.director_doctor_id,
  6243. a.director_doctor_name,
  6244. a.diagnose,
  6245. a.placefile_date,
  6246. a.ward_name,
  6247. a.file_code
  6248. FROM
  6249. med_behospital_info a
  6250. WHERE
  6251. a.is_deleted = 'N'
  6252. AND a.qc_type_id != 0
  6253. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  6254. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  6255. </if>
  6256. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  6257. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  6258. </if>
  6259. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  6260. <if test="qcResultShortPageVO.startDate != null ">
  6261. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  6262. </if>
  6263. <if test="qcResultShortPageVO.endDate != null ">
  6264. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  6265. </if>
  6266. </if>
  6267. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  6268. <if test="qcResultShortPageVO.startDate != null ">
  6269. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  6270. </if>
  6271. <if test="qcResultShortPageVO.endDate != null">
  6272. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  6273. </if>
  6274. </if>
  6275. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  6276. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  6277. </if>
  6278. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  6279. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  6280. </if>
  6281. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  6282. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  6283. </if>
  6284. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  6285. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  6286. </if>
  6287. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  6288. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6289. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6290. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  6291. </if>
  6292. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  6293. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6294. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6295. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  6296. </if>
  6297. ) b
  6298. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  6299. AND b.hospital_id = c.hospital_id
  6300. AND b.behospital_code = c.behospital_code
  6301. ) tt1
  6302. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  6303. ,med_medical_record tt2,
  6304. qc_mode tt3
  6305. WHERE
  6306. tt2.is_deleted = 'N'
  6307. AND tt3.is_deleted = 'N'
  6308. AND tt1.hospital_id = tt2.hospital_id
  6309. AND tt1.behospital_code = tt2.behospital_code
  6310. AND tt2.mode_id = tt3.id
  6311. AND tt3.`name` = '手术记录'
  6312. </if>
  6313. ) be
  6314. left join med_check_info mci
  6315. on mci.is_deleted = 'N'
  6316. and mci.check_type = 0
  6317. and be.hospital_id = mci.hospital_id
  6318. and be.behospital_code = mci.behospital_code
  6319. left join med_check_info hm_mci
  6320. on hm_mci.is_deleted = 'N'
  6321. and hm_mci.check_type = 1
  6322. and be.hospital_id = hm_mci.hospital_id
  6323. and be.behospital_code = hm_mci.behospital_code
  6324. LEFT JOIN med_qcresult_cases e
  6325. on be.behospital_code = e.behospital_code
  6326. and be.hospital_id = e.hospital_id
  6327. AND e.is_deleted = 'N'
  6328. and e.cases_id = 243
  6329. )t1
  6330. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  6331. ,med_home_page t2
  6332. WHERE
  6333. t2.is_deleted = 'N'
  6334. AND t1.hospital_id = t2.hospital_id
  6335. AND t1.behospital_code = t2.behospital_code
  6336. AND (
  6337. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  6338. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  6339. )
  6340. </if>
  6341. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  6342. ,med_home_page t2
  6343. WHERE
  6344. t2.is_deleted = 'N'
  6345. AND t1.hospital_id = t2.hospital_id
  6346. AND t1.behospital_code = t2.behospital_code
  6347. AND t2.return_to_type = '死亡'
  6348. </if>
  6349. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  6350. ,med_home_page t2
  6351. WHERE
  6352. t2.is_deleted = 'N'
  6353. AND t1.hospital_id = t2.hospital_id
  6354. AND t1.behospital_code = t2.behospital_code
  6355. AND t2.leave_hospital_type = '非医嘱离院'
  6356. </if>
  6357. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  6358. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  6359. AND t1.hospital_id = t2.hospital_id
  6360. AND t1.behospital_code = t2.behospital_code
  6361. </if>
  6362. )t
  6363. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  6364. AND t.hospitalId = qi.hospital_id
  6365. AND t.behospitalCode = qi.behospital_code
  6366. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  6367. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  6368. AND t.hospitalId = qd.hospital_id
  6369. AND t.behospitalCode = qd.behospital_code
  6370. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  6371. AND qd.cases_id = qc.id
  6372. </if>
  6373. where 1=1
  6374. <if test="qcResultShortPageVO.checkStatus != null">
  6375. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6376. </if>
  6377. <if test="qcResultShortPageVO.mrStatus != null">
  6378. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6379. </if>
  6380. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6381. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6382. </if>
  6383. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6384. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6385. </if>
  6386. <if test="qcResultShortPageVO.chTimeStart != null ">
  6387. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6388. </if>
  6389. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6390. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6391. </if>
  6392. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6393. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6394. </if>
  6395. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6396. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6397. </if>
  6398. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  6399. AND t.`level` = #{qcResultShortPageVO.level}
  6400. </if>)f1,(SELECT
  6401. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  6402. t.behDeptId,
  6403. t.behDeptName
  6404. FROM
  6405. (SELECT DISTINCT
  6406. t1.hospital_id AS hospitalId,
  6407. t1.behospital_code AS behospitalCode,
  6408. t1.bed_code AS bedCode,
  6409. t1.LEVEL AS LEVEL,
  6410. t1.grade_type AS gradeType,
  6411. t1.score_res AS scoreRes,
  6412. t1.NAME AS NAME,
  6413. t1.sex AS sex,
  6414. t1.beh_dept_id AS behDeptId,
  6415. t1.beh_dept_name AS behDeptName,
  6416. t1.doctor_id AS doctorId,
  6417. t1.doctor_name AS doctorName,
  6418. t1.beh_doctor_id AS behDoctorId,
  6419. t1.beh_doctor_name AS behDoctorName,
  6420. t1.director_doctor_id AS directorDoctorId,
  6421. t1.director_doctor_name AS directorDoctorName,
  6422. t1.birthday AS birthday,
  6423. t1.behospital_date AS behospitalDate,
  6424. t1.leave_hospital_date AS leaveHospitalDate,
  6425. t1.placefile_date AS placefileDate,
  6426. t1.gmt_create AS gradeTime,
  6427. t1.diagnose,
  6428. t1.ward_name AS wardName,
  6429. t1.checkStatus,
  6430. t1.mrStatus,
  6431. t1.chName,
  6432. t1.mrName,
  6433. t1.chTime,
  6434. t1.mrTime,
  6435. t2.age,
  6436. t1.file_code AS fileCode
  6437. FROM
  6438. (
  6439. SELECT be.*,
  6440. ifnull(mci.status,0) AS checkStatus,
  6441. ifnull(hm_mci.status,0) AS mrStatus,
  6442. mci.check_name as chName,
  6443. hm_mci.check_name as mrName,
  6444. mci.gmt_create as chTime,
  6445. hm_mci.gmt_create as mrTime
  6446. FROM
  6447. (
  6448. SELECT DISTINCT
  6449. tt1.*
  6450. FROM
  6451. (
  6452. SELECT
  6453. b.*,
  6454. ifnull(c.LEVEL,'未评分') as LEVEL ,
  6455. c.grade_type,
  6456. c.score_res,
  6457. c.gmt_create
  6458. FROM
  6459. (
  6460. SELECT DISTINCT
  6461. a.hospital_id,
  6462. a.behospital_code,
  6463. a.bed_code,
  6464. a.NAME,
  6465. a.sex,
  6466. a.beh_dept_id,
  6467. a.beh_dept_name,
  6468. a.birthday,
  6469. a.behospital_date,
  6470. a.leave_hospital_date,
  6471. a.doctor_id,
  6472. a.doctor_name,
  6473. a.beh_doctor_id,
  6474. a.beh_doctor_name,
  6475. a.director_doctor_id,
  6476. a.director_doctor_name,
  6477. a.diagnose,
  6478. a.placefile_date,
  6479. a.ward_name,
  6480. a.file_code
  6481. FROM
  6482. med_behospital_info a
  6483. WHERE
  6484. a.is_deleted = 'N'
  6485. AND a.qc_type_id != 0
  6486. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  6487. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  6488. </if>
  6489. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  6490. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  6491. </if>
  6492. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  6493. <if test="qcResultShortPageVO.startDate != null ">
  6494. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  6495. </if>
  6496. <if test="qcResultShortPageVO.endDate != null ">
  6497. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  6498. </if>
  6499. </if>
  6500. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  6501. <if test="qcResultShortPageVO.startDate != null ">
  6502. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  6503. </if>
  6504. <if test="qcResultShortPageVO.endDate != null">
  6505. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  6506. </if>
  6507. </if>
  6508. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  6509. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  6510. </if>
  6511. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  6512. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  6513. </if>
  6514. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  6515. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  6516. </if>
  6517. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  6518. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  6519. </if>
  6520. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  6521. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6522. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  6523. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  6524. </if>
  6525. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  6526. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6527. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  6528. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  6529. </if>
  6530. ) b
  6531. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  6532. AND b.hospital_id = c.hospital_id
  6533. AND b.behospital_code = c.behospital_code
  6534. ) tt1
  6535. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  6536. ,med_medical_record tt2,
  6537. qc_mode tt3
  6538. WHERE
  6539. tt2.is_deleted = 'N'
  6540. AND tt3.is_deleted = 'N'
  6541. AND tt1.hospital_id = tt2.hospital_id
  6542. AND tt1.behospital_code = tt2.behospital_code
  6543. AND tt2.mode_id = tt3.id
  6544. AND tt3.`name` = '手术记录'
  6545. </if>
  6546. ) be
  6547. left join med_check_info mci
  6548. on mci.is_deleted = 'N'
  6549. and mci.check_type = 0
  6550. and be.hospital_id = mci.hospital_id
  6551. and be.behospital_code = mci.behospital_code
  6552. left join med_check_info hm_mci
  6553. on hm_mci.is_deleted = 'N'
  6554. and hm_mci.check_type = 1
  6555. and be.hospital_id = hm_mci.hospital_id
  6556. and be.behospital_code = hm_mci.behospital_code
  6557. )t1
  6558. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  6559. ,med_home_page t2
  6560. WHERE
  6561. t2.is_deleted = 'N'
  6562. AND t1.hospital_id = t2.hospital_id
  6563. AND t1.behospital_code = t2.behospital_code
  6564. AND (
  6565. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-'AND t2.newborn_day != '—' )
  6566. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  6567. )
  6568. </if>
  6569. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  6570. ,med_home_page t2
  6571. WHERE
  6572. t2.is_deleted = 'N'
  6573. AND t1.hospital_id = t2.hospital_id
  6574. AND t1.behospital_code = t2.behospital_code
  6575. AND t2.return_to_type = '死亡'
  6576. </if>
  6577. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  6578. ,med_home_page t2
  6579. WHERE
  6580. t2.is_deleted = 'N'
  6581. AND t1.hospital_id = t2.hospital_id
  6582. AND t1.behospital_code = t2.behospital_code
  6583. AND t2.leave_hospital_type = '非医嘱离院'
  6584. </if>
  6585. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  6586. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  6587. AND t1.hospital_id = t2.hospital_id
  6588. AND t1.behospital_code = t2.behospital_code
  6589. </if>
  6590. )t
  6591. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  6592. AND t.hospitalId = qi.hospital_id
  6593. AND t.behospitalCode = qi.behospital_code
  6594. where 1=1
  6595. <if test="qcResultShortPageVO.checkStatus != null">
  6596. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6597. </if>
  6598. <if test="qcResultShortPageVO.mrStatus != null">
  6599. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6600. </if>
  6601. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6602. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6603. </if>
  6604. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6605. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6606. </if>
  6607. <if test="qcResultShortPageVO.chTimeStart != null ">
  6608. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6609. </if>
  6610. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6611. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6612. </if>
  6613. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6614. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6615. </if>
  6616. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6617. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6618. </if>
  6619. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  6620. AND t.`level` = #{qcResultShortPageVO.level}
  6621. </if>
  6622. GROUP BY
  6623. t.behDeptId,
  6624. t.behDeptName
  6625. )f2
  6626. WHERE
  6627. f1.behDeptId = f2.behDeptId
  6628. AND f1.behDeptName = f2.behDeptName
  6629. </select>
  6630. <!-- 离院病人评分详情页导出-科室-->
  6631. <select id="leaveHosMRPageExportByDept" resultMap="ExportExcelMapByDept">
  6632. SELECT
  6633. f1.behDeptId,
  6634. f1.behDeptName,
  6635. f1.doctorName,
  6636. f1.patName,
  6637. f1.behospitalCode,
  6638. f1.hospitalId,
  6639. f1.behospitalDate,
  6640. f1.leaveHospitalDate,
  6641. f1.score,
  6642. f1.medoupName,
  6643. f1.wardName,
  6644. f2.avgScore,
  6645. f1.scoreBn,
  6646. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  6647. f1.msg,
  6648. f1.caseName,
  6649. </if>
  6650. f1.checkStatus,
  6651. f1.mrStatus,
  6652. f1.chName,
  6653. f1.mrName,
  6654. f1.chTime,
  6655. f1.mrTime
  6656. FROM
  6657. (SELECT
  6658. t.doctorName,
  6659. t.doctorId,
  6660. t.`name` AS patName,
  6661. t3.name as medoupName,
  6662. t.behospitalCode AS behospitalCode,
  6663. t.behospitalDate AS behospitalDate,
  6664. t.leaveHospitalDate AS leaveHospitalDate,
  6665. qi.score_res AS score,
  6666. t.scoreBn,
  6667. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  6668. qd.msg AS msg,
  6669. qc.NAME AS caseName,
  6670. </if>
  6671. t.behDeptId,
  6672. t.behDeptName,
  6673. t.wardName,
  6674. t.hospitalId,
  6675. t.checkStatus,
  6676. t.mrStatus,
  6677. t.chName,
  6678. t.mrName,
  6679. t.chTime,
  6680. t.mrTime
  6681. FROM
  6682. (SELECT DISTINCT
  6683. t1.hospital_id AS hospitalId,
  6684. t1.behospital_code AS behospitalCode,
  6685. t1.bed_code AS bedCode,
  6686. t1.LEVEL AS LEVEL,
  6687. t1.grade_type AS gradeType,
  6688. t1.score_res AS scoreRes,
  6689. t1.scoreBn,
  6690. t1.NAME AS NAME,
  6691. t1.sex AS sex,
  6692. t1.beh_dept_id AS behDeptId,
  6693. t1.beh_dept_name AS behDeptName,
  6694. t1.doctor_id AS doctorId,
  6695. t1.doctor_name AS doctorName,
  6696. t1.beh_doctor_id AS behDoctorId,
  6697. t1.beh_doctor_name AS behDoctorName,
  6698. t1.director_doctor_id AS directorDoctorId,
  6699. t1.director_doctor_name AS directorDoctorName,
  6700. t1.birthday AS birthday,
  6701. t1.behospital_date AS behospitalDate,
  6702. t1.leave_hospital_date AS leaveHospitalDate,
  6703. t1.placefile_date AS placefileDate,
  6704. t1.gmt_create AS gradeTime,
  6705. t1.diagnose,
  6706. t1.ward_name AS wardName,
  6707. t1.checkStatus,
  6708. t1.mrStatus,
  6709. t1.chName,
  6710. t1.mrName,
  6711. t1.chTime,
  6712. t1.mrTime,
  6713. t2.age,
  6714. t1.file_code AS fileCode
  6715. FROM
  6716. (
  6717. SELECT be.*,
  6718. ifnull(mci.status,0) AS checkStatus,
  6719. ifnull(hm_mci.status,0) AS mrStatus,
  6720. mci.check_name as chName,
  6721. e.score_res as scoreBn,
  6722. hm_mci.check_name as mrName,
  6723. mci.gmt_create as chTime,
  6724. hm_mci.gmt_create as mrTime
  6725. FROM
  6726. (
  6727. SELECT DISTINCT
  6728. tt1.*
  6729. FROM
  6730. (
  6731. SELECT
  6732. b.*,
  6733. ifnull(c.LEVEL,'未评分') as LEVEL ,
  6734. c.grade_type,
  6735. c.score_res,
  6736. c.gmt_create
  6737. FROM
  6738. (
  6739. SELECT DISTINCT
  6740. a.hospital_id,
  6741. a.behospital_code,
  6742. a.bed_code,
  6743. a.NAME,
  6744. a.sex,
  6745. a.beh_dept_id,
  6746. a.beh_dept_name,
  6747. a.birthday,
  6748. a.behospital_date,
  6749. a.leave_hospital_date,
  6750. a.doctor_id,
  6751. a.doctor_name,
  6752. a.beh_doctor_id,
  6753. a.beh_doctor_name,
  6754. a.director_doctor_id,
  6755. a.director_doctor_name,
  6756. a.diagnose,
  6757. a.placefile_date,
  6758. a.ward_name,
  6759. a.file_code
  6760. FROM
  6761. med_behospital_info a,
  6762. sys_user_dept b
  6763. WHERE
  6764. a.is_deleted = 'N'
  6765. AND b.is_deleted = 'N'
  6766. AND a.hospital_id = b.hospital_id
  6767. AND a.beh_dept_id = b.dept_id
  6768. AND a.qc_type_id != 0
  6769. <if test="qcResultShortPageVO.userId!=null">
  6770. AND b.user_id = #{qcResultShortPageVO.userId}
  6771. </if>
  6772. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  6773. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  6774. </if>
  6775. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  6776. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  6777. </if>
  6778. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  6779. <if test="qcResultShortPageVO.startDate != null ">
  6780. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  6781. </if>
  6782. <if test="qcResultShortPageVO.endDate != null ">
  6783. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  6784. </if>
  6785. </if>
  6786. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  6787. <if test="qcResultShortPageVO.startDate != null ">
  6788. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  6789. </if>
  6790. <if test="qcResultShortPageVO.endDate != null">
  6791. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  6792. </if>
  6793. </if>
  6794. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  6795. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  6796. </if>
  6797. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  6798. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  6799. </if>
  6800. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  6801. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  6802. </if>
  6803. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  6804. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  6805. </if>
  6806. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  6807. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  6808. </if>
  6809. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  6810. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  6811. </if>
  6812. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  6813. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  6814. </if>
  6815. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  6816. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  6817. </if>
  6818. ) b
  6819. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  6820. AND b.hospital_id = c.hospital_id
  6821. AND b.behospital_code = c.behospital_code
  6822. ) tt1
  6823. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  6824. ,med_medical_record tt2,
  6825. qc_mode tt3
  6826. WHERE
  6827. tt2.is_deleted = 'N'
  6828. AND tt3.is_deleted = 'N'
  6829. AND tt1.hospital_id = tt2.hospital_id
  6830. AND tt1.behospital_code = tt2.behospital_code
  6831. AND tt2.mode_id = tt3.id
  6832. AND tt3.`name` = '手术记录'
  6833. </if>
  6834. ) be
  6835. left join med_check_info mci
  6836. on mci.is_deleted = 'N'
  6837. and mci.check_type = 0
  6838. and be.hospital_id = mci.hospital_id
  6839. and be.behospital_code = mci.behospital_code
  6840. left join med_check_info hm_mci
  6841. on hm_mci.is_deleted = 'N'
  6842. and hm_mci.check_type = 1
  6843. and be.hospital_id = hm_mci.hospital_id
  6844. and be.behospital_code = hm_mci.behospital_code
  6845. LEFT JOIN med_qcresult_cases e
  6846. on be.behospital_code = e.behospital_code
  6847. and be.hospital_id = e.hospital_id
  6848. AND e.is_deleted = 'N'
  6849. and e.cases_id = 243
  6850. )t1
  6851. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  6852. ,med_home_page t2
  6853. WHERE
  6854. t2.is_deleted = 'N'
  6855. AND t1.hospital_id = t2.hospital_id
  6856. AND t1.behospital_code = t2.behospital_code
  6857. AND (
  6858. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  6859. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-' AND t2.newborn_month != '—')
  6860. )
  6861. </if>
  6862. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  6863. ,med_home_page t2
  6864. WHERE
  6865. t2.is_deleted = 'N'
  6866. AND t1.hospital_id = t2.hospital_id
  6867. AND t1.behospital_code = t2.behospital_code
  6868. AND t2.return_to_type = '死亡'
  6869. </if>
  6870. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  6871. ,med_home_page t2
  6872. WHERE
  6873. t2.is_deleted = 'N'
  6874. AND t1.hospital_id = t2.hospital_id
  6875. AND t1.behospital_code = t2.behospital_code
  6876. AND t2.leave_hospital_type = '非医嘱离院'
  6877. </if>
  6878. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  6879. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  6880. AND t1.hospital_id = t2.hospital_id
  6881. AND t1.behospital_code = t2.behospital_code
  6882. </if>
  6883. )t
  6884. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  6885. AND t.hospitalId = qi.hospital_id
  6886. AND t.behospitalCode = qi.behospital_code
  6887. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  6888. AND t.hospitalId = t2.hospital_id
  6889. AND t2.is_deleted = 'N'
  6890. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  6891. AND t3.is_deleted = 'N'
  6892. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  6893. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  6894. AND t.hospitalId = qd.hospital_id
  6895. AND t.behospitalCode = qd.behospital_code
  6896. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  6897. AND qd.cases_id = qc.id
  6898. </if>
  6899. where 1=1
  6900. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  6901. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  6902. </if>
  6903. <if test="qcResultShortPageVO.checkStatus != null">
  6904. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  6905. </if>
  6906. <if test="qcResultShortPageVO.mrStatus != null">
  6907. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  6908. </if>
  6909. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  6910. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  6911. </if>
  6912. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  6913. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  6914. </if>
  6915. <if test="qcResultShortPageVO.chTimeStart != null ">
  6916. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  6917. </if>
  6918. <if test="qcResultShortPageVO.chTimeEnd != null ">
  6919. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  6920. </if>
  6921. <if test="qcResultShortPageVO.mrTimeStart != null ">
  6922. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  6923. </if>
  6924. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  6925. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  6926. </if>
  6927. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  6928. AND t.`level` = #{qcResultShortPageVO.level}
  6929. </if>)f1,(SELECT
  6930. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  6931. t.behDeptId,
  6932. t.behDeptName,
  6933. t.doctorId,
  6934. t.doctorName
  6935. FROM
  6936. (SELECT DISTINCT
  6937. t1.hospital_id AS hospitalId,
  6938. t1.behospital_code AS behospitalCode,
  6939. t1.bed_code AS bedCode,
  6940. t1.LEVEL AS LEVEL,
  6941. t1.grade_type AS gradeType,
  6942. t1.score_res AS scoreRes,
  6943. t1.NAME AS NAME,
  6944. t1.sex AS sex,
  6945. t1.beh_dept_id AS behDeptId,
  6946. t1.beh_dept_name AS behDeptName,
  6947. t1.doctor_id AS doctorId,
  6948. t1.doctor_name AS doctorName,
  6949. t1.beh_doctor_id AS behDoctorId,
  6950. t1.beh_doctor_name AS behDoctorName,
  6951. t1.director_doctor_id AS directorDoctorId,
  6952. t1.director_doctor_name AS directorDoctorName,
  6953. t1.birthday AS birthday,
  6954. t1.behospital_date AS behospitalDate,
  6955. t1.leave_hospital_date AS leaveHospitalDate,
  6956. t1.placefile_date AS placefileDate,
  6957. t1.gmt_create AS gradeTime,
  6958. t1.diagnose,
  6959. t1.ward_name AS wardName,
  6960. t1.checkStatus,
  6961. t1.mrStatus,
  6962. t1.chName,
  6963. t1.mrName,
  6964. t1.chTime,
  6965. t1.mrTime,
  6966. t2.age,
  6967. t1.file_code AS fileCode
  6968. FROM
  6969. (
  6970. SELECT be.*,
  6971. ifnull(mci.status,0) AS checkStatus,
  6972. ifnull(hm_mci.status,0) AS mrStatus,
  6973. mci.check_name as chName,
  6974. hm_mci.check_name as mrName,
  6975. mci.gmt_create as chTime,
  6976. hm_mci.gmt_create as mrTime
  6977. FROM
  6978. (
  6979. SELECT DISTINCT
  6980. tt1.*
  6981. FROM
  6982. (
  6983. SELECT
  6984. b.*,
  6985. ifnull(c.LEVEL,'未评分') as LEVEL ,
  6986. c.grade_type,
  6987. c.score_res,
  6988. c.gmt_create
  6989. FROM
  6990. (
  6991. SELECT DISTINCT
  6992. a.hospital_id,
  6993. a.behospital_code,
  6994. a.bed_code,
  6995. a.NAME,
  6996. a.sex,
  6997. a.beh_dept_id,
  6998. a.beh_dept_name,
  6999. a.birthday,
  7000. a.behospital_date,
  7001. a.leave_hospital_date,
  7002. a.doctor_id,
  7003. a.doctor_name,
  7004. a.beh_doctor_id,
  7005. a.beh_doctor_name,
  7006. a.director_doctor_id,
  7007. a.director_doctor_name,
  7008. a.diagnose,
  7009. a.placefile_date,
  7010. a.ward_name,
  7011. a.file_code
  7012. FROM
  7013. med_behospital_info a,
  7014. sys_user_dept b
  7015. WHERE
  7016. a.is_deleted = 'N'
  7017. AND b.is_deleted = 'N'
  7018. AND a.hospital_id = b.hospital_id
  7019. AND a.beh_dept_id = b.dept_id
  7020. AND a.qc_type_id != 0
  7021. <if test="qcResultShortPageVO.userId!=null">
  7022. AND b.user_id = #{qcResultShortPageVO.userId}
  7023. </if>
  7024. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7025. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7026. </if>
  7027. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7028. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7029. </if>
  7030. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7031. <if test="qcResultShortPageVO.startDate != null ">
  7032. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7033. </if>
  7034. <if test="qcResultShortPageVO.endDate != null ">
  7035. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7036. </if>
  7037. </if>
  7038. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7039. <if test="qcResultShortPageVO.startDate != null ">
  7040. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7041. </if>
  7042. <if test="qcResultShortPageVO.endDate != null">
  7043. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7044. </if>
  7045. </if>
  7046. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7047. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7048. </if>
  7049. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  7050. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  7051. </if>
  7052. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7053. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7054. </if>
  7055. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  7056. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  7057. </if>
  7058. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7059. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7060. </if>
  7061. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7062. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7063. </if>
  7064. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7065. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  7066. </if>
  7067. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7068. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  7069. </if>
  7070. ) b
  7071. LEFT JOIN med_qcresult_info c ON c.is_deleted = 'N'
  7072. AND b.hospital_id = c.hospital_id
  7073. AND b.behospital_code = c.behospital_code
  7074. ) tt1
  7075. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==3">
  7076. ,med_medical_record tt2,
  7077. qc_mode tt3
  7078. WHERE
  7079. tt2.is_deleted = 'N'
  7080. AND tt3.is_deleted = 'N'
  7081. AND tt1.hospital_id = tt2.hospital_id
  7082. AND tt1.behospital_code = tt2.behospital_code
  7083. AND tt2.mode_id = tt3.id
  7084. AND tt3.`name` = '手术记录'
  7085. </if>
  7086. ) be
  7087. left join med_check_info mci
  7088. on mci.is_deleted = 'N'
  7089. and mci.check_type = 0
  7090. and be.hospital_id = mci.hospital_id
  7091. and be.behospital_code = mci.behospital_code
  7092. left join med_check_info hm_mci
  7093. on hm_mci.is_deleted = 'N'
  7094. and hm_mci.check_type = 1
  7095. and be.hospital_id = hm_mci.hospital_id
  7096. and be.behospital_code = hm_mci.behospital_code
  7097. )t1
  7098. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==2">
  7099. ,med_home_page t2
  7100. WHERE
  7101. t2.is_deleted = 'N'
  7102. AND t1.hospital_id = t2.hospital_id
  7103. AND t1.behospital_code = t2.behospital_code
  7104. AND (
  7105. ( IFNULL( t2.newborn_day, '' ) != '' AND t2.newborn_day != '0' AND t2.newborn_day != '-' AND t2.newborn_day != '—')
  7106. OR ( IFNULL( t2.newborn_month, '' )!= '' AND t2.newborn_month != '0' AND t2.newborn_month != '-'AND t2.newborn_month != '—' )
  7107. )
  7108. </if>
  7109. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==1">
  7110. ,med_home_page t2
  7111. WHERE
  7112. t2.is_deleted = 'N'
  7113. AND t1.hospital_id = t2.hospital_id
  7114. AND t1.behospital_code = t2.behospital_code
  7115. AND t2.return_to_type = '死亡'
  7116. </if>
  7117. <if test="qcResultShortPageVO.leaveHosType != null and qcResultShortPageVO.leaveHosType ==4">
  7118. ,med_home_page t2
  7119. WHERE
  7120. t2.is_deleted = 'N'
  7121. AND t1.hospital_id = t2.hospital_id
  7122. AND t1.behospital_code = t2.behospital_code
  7123. AND t2.leave_hospital_type = '非医嘱离院'
  7124. </if>
  7125. <if test="qcResultShortPageVO.leaveHosType == null or qcResultShortPageVO.leaveHosType == 0 or qcResultShortPageVO.leaveHosType == 3">
  7126. LEFT JOIN med_home_page t2 ON t2.is_deleted = 'N'
  7127. AND t1.hospital_id = t2.hospital_id
  7128. AND t1.behospital_code = t2.behospital_code
  7129. </if>
  7130. )t
  7131. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  7132. AND t.hospitalId = qi.hospital_id
  7133. AND t.behospitalCode = qi.behospital_code
  7134. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  7135. AND t.hospitalId = t2.hospital_id
  7136. AND t2.is_deleted = 'N'
  7137. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  7138. AND t3.is_deleted = 'N'
  7139. where 1=1
  7140. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  7141. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  7142. </if>
  7143. <if test="qcResultShortPageVO.checkStatus != null">
  7144. and t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7145. </if>
  7146. <if test="qcResultShortPageVO.mrStatus != null">
  7147. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7148. </if>
  7149. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7150. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7151. </if>
  7152. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7153. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7154. </if>
  7155. <if test="qcResultShortPageVO.chTimeStart != null ">
  7156. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7157. </if>
  7158. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7159. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7160. </if>
  7161. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7162. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7163. </if>
  7164. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7165. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7166. </if>
  7167. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7168. AND t.`level` = #{qcResultShortPageVO.level}
  7169. </if>
  7170. GROUP BY
  7171. t.behDeptId,
  7172. t.behDeptName,
  7173. t.doctorId,
  7174. t.doctorName
  7175. )f2
  7176. WHERE
  7177. f1.doctorId = f2.doctorId
  7178. AND f1.doctorName = f2.doctorName
  7179. </select>
  7180. <!--缺陷详情质控评分页导出-科室-->
  7181. <select id="qcResultShortByDeptPageExport" resultMap="ExportExcelMapByDept">
  7182. SELECT
  7183. f1.*,
  7184. f2.avgScore
  7185. FROM
  7186. (SELECT
  7187. t.*,
  7188. qi.score_res AS score,
  7189. qd.msg AS msg,
  7190. qc.NAME AS caseName
  7191. FROM
  7192. (SELECT DISTINCT
  7193. t1.hospital_id AS hospitalId,
  7194. t1.behospital_code AS behospitalCode,
  7195. t1.bed_code AS bedCode,
  7196. t1.LEVEL AS LEVEL,
  7197. t1.grade_type AS gradeType,
  7198. t1.score_res AS scoreRes,
  7199. t1.scoreBn AS scoreBn,
  7200. t1.NAME AS patName,
  7201. t1.medoupName,
  7202. t1.sex AS sex,
  7203. t1.beh_dept_id AS behDeptId,
  7204. t1.beh_dept_name AS behDeptName,
  7205. t1.doctor_id AS doctorId,
  7206. t1.doctor_name AS doctorName,
  7207. t1.beh_doctor_id AS behDoctorId,
  7208. t1.beh_doctor_name AS behDoctorName,
  7209. t1.director_doctor_id AS directorDoctorId,
  7210. t1.director_doctor_name AS directorDoctorName,
  7211. t1.birthday AS birthday,
  7212. t1.behospital_date AS behospitalDate,
  7213. t1.leave_hospital_date AS leaveHospitalDate,
  7214. t1.placefile_date AS placefileDate,
  7215. t1.gmt_create AS gradeTime,
  7216. t1.diagnose AS diagnose,
  7217. t1.ward_name AS wardName,
  7218. t1.file_code AS fileCode,
  7219. t1.checkStatus AS checkStatus,
  7220. t1.mrStatus AS mrStatus,
  7221. t1.chName AS chName,
  7222. t1.mrName AS mrName,
  7223. t1.chTime AS chTime,
  7224. t1.mrTime AS mrTime
  7225. FROM
  7226. (
  7227. SELECT DISTINCT
  7228. tt1.*
  7229. FROM
  7230. (SELECT
  7231. be.*,
  7232. t3.name as medoupName,
  7233. ifnull(mci.status,0) AS checkStatus,
  7234. ifnull(hm_mci.status,0) AS mrStatus,
  7235. mci.check_name as chName,
  7236. hm_mci.check_name as mrName,
  7237. mci.gmt_create as chTime,
  7238. e.score_res as scoreBn,
  7239. hm_mci.gmt_create as mrTime
  7240. FROM
  7241. (
  7242. SELECT DISTINCT
  7243. a.hospital_id,
  7244. a.behospital_code,
  7245. a.bed_code,
  7246. a.file_code,
  7247. b.LEVEL,
  7248. b.grade_type,
  7249. b.score_res,
  7250. a.NAME,
  7251. a.sex,
  7252. a.beh_dept_id,
  7253. a.beh_dept_name,
  7254. a.birthday,
  7255. a.behospital_date,
  7256. a.leave_hospital_date,
  7257. a.doctor_id,
  7258. a.doctor_name,
  7259. a.beh_doctor_id,
  7260. a.beh_doctor_name,
  7261. a.director_doctor_id,
  7262. a.director_doctor_name,
  7263. a.diagnose,
  7264. a.placefile_date,
  7265. a.ward_name,
  7266. b.gmt_create
  7267. FROM
  7268. med_behospital_info a,
  7269. med_qcresult_info b,
  7270. med_qcresult_detail c,
  7271. qc_cases_entry d,
  7272. sys_user_dept e
  7273. WHERE
  7274. a.is_deleted = 'N'
  7275. AND b.is_deleted = 'N'
  7276. AND c.is_deleted = 'N'
  7277. AND d.is_deleted = 'N'
  7278. AND e.is_deleted = 'N'
  7279. AND a.hospital_id = b.hospital_id
  7280. AND a.hospital_id = c.hospital_id
  7281. AND a.hospital_id = e.hospital_id
  7282. AND a.behospital_code = b.behospital_code
  7283. AND a.behospital_code = c.behospital_code
  7284. AND a.beh_dept_id = e.dept_id
  7285. AND c.cases_id = d.cases_id
  7286. AND c.cases_entry_id = d.id
  7287. AND a.qc_type_id != 0
  7288. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7289. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7290. </if>
  7291. <if test="qcResultShortPageVO.userId != null and qcResultShortPageVO.userId != ''">
  7292. AND e.user_id = #{qcResultShortPageVO.userId}
  7293. </if>
  7294. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7295. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7296. </if>
  7297. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7298. <if test="qcResultShortPageVO.startDate != null ">
  7299. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7300. </if>
  7301. <if test="qcResultShortPageVO.endDate != null ">
  7302. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7303. </if>
  7304. </if>
  7305. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7306. <if test="qcResultShortPageVO.startDate != null ">
  7307. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7308. </if>
  7309. <if test="qcResultShortPageVO.endDate != null">
  7310. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7311. </if>
  7312. </if>
  7313. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7314. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7315. </if>
  7316. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  7317. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  7318. </if>
  7319. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7320. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7321. </if>
  7322. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  7323. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  7324. </if>
  7325. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7326. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  7327. </if>
  7328. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7329. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  7330. </if>
  7331. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7332. AND b.`level` = #{qcResultShortPageVO.level}
  7333. </if>
  7334. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7335. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7336. </if>
  7337. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7338. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7339. </if>
  7340. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  7341. AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
  7342. </if>
  7343. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
  7344. AND d.id = #{qcResultShortPageVO.casesEntryId}
  7345. </if>
  7346. <if test="qcResultShortPageVO.isReject != null">
  7347. AND c.is_reject = #{qcResultShortPageVO.isReject}
  7348. </if>
  7349. <if test="qcResultShortPageVO.ruleType != null">
  7350. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  7351. </if>
  7352. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  7353. AND TIMESTAMPDIFF(
  7354. DAY,
  7355. DATE( a.behospital_date ),
  7356. DATE( a.leave_hospital_date ))> 30
  7357. </if>
  7358. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  7359. AND TIMESTAMPDIFF(
  7360. DAY,
  7361. DATE( a.behospital_date ),
  7362. DATE( a.leave_hospital_date ))> 31
  7363. </if>
  7364. )be
  7365. left join med_check_info mci
  7366. on mci.is_deleted = 'N'
  7367. and mci.check_type = 0
  7368. and be.hospital_id = mci.hospital_id
  7369. and be.behospital_code = mci.behospital_code
  7370. left join med_check_info hm_mci
  7371. on hm_mci.is_deleted = 'N'
  7372. and hm_mci.check_type = 1
  7373. and be.hospital_id = hm_mci.hospital_id
  7374. and be.behospital_code = hm_mci.behospital_code
  7375. LEFT JOIN med_qcresult_cases e
  7376. on be.behospital_code = e.behospital_code
  7377. and be.hospital_id = e.hospital_id
  7378. AND e.is_deleted = 'N'
  7379. and e.cases_id = 243
  7380. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  7381. and be.hospital_id = t2.hospital_id
  7382. AND t2.is_deleted = 'N'
  7383. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  7384. AND t3.is_deleted = 'N'
  7385. )tt1
  7386. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  7387. ,med_medical_record tt2
  7388. WHERE
  7389. tt2.is_deleted = 'N'
  7390. AND tt1.hospital_id = tt2.hospital_id
  7391. AND tt1.behospital_code = tt2.behospital_code
  7392. AND tt2.mode_id = 30
  7393. </if>
  7394. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  7395. ,med_crisis_info tt2
  7396. WHERE
  7397. tt2.is_deleted = 'N'
  7398. AND tt1.hospital_id = tt2.hospital_id
  7399. AND tt1.behospital_code = tt2.behospital_code
  7400. </if>
  7401. ) t1
  7402. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  7403. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  7404. AND t1.behospital_code = t2.behospital_code
  7405. AND t2.is_deleted = 'N'
  7406. </if>
  7407. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  7408. , med_home_page t2
  7409. , med_home_operation_info t3
  7410. WHERE t1.hospital_id = t2.hospital_id
  7411. AND t1.behospital_code = t2.behospital_code
  7412. AND t2.home_page_id = t3.home_page_id
  7413. AND t2.is_deleted = 'N'
  7414. AND t3.is_deleted = 'N'
  7415. </if>
  7416. ) t
  7417. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  7418. AND t.hospitalId = qi.hospital_id
  7419. AND t.behospitalCode = qi.behospital_code
  7420. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  7421. AND t.hospitalId = qd.hospital_id
  7422. AND t.behospitalCode = qd.behospital_code
  7423. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  7424. AND qd.cases_id = qc.id
  7425. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  7426. AND qd.cases_id = qce.cases_id
  7427. AND qd.cases_entry_id = qce.id
  7428. where 1=1
  7429. <if test="qcResultShortPageVO.checkStatus != null">
  7430. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7431. </if>
  7432. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  7433. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  7434. </if>
  7435. <if test="qcResultShortPageVO.mrStatus != null">
  7436. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7437. </if>
  7438. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7439. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7440. </if>
  7441. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7442. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7443. </if>
  7444. <if test="qcResultShortPageVO.chTimeStart != null ">
  7445. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7446. </if>
  7447. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7448. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7449. </if>
  7450. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7451. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7452. </if>
  7453. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7454. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7455. </if>
  7456. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  7457. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  7458. </if>
  7459. <if test="qcResultShortPageVO.casesEntryId != null ">
  7460. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  7461. </if>
  7462. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  7463. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  7464. </if>
  7465. <if test="qcResultShortPageVO.casesId != null">
  7466. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  7467. </if>
  7468. )f1,
  7469. (SELECT
  7470. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  7471. t.behDeptId,
  7472. t.behDeptName,
  7473. t.doctorId,
  7474. t.doctorName
  7475. FROM
  7476. (SELECT DISTINCT
  7477. t1.hospital_id AS hospitalId,
  7478. t1.behospital_code AS behospitalCode,
  7479. t1.bed_code AS bedCode,
  7480. t1.LEVEL AS LEVEL,
  7481. t1.grade_type AS gradeType,
  7482. t1.score_res AS scoreRes,
  7483. t1.NAME AS NAME,
  7484. t1.medoupName,
  7485. t1.sex AS sex,
  7486. t1.beh_dept_id AS behDeptId,
  7487. t1.beh_dept_name AS behDeptName,
  7488. t1.doctor_id AS doctorId,
  7489. t1.doctor_name AS doctorName,
  7490. t1.beh_doctor_id AS behDoctorId,
  7491. t1.beh_doctor_name AS behDoctorName,
  7492. t1.director_doctor_id AS directorDoctorId,
  7493. t1.director_doctor_name AS directorDoctorName,
  7494. t1.birthday AS birthday,
  7495. t1.behospital_date AS behospitalDate,
  7496. t1.leave_hospital_date AS leaveHospitalDate,
  7497. t1.placefile_date AS placefileDate,
  7498. t1.gmt_create AS gradeTime,
  7499. t1.diagnose,
  7500. t1.ward_name AS wardName,
  7501. t2.age,
  7502. t1.file_code AS fileCode,
  7503. t1.checkStatus,
  7504. t1.mrStatus,
  7505. t1.chName,
  7506. t1.mrName,
  7507. t1.chTime,
  7508. t1.mrTime
  7509. FROM
  7510. (
  7511. SELECT DISTINCT
  7512. tt1.*
  7513. FROM
  7514. (SELECT
  7515. be.*,
  7516. t3.name as medoupName,
  7517. ifnull(mci.status,0) AS checkStatus,
  7518. ifnull(hm_mci.status,0) AS mrStatus,
  7519. mci.check_name as chName,
  7520. hm_mci.check_name as mrName,
  7521. mci.gmt_create as chTime,
  7522. hm_mci.gmt_create as mrTime
  7523. FROM
  7524. (
  7525. SELECT DISTINCT
  7526. a.hospital_id,
  7527. a.behospital_code,
  7528. a.bed_code,
  7529. a.file_code,
  7530. b.LEVEL,
  7531. b.grade_type,
  7532. b.score_res,
  7533. a.NAME,
  7534. a.sex,
  7535. a.beh_dept_id,
  7536. a.beh_dept_name,
  7537. a.birthday,
  7538. a.behospital_date,
  7539. a.leave_hospital_date,
  7540. a.doctor_id,
  7541. a.doctor_name,
  7542. a.beh_doctor_id,
  7543. a.beh_doctor_name,
  7544. a.director_doctor_id,
  7545. a.director_doctor_name,
  7546. a.diagnose,
  7547. a.placefile_date,
  7548. a.ward_name,
  7549. b.gmt_create
  7550. FROM
  7551. med_behospital_info a,
  7552. med_qcresult_info b,
  7553. med_qcresult_detail c,
  7554. qc_cases_entry d,
  7555. sys_user_dept e
  7556. WHERE
  7557. a.is_deleted = 'N'
  7558. AND b.is_deleted = 'N'
  7559. AND c.is_deleted = 'N'
  7560. AND d.is_deleted = 'N'
  7561. AND e.is_deleted = 'N'
  7562. AND a.hospital_id = b.hospital_id
  7563. AND a.hospital_id = c.hospital_id
  7564. AND a.hospital_id = e.hospital_id
  7565. AND a.behospital_code = b.behospital_code
  7566. AND a.behospital_code = c.behospital_code
  7567. AND a.beh_dept_id = e.dept_id
  7568. AND c.cases_id = d.cases_id
  7569. AND c.cases_entry_id = d.id
  7570. AND a.qc_type_id != 0
  7571. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7572. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7573. </if>
  7574. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7575. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7576. </if>
  7577. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7578. <if test="qcResultShortPageVO.startDate != null ">
  7579. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7580. </if>
  7581. <if test="qcResultShortPageVO.endDate != null ">
  7582. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7583. </if>
  7584. </if>
  7585. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7586. <if test="qcResultShortPageVO.startDate != null ">
  7587. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7588. </if>
  7589. <if test="qcResultShortPageVO.endDate != null">
  7590. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7591. </if>
  7592. </if>
  7593. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7594. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7595. </if>
  7596. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  7597. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  7598. </if>
  7599. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7600. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7601. </if>
  7602. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  7603. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  7604. </if>
  7605. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7606. AND b.`level` = #{qcResultShortPageVO.level}
  7607. </if>
  7608. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7609. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7610. </if>
  7611. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7612. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7613. </if>
  7614. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  7615. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  7616. </if>
  7617. <if test="qcResultShortPageVO.casesEntryId != null ">
  7618. AND d.id = #{qcResultShortPageVO.casesEntryId}
  7619. </if>
  7620. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  7621. AND d.cases_name = #{qcResultShortPageVO.casesName}
  7622. </if>
  7623. <if test="qcResultShortPageVO.casesId != null">
  7624. AND d.cases_id = #{qcResultShortPageVO.casesId}
  7625. </if>
  7626. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7627. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  7628. </if>
  7629. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7630. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  7631. </if>
  7632. <if test="qcResultShortPageVO.isReject != null">
  7633. AND c.is_reject = #{qcResultShortPageVO.isReject}
  7634. </if>
  7635. <if test="qcResultShortPageVO.ruleType != null">
  7636. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  7637. </if>
  7638. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  7639. AND TIMESTAMPDIFF(
  7640. DAY,
  7641. DATE( a.behospital_date ),
  7642. DATE( a.leave_hospital_date ))> 30
  7643. </if>
  7644. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  7645. AND TIMESTAMPDIFF(
  7646. DAY,
  7647. DATE( a.behospital_date ),
  7648. DATE( a.leave_hospital_date ))> 31
  7649. </if>
  7650. )be
  7651. left join med_check_info mci
  7652. on mci.is_deleted = 'N'
  7653. and mci.check_type = 0
  7654. and be.hospital_id = mci.hospital_id
  7655. and be.behospital_code = mci.behospital_code
  7656. left join med_check_info hm_mci
  7657. on hm_mci.is_deleted = 'N'
  7658. and hm_mci.check_type = 1
  7659. and be.hospital_id = hm_mci.hospital_id
  7660. and be.behospital_code = hm_mci.behospital_code
  7661. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  7662. and be.hospital_id = t2.hospital_id
  7663. AND t2.is_deleted = 'N'
  7664. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  7665. AND t3.is_deleted = 'N'
  7666. )tt1
  7667. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  7668. ,med_medical_record tt2
  7669. WHERE
  7670. tt2.is_deleted = 'N'
  7671. AND tt1.hospital_id = tt2.hospital_id
  7672. AND tt1.behospital_code = tt2.behospital_code
  7673. AND tt2.mode_id = 30
  7674. </if>
  7675. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  7676. ,med_crisis_info tt2
  7677. WHERE
  7678. tt2.is_deleted = 'N'
  7679. AND tt1.hospital_id = tt2.hospital_id
  7680. AND tt1.behospital_code = tt2.behospital_code
  7681. </if>
  7682. ) t1
  7683. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  7684. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  7685. AND t1.behospital_code = t2.behospital_code
  7686. AND t2.is_deleted = 'N'
  7687. </if>
  7688. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  7689. , med_home_page t2
  7690. , med_home_operation_info t3
  7691. WHERE t1.hospital_id = t2.hospital_id
  7692. AND t1.behospital_code = t2.behospital_code
  7693. AND t2.home_page_id = t3.home_page_id
  7694. AND t2.is_deleted = 'N'
  7695. AND t3.is_deleted = 'N'
  7696. </if>
  7697. ) t
  7698. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  7699. AND t.hospitalId = qi.hospital_id
  7700. AND t.behospitalCode = qi.behospital_code
  7701. where 1=1
  7702. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  7703. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  7704. </if>
  7705. <if test="qcResultShortPageVO.checkStatus != null">
  7706. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7707. </if>
  7708. <if test="qcResultShortPageVO.mrStatus != null">
  7709. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7710. </if>
  7711. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7712. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7713. </if>
  7714. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7715. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7716. </if>
  7717. <if test="qcResultShortPageVO.chTimeStart != null ">
  7718. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7719. </if>
  7720. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7721. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7722. </if>
  7723. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7724. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  7725. </if>
  7726. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  7727. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  7728. </if>
  7729. GROUP BY
  7730. t.behDeptId,
  7731. t.behDeptName,
  7732. t.doctorId,
  7733. t.doctorName
  7734. )f2
  7735. WHERE
  7736. f1.doctorId = f2.doctorId
  7737. AND f1.doctorName = f2.doctorName
  7738. AND f1.doctorName = f2.doctorName
  7739. </select>
  7740. <!-- 条目缺陷评分详情页导出-->
  7741. <select id="qcResultShortPageExport" resultMap="ExportExcelMap">
  7742. SELECT * from(
  7743. SELECT
  7744. f1.*,
  7745. f2.avgScore
  7746. FROM
  7747. (SELECT
  7748. t.*,
  7749. qi.score_res AS score,
  7750. qd.msg AS msg,
  7751. qc.NAME AS caseName
  7752. FROM
  7753. (SELECT DISTINCT
  7754. t1.hospital_id AS hospitalId,
  7755. t1.behospital_code AS behospitalCode,
  7756. t1.bed_code AS bedCode,
  7757. t1.LEVEL AS LEVEL,
  7758. t1.grade_type AS gradeType,
  7759. t1.score_res AS scoreRes,
  7760. t1.scoreBn AS scoreBn,
  7761. t1.NAME AS patName,
  7762. t1.sex AS sex,
  7763. t1.beh_dept_id AS behDeptId,
  7764. t1.beh_dept_name AS behDeptName,
  7765. t1.doctor_id AS doctorId,
  7766. t1.doctor_name AS doctorName,
  7767. t1.beh_doctor_id AS behDoctorId,
  7768. t1.beh_doctor_name AS behDoctorName,
  7769. t1.director_doctor_id AS directorDoctorId,
  7770. t1.director_doctor_name AS directorDoctorName,
  7771. t1.birthday AS birthday,
  7772. t1.behospital_date AS behospitalDate,
  7773. t1.leave_hospital_date AS leaveHospitalDate,
  7774. t1.placefile_date AS placefileDate,
  7775. t1.gmt_create AS gradeTime,
  7776. t1.diagnose AS diagnose,
  7777. t1.ward_name AS wardName,
  7778. t1.file_code AS fileCode,
  7779. t1.checkStatus AS checkStatus,
  7780. t1.mrStatus AS mrStatus,
  7781. t1.chName AS chName,
  7782. t1.mrName AS mrName,
  7783. t1.chTime AS chTime,
  7784. t1.mrTime AS mrTime
  7785. FROM
  7786. (
  7787. SELECT DISTINCT
  7788. tt1.*
  7789. FROM
  7790. (SELECT
  7791. be.*,
  7792. ifnull(mci.status,0) AS checkStatus,
  7793. ifnull(hm_mci.status,0) AS mrStatus,
  7794. mci.check_name as chName,
  7795. hm_mci.check_name as mrName,
  7796. mci.gmt_create as chTime,
  7797. e.score_res as scoreBn,
  7798. hm_mci.gmt_create as mrTime
  7799. FROM
  7800. (
  7801. SELECT DISTINCT
  7802. a.hospital_id,
  7803. a.behospital_code,
  7804. a.bed_code,
  7805. a.file_code,
  7806. b.LEVEL,
  7807. b.grade_type,
  7808. b.score_res,
  7809. a.NAME,
  7810. a.sex,
  7811. a.beh_dept_id,
  7812. a.beh_dept_name,
  7813. a.birthday,
  7814. a.behospital_date,
  7815. a.leave_hospital_date,
  7816. a.doctor_id,
  7817. a.doctor_name,
  7818. a.beh_doctor_id,
  7819. a.beh_doctor_name,
  7820. a.director_doctor_id,
  7821. a.director_doctor_name,
  7822. a.diagnose,
  7823. a.placefile_date,
  7824. a.ward_name,
  7825. b.gmt_create
  7826. FROM
  7827. med_behospital_info a,
  7828. med_qcresult_info b,
  7829. med_qcresult_detail c,
  7830. qc_cases_entry d
  7831. WHERE
  7832. a.is_deleted = 'N'
  7833. AND b.is_deleted = 'N'
  7834. AND c.is_deleted = 'N'
  7835. AND d.is_deleted = 'N'
  7836. AND a.hospital_id = b.hospital_id
  7837. AND a.hospital_id = c.hospital_id
  7838. AND a.behospital_code = b.behospital_code
  7839. AND a.behospital_code = c.behospital_code
  7840. AND c.cases_id = d.cases_id
  7841. AND c.cases_entry_id = d.id
  7842. AND a.qc_type_id != 0
  7843. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  7844. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  7845. </if>
  7846. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  7847. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  7848. </if>
  7849. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  7850. <if test="qcResultShortPageVO.startDate != null ">
  7851. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  7852. </if>
  7853. <if test="qcResultShortPageVO.endDate != null ">
  7854. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  7855. </if>
  7856. </if>
  7857. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  7858. <if test="qcResultShortPageVO.startDate != null ">
  7859. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  7860. </if>
  7861. <if test="qcResultShortPageVO.endDate != null">
  7862. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  7863. </if>
  7864. </if>
  7865. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  7866. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  7867. </if>
  7868. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  7869. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  7870. </if>
  7871. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  7872. AND b.`level` = #{qcResultShortPageVO.level}
  7873. </if>
  7874. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  7875. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  7876. </if>
  7877. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  7878. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  7879. </if>
  7880. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  7881. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  7882. </if>
  7883. <if test="qcResultShortPageVO.casesEntryId != null ">
  7884. AND d.id = #{qcResultShortPageVO.casesEntryId}
  7885. </if>
  7886. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  7887. AND d.cases_name = #{qcResultShortPageVO.casesName}
  7888. </if>
  7889. <if test="qcResultShortPageVO.casesId != null">
  7890. AND d.cases_id = #{qcResultShortPageVO.casesId}
  7891. </if>
  7892. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  7893. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7894. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  7895. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  7896. </if>
  7897. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  7898. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7899. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  7900. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  7901. </if>
  7902. <if test="qcResultShortPageVO.isReject != null">
  7903. AND c.is_reject = #{qcResultShortPageVO.isReject}
  7904. </if>
  7905. <if test="qcResultShortPageVO.ruleType != null">
  7906. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  7907. </if>
  7908. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  7909. AND TIMESTAMPDIFF(
  7910. DAY,
  7911. DATE( a.behospital_date ),
  7912. DATE( a.leave_hospital_date ))> 30
  7913. </if>
  7914. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  7915. AND TIMESTAMPDIFF(
  7916. DAY,
  7917. DATE( a.behospital_date ),
  7918. DATE( a.leave_hospital_date ))> 31
  7919. </if>
  7920. )be
  7921. left join med_check_info mci
  7922. on mci.is_deleted = 'N'
  7923. and mci.check_type = 0
  7924. and be.hospital_id = mci.hospital_id
  7925. and be.behospital_code = mci.behospital_code
  7926. left join med_check_info hm_mci
  7927. on hm_mci.is_deleted = 'N'
  7928. and hm_mci.check_type = 1
  7929. and be.hospital_id = hm_mci.hospital_id
  7930. and be.behospital_code = hm_mci.behospital_code
  7931. LEFT JOIN med_qcresult_cases e
  7932. on be.behospital_code = e.behospital_code
  7933. and be.hospital_id = e.hospital_id
  7934. AND e.is_deleted = 'N'
  7935. and e.cases_id = 243
  7936. )tt1
  7937. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  7938. ,med_medical_record tt2
  7939. WHERE
  7940. tt2.is_deleted = 'N'
  7941. AND tt1.hospital_id = tt2.hospital_id
  7942. AND tt1.behospital_code = tt2.behospital_code
  7943. AND tt2.mode_id = 30
  7944. </if>
  7945. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  7946. ,med_crisis_info tt2
  7947. WHERE
  7948. tt2.is_deleted = 'N'
  7949. AND tt1.hospital_id = tt2.hospital_id
  7950. AND tt1.behospital_code = tt2.behospital_code
  7951. </if>
  7952. ) t1
  7953. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  7954. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  7955. AND t1.behospital_code = t2.behospital_code
  7956. AND t2.is_deleted = 'N'
  7957. </if>
  7958. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  7959. , med_home_page t2
  7960. , med_home_operation_info t3
  7961. WHERE t1.hospital_id = t2.hospital_id
  7962. AND t1.behospital_code = t2.behospital_code
  7963. AND t2.home_page_id = t3.home_page_id
  7964. AND t2.is_deleted = 'N'
  7965. AND t3.is_deleted = 'N'
  7966. </if>
  7967. ) t
  7968. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  7969. AND t.hospitalId = qi.hospital_id
  7970. AND t.behospitalCode = qi.behospital_code
  7971. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  7972. AND t.hospitalId = qd.hospital_id
  7973. AND t.behospitalCode = qd.behospital_code
  7974. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  7975. AND qd.cases_id = qc.id
  7976. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  7977. AND qd.cases_id = qce.cases_id
  7978. AND qd.cases_entry_id = qce.id
  7979. where 1=1
  7980. <if test="qcResultShortPageVO.checkStatus != null">
  7981. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  7982. </if>
  7983. <if test="qcResultShortPageVO.mrStatus != null">
  7984. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  7985. </if>
  7986. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  7987. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  7988. </if>
  7989. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  7990. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  7991. </if>
  7992. <if test="qcResultShortPageVO.chTimeStart != null ">
  7993. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  7994. </if>
  7995. <if test="qcResultShortPageVO.chTimeEnd != null ">
  7996. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  7997. </if>
  7998. <if test="qcResultShortPageVO.mrTimeStart != null ">
  7999. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8000. </if>
  8001. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8002. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8003. </if>
  8004. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  8005. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  8006. </if>
  8007. <if test="qcResultShortPageVO.casesEntryId != null ">
  8008. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  8009. </if>
  8010. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  8011. AND qce.cases_name = #{qcResultShortPageVO.casesName}
  8012. </if>
  8013. <if test="qcResultShortPageVO.casesId != null">
  8014. AND qce.cases_id = #{qcResultShortPageVO.casesId}
  8015. </if>
  8016. )f1,
  8017. (SELECT
  8018. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  8019. t.behDeptId,
  8020. t.behDeptName
  8021. FROM
  8022. (SELECT DISTINCT
  8023. t1.hospital_id AS hospitalId,
  8024. t1.behospital_code AS behospitalCode,
  8025. t1.bed_code AS bedCode,
  8026. t1.LEVEL AS LEVEL,
  8027. t1.grade_type AS gradeType,
  8028. t1.score_res AS scoreRes,
  8029. t1.NAME AS NAME,
  8030. t1.sex AS sex,
  8031. t1.beh_dept_id AS behDeptId,
  8032. t1.beh_dept_name AS behDeptName,
  8033. t1.doctor_id AS doctorId,
  8034. t1.doctor_name AS doctorName,
  8035. t1.beh_doctor_id AS behDoctorId,
  8036. t1.beh_doctor_name AS behDoctorName,
  8037. t1.director_doctor_id AS directorDoctorId,
  8038. t1.director_doctor_name AS directorDoctorName,
  8039. t1.birthday AS birthday,
  8040. t1.behospital_date AS behospitalDate,
  8041. t1.leave_hospital_date AS leaveHospitalDate,
  8042. t1.placefile_date AS placefileDate,
  8043. t1.gmt_create AS gradeTime,
  8044. t1.diagnose,
  8045. t1.ward_name AS wardName,
  8046. t2.age,
  8047. t1.file_code AS fileCode,
  8048. t1.checkStatus,
  8049. t1.mrStatus,
  8050. t1.chName,
  8051. t1.mrName,
  8052. t1.chTime,
  8053. t1.mrTime
  8054. FROM
  8055. (
  8056. SELECT DISTINCT
  8057. tt1.*
  8058. FROM
  8059. (SELECT
  8060. be.*,
  8061. ifnull(mci.status,0) AS checkStatus,
  8062. ifnull(hm_mci.status,0) AS mrStatus,
  8063. mci.check_name as chName,
  8064. hm_mci.check_name as mrName,
  8065. mci.gmt_create as chTime,
  8066. hm_mci.gmt_create as mrTime
  8067. FROM
  8068. (
  8069. SELECT DISTINCT
  8070. a.hospital_id,
  8071. a.behospital_code,
  8072. a.bed_code,
  8073. a.file_code,
  8074. b.LEVEL,
  8075. b.grade_type,
  8076. b.score_res,
  8077. a.NAME,
  8078. a.sex,
  8079. a.beh_dept_id,
  8080. a.beh_dept_name,
  8081. a.birthday,
  8082. a.behospital_date,
  8083. a.leave_hospital_date,
  8084. a.doctor_id,
  8085. a.doctor_name,
  8086. a.beh_doctor_id,
  8087. a.beh_doctor_name,
  8088. a.director_doctor_id,
  8089. a.director_doctor_name,
  8090. a.diagnose,
  8091. a.placefile_date,
  8092. a.ward_name,
  8093. b.gmt_create
  8094. FROM
  8095. med_behospital_info a,
  8096. med_qcresult_info b,
  8097. med_qcresult_detail c,
  8098. qc_cases_entry d
  8099. WHERE
  8100. a.is_deleted = 'N'
  8101. AND b.is_deleted = 'N'
  8102. AND c.is_deleted = 'N'
  8103. AND d.is_deleted = 'N'
  8104. AND a.hospital_id = b.hospital_id
  8105. AND a.hospital_id = c.hospital_id
  8106. AND a.behospital_code = b.behospital_code
  8107. AND a.behospital_code = c.behospital_code
  8108. AND c.cases_id = d.cases_id
  8109. AND c.cases_entry_id = d.id
  8110. AND a.qc_type_id != 0
  8111. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  8112. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  8113. </if>
  8114. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  8115. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  8116. </if>
  8117. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  8118. <if test="qcResultShortPageVO.startDate != null ">
  8119. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  8120. </if>
  8121. <if test="qcResultShortPageVO.endDate != null ">
  8122. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  8123. </if>
  8124. </if>
  8125. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  8126. <if test="qcResultShortPageVO.startDate != null ">
  8127. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  8128. </if>
  8129. <if test="qcResultShortPageVO.endDate != null">
  8130. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  8131. </if>
  8132. </if>
  8133. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  8134. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  8135. </if>
  8136. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  8137. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  8138. </if>
  8139. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  8140. AND b.`level` = #{qcResultShortPageVO.level}
  8141. </if>
  8142. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  8143. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  8144. </if>
  8145. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  8146. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  8147. </if>
  8148. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  8149. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  8150. </if>
  8151. <if test="qcResultShortPageVO.casesEntryId != null ">
  8152. AND d.id = #{qcResultShortPageVO.casesEntryId}
  8153. </if>
  8154. <if test="qcResultShortPageVO.casesName != null and qcResultShortPageVO.casesName != ''">
  8155. AND d.cases_name = #{qcResultShortPageVO.casesName}
  8156. </if>
  8157. <if test="qcResultShortPageVO.casesId != null">
  8158. AND d.cases_id = #{qcResultShortPageVO.casesId}
  8159. </if>
  8160. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  8161. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8162. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  8163. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  8164. </if>
  8165. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  8166. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8167. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  8168. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  8169. </if>
  8170. <if test="qcResultShortPageVO.isReject != null">
  8171. AND c.is_reject = #{qcResultShortPageVO.isReject}
  8172. </if>
  8173. <if test="qcResultShortPageVO.ruleType != null">
  8174. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  8175. </if>
  8176. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
  8177. AND TIMESTAMPDIFF(
  8178. DAY,
  8179. DATE( a.behospital_date ),
  8180. DATE( a.leave_hospital_date ))> 30
  8181. </if>
  8182. <if test="qcResultShortPageVO.beHosGT31Days != null and qcResultShortPageVO.beHosGT31Days==1">
  8183. AND TIMESTAMPDIFF(
  8184. DAY,
  8185. DATE( a.behospital_date ),
  8186. DATE( a.leave_hospital_date ))> 31
  8187. </if>
  8188. )be
  8189. left join med_check_info mci
  8190. on mci.is_deleted = 'N'
  8191. and mci.check_type = 0
  8192. and be.hospital_id = mci.hospital_id
  8193. and be.behospital_code = mci.behospital_code
  8194. left join med_check_info hm_mci
  8195. on hm_mci.is_deleted = 'N'
  8196. and hm_mci.check_type = 1
  8197. and be.hospital_id = hm_mci.hospital_id
  8198. and be.behospital_code = hm_mci.behospital_code
  8199. )tt1
  8200. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
  8201. ,med_medical_record tt2
  8202. WHERE
  8203. tt2.is_deleted = 'N'
  8204. AND tt1.hospital_id = tt2.hospital_id
  8205. AND tt1.behospital_code = tt2.behospital_code
  8206. AND tt2.mode_id = 30
  8207. </if>
  8208. <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
  8209. ,med_crisis_info tt2
  8210. WHERE
  8211. tt2.is_deleted = 'N'
  8212. AND tt1.hospital_id = tt2.hospital_id
  8213. AND tt1.behospital_code = tt2.behospital_code
  8214. </if>
  8215. ) t1
  8216. <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594 and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2930)">
  8217. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  8218. AND t1.behospital_code = t2.behospital_code
  8219. AND t2.is_deleted = 'N'
  8220. </if>
  8221. <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594 or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2930)">
  8222. , med_home_page t2
  8223. , med_home_operation_info t3
  8224. WHERE t1.hospital_id = t2.hospital_id
  8225. AND t1.behospital_code = t2.behospital_code
  8226. AND t2.home_page_id = t3.home_page_id
  8227. AND t2.is_deleted = 'N'
  8228. AND t3.is_deleted = 'N'
  8229. </if>
  8230. ) t
  8231. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  8232. AND t.hospitalId = qi.hospital_id
  8233. AND t.behospitalCode = qi.behospital_code
  8234. where 1=1
  8235. <if test="qcResultShortPageVO.checkStatus != null">
  8236. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  8237. </if>
  8238. <if test="qcResultShortPageVO.mrStatus != null">
  8239. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  8240. </if>
  8241. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  8242. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  8243. </if>
  8244. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  8245. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  8246. </if>
  8247. <if test="qcResultShortPageVO.chTimeStart != null ">
  8248. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  8249. </if>
  8250. <if test="qcResultShortPageVO.chTimeEnd != null ">
  8251. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  8252. </if>
  8253. <if test="qcResultShortPageVO.mrTimeStart != null ">
  8254. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  8255. </if>
  8256. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  8257. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  8258. </if>
  8259. GROUP BY
  8260. t.behDeptId,
  8261. t.behDeptName
  8262. )f2
  8263. WHERE
  8264. f1.behDeptId = f2.behDeptId
  8265. AND f1.behDeptName = f2.behDeptName
  8266. )m
  8267. </select>
  8268. <resultMap id="MedicalCheckMap" type="com.diagbot.dto.MedicalCheckDTO">
  8269. <result column="deptName" property="deptName"/>
  8270. <result column="deptId" property="deptId"/>
  8271. <result column="doctorGroup" property="doctorGroup"/>
  8272. <result column="doctorName" property="doctorName"/>
  8273. <result column="entry_2658_num" property="entry_2658_num"/>
  8274. <result column="entry_2686_num" property="entry_2686_num"/>
  8275. <result column="entry_2657_num" property="entry_2657_num"/>
  8276. <result column="entry_3010_num" property="entry_3010_num"/>
  8277. <result column="entry_2655_num" property="entry_2655_num"/>
  8278. <result column="entry_2654_num" property="entry_2654_num"/>
  8279. <result column="entry_2852_num" property="entry_2852_num"/>
  8280. <result column="entry_2287_num" property="entry_2287_num"/>
  8281. <result column="entry_3025_num" property="entry_3025_num"/>
  8282. <result column="entry_2170_num" property="entry_2170_num"/>
  8283. <result column="entry_2930_num" property="entry_2930_num"/>
  8284. <result column="entry_2900_num" property="entry_2900_num"/>
  8285. <result column="entry_2229_num" property="entry_2229_num"/>
  8286. <result column="entry_2217_num" property="entry_2217_num"/>
  8287. <result column="entry_2218_num" property="entry_2218_num"/>
  8288. <result column="entry_2220_num" property="entry_2220_num"/>
  8289. <result column="entry_2486_num" property="entry_2486_num"/>
  8290. <result column="entry_3063_num" property="entry_3063_num"/>
  8291. <result column="entry_3062_num" property="entry_3062_num"/>
  8292. <result column="entry_2495_num" property="entry_2495_num"/>
  8293. </resultMap>
  8294. <!-- 病历稽查表-->
  8295. <select id="getMedicalCheck" resultMap="MedicalCheckMap">
  8296. SELECT
  8297. a.beh_dept_id AS deptId,
  8298. a.beh_dept_name AS deptName,
  8299. a.doctor_name as doctorGroup,
  8300. a.doctor_name as doctorName,
  8301. sum(c.cases_entry_id = 2658) as entry_2658_num,
  8302. sum(c.cases_entry_id = 2686) as entry_2686_num,
  8303. sum(c.cases_entry_id = 2657) as entry_2657_num,
  8304. sum(c.cases_entry_id = 3010) as entry_3010_num,
  8305. sum(c.cases_entry_id = 2655) as entry_2655_num,
  8306. sum(c.cases_entry_id = 2654) as entry_2654_num,
  8307. sum(c.cases_entry_id = 2852) as entry_2852_num,
  8308. sum(c.cases_entry_id = 2287) as entry_2287_num,
  8309. sum(c.cases_entry_id = 3025) as entry_3025_num,
  8310. sum(c.cases_entry_id = 2170) as entry_2170_num,
  8311. sum(c.cases_entry_id = 2930) as entry_2930_num,
  8312. sum(c.cases_entry_id = 2900) as entry_2900_num,
  8313. sum(c.cases_entry_id = 2229) as entry_2229_num,
  8314. sum(c.cases_entry_id = 2217) as entry_2217_num,
  8315. sum(c.cases_entry_id = 2218) as entry_2218_num,
  8316. sum(c.cases_entry_id = 2220) as entry_2220_num,
  8317. sum(c.cases_entry_id = 2486) as entry_2486_num,
  8318. sum(c.cases_entry_id = 3063) as entry_3063_num,
  8319. sum(c.cases_entry_id = 3062) as entry_3062_num,
  8320. sum(c.cases_entry_id = 2495) as entry_2495_num
  8321. FROM
  8322. med_behospital_info a,
  8323. med_qcresult_info b,
  8324. med_qcresult_detail c,
  8325. qc_cases_entry d,
  8326. bas_doctor_info e
  8327. WHERE
  8328. a.is_deleted = 'N'
  8329. AND b.is_deleted = 'N'
  8330. AND c.is_deleted = 'N'
  8331. AND d.is_deleted = 'N'
  8332. AND e.is_deleted = 'N'
  8333. AND a.hospital_id = b.hospital_id
  8334. AND a.hospital_id = c.hospital_id
  8335. AND a.hospital_id = e.hospital_id
  8336. AND a.behospital_code = b.behospital_code
  8337. AND a.behospital_code = c.behospital_code
  8338. AND a.beh_dept_id = e.dept_id
  8339. AND c.cases_entry_id = d.id
  8340. and a.doctor_id=e.doctor_id
  8341. and e.group_id is not NULL
  8342. AND LENGTH(e.group_id)>0
  8343. AND a.qc_type_id != 0
  8344. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  8345. and a.is_placefile = #{filterVO.isPlacefile}
  8346. </if>
  8347. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  8348. AND a.hospital_id = #{filterVO.hospitalId}
  8349. </if>
  8350. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  8351. <if test="filterVO.startDate != null ">
  8352. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  8353. </if>
  8354. <if test="filterVO.endDate != null ">
  8355. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  8356. </if>
  8357. </if>
  8358. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  8359. <if test="filterVO.startDate != null ">
  8360. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  8361. </if>
  8362. <if test="filterVO.endDate != null ">
  8363. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  8364. </if>
  8365. </if>
  8366. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  8367. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  8368. </if>
  8369. GROUP BY
  8370. a.beh_dept_id,
  8371. e.group_id,
  8372. a.doctor_id
  8373. </select>
  8374. <!-- 病历稽查表-科室-->
  8375. <select id="getMedicalCheckByDept" resultMap="MedicalCheckMap">
  8376. SELECT
  8377. a.beh_dept_id AS deptId,
  8378. a.beh_dept_name AS deptName,
  8379. a.doctor_name as doctorName,
  8380. a.doctor_name as doctorGroup,
  8381. sum(c.cases_entry_id = 2658) as entry_2658_num,
  8382. sum(c.cases_entry_id = 2686) as entry_2686_num,
  8383. sum(c.cases_entry_id = 2657) as entry_2657_num,
  8384. sum(c.cases_entry_id = 3010) as entry_3010_num,
  8385. sum(c.cases_entry_id = 2655) as entry_2655_num,
  8386. sum(c.cases_entry_id = 2654) as entry_2654_num,
  8387. sum(c.cases_entry_id = 2852) as entry_2852_num,
  8388. sum(c.cases_entry_id = 2287) as entry_2287_num,
  8389. sum(c.cases_entry_id = 3025) as entry_3025_num,
  8390. sum(c.cases_entry_id = 2170) as entry_2170_num,
  8391. sum(c.cases_entry_id = 2930) as entry_2930_num,
  8392. sum(c.cases_entry_id = 2900) as entry_2900_num,
  8393. sum(c.cases_entry_id = 2229) as entry_2229_num,
  8394. sum(c.cases_entry_id = 2217) as entry_2217_num,
  8395. sum(c.cases_entry_id = 2218) as entry_2218_num,
  8396. sum(c.cases_entry_id = 2220) as entry_2220_num,
  8397. sum(c.cases_entry_id = 2486) as entry_2486_num,
  8398. sum(c.cases_entry_id = 3063) as entry_3063_num,
  8399. sum(c.cases_entry_id = 3062) as entry_3062_num,
  8400. sum(c.cases_entry_id = 2495) as entry_2495_num
  8401. FROM
  8402. med_behospital_info a,
  8403. med_qcresult_info b,
  8404. med_qcresult_detail c,
  8405. qc_cases_entry d,
  8406. bas_doctor_info e,
  8407. sys_user_dept f
  8408. WHERE
  8409. a.is_deleted = 'N'
  8410. AND b.is_deleted = 'N'
  8411. AND c.is_deleted = 'N'
  8412. AND d.is_deleted = 'N'
  8413. AND e.is_deleted = 'N'
  8414. AND f.is_deleted = 'N'
  8415. AND a.hospital_id = b.hospital_id
  8416. AND a.hospital_id = c.hospital_id
  8417. AND a.hospital_id = e.hospital_id
  8418. AND a.hospital_id = f.hospital_id
  8419. AND a.behospital_code = b.behospital_code
  8420. AND a.behospital_code = c.behospital_code
  8421. AND a.beh_dept_id = f.dept_id
  8422. AND c.cases_entry_id = d.id
  8423. and a.doctor_id=e.doctor_id
  8424. and e.group_id is not NULL
  8425. AND LENGTH(e.group_id)>0
  8426. AND a.qc_type_id != 0
  8427. <if test="filterVO.userId!=null">
  8428. AND f.user_id = #{filterVO.userId}
  8429. </if>
  8430. <if test="filterVO.name != null and filterVO.name != ''">
  8431. AND a.doctor_name like CONCAT('%', #{filterVO.name}, '%')
  8432. </if>
  8433. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  8434. and a.is_placefile = #{filterVO.isPlacefile}
  8435. </if>
  8436. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  8437. AND a.hospital_id = #{filterVO.hospitalId}
  8438. </if>
  8439. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  8440. <if test="filterVO.startDate != null ">
  8441. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  8442. </if>
  8443. <if test="filterVO.endDate != null ">
  8444. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  8445. </if>
  8446. </if>
  8447. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  8448. <if test="filterVO.startDate != null ">
  8449. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  8450. </if>
  8451. <if test="filterVO.endDate != null ">
  8452. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  8453. </if>
  8454. </if>
  8455. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  8456. AND a.beh_dept_name = #{filterVO.deptName}
  8457. </if>
  8458. GROUP BY
  8459. a.beh_dept_id,
  8460. e.group_id,
  8461. a.doctor_name
  8462. </select>
  8463. <!-- 病历稽查表最新sql、id&&name-->
  8464. <select id="getMedicalEntryIds" resultType="com.diagbot.dto.MedicalCheckIdNameDTO">
  8465. SELECT
  8466. d.id,
  8467. d.name
  8468. from
  8469. qc_cases_entry d
  8470. where
  8471. 1=1
  8472. <if test="casesEntryIds != null and casesEntryIds.size() > 0">
  8473. and d.id in
  8474. <foreach collection="casesEntryIds" open="(" separator="," close=")" item="item">
  8475. '${item}'
  8476. </foreach>
  8477. </if>
  8478. </select>
  8479. <resultMap id="MedicalCheckExcelMap" type="com.diagbot.dto.MedicalCheckExportDTO">
  8480. <result column="deptName" property="deptName"/>
  8481. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  8482. ofType="com.diagbot.dto.MedicalDoctorExportDTO">
  8483. <result column="doctorName" property="doctorName"/>
  8484. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  8485. ofType="com.diagbot.dto.MedicalCheckTitleDTO">
  8486. <result column="RYJLW_24" property="ryjlw_24"/>
  8487. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  8488. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  8489. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  8490. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  8491. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  8492. <result column="QJJLW_6H" property="qjjlw_6h"/>
  8493. <result column="HZJLW_24H" property="hzjlw_24h"/>
  8494. <result column="SQTLXJW" property="sqtlxjw"/>
  8495. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  8496. <result column="XHSCW_30M" property="xhscw_30m"/>
  8497. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  8498. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  8499. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  8500. <result column="ZKJLW_24" property="zkjlw_24"/>
  8501. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  8502. <result column="SXHWJL" property="sxhwjl"/>
  8503. <result column="SXPJW_24" property="sxpjw_24"/>
  8504. <result column="WJZWJL" property="wjzwjl"/>
  8505. <result column="WYWWCXJ" property="wywwcxj"/>
  8506. </collection>
  8507. </collection>
  8508. </resultMap>
  8509. <resultMap id="MedicalCheckByDeptMap" type="com.diagbot.dto.MedicalDeptDTO">
  8510. <result column="deptName" property="deptName"/>
  8511. <collection property="medicalDoctorExportDTOS" javaType="ArrayList"
  8512. ofType="com.diagbot.dto.MedicalDoDeptDTO">
  8513. <result column="doctorGroup" property="doctorGroup"/>
  8514. <collection property="medicalCheckTitleDTOS" javaType="ArrayList"
  8515. ofType="com.diagbot.dto.MedicalSeeByDeptDTO">
  8516. <result column="doctorName" property="doctorName"/>
  8517. <result column="RYJLW_24" property="ryjlw_24"/>
  8518. <result column="SCBCJLW_8H" property="scbcjlw_8h"/>
  8519. <result column="ZRSCCFW_72H" property="zrsccfw_72h"/>
  8520. <result column="RYHLJBCW_3D" property="ryhljbcw_3d"/>
  8521. <result column="ZRCFW_2W" property="zrcfw_2w"/>
  8522. <result column="ZZCFW_3W" property="zzcfw_3w"/>
  8523. <result column="QJJLW_6H" property="qjjlw_6h"/>
  8524. <result column="HZJLW_24H" property="hzjlw_24h"/>
  8525. <result column="SQTLXJW" property="sqtlxjw"/>
  8526. <result column="SXJLSW_24H" property="sxjlsw_24h"/>
  8527. <result column="XHSCW_30M" property="xhscw_30m"/>
  8528. <result column="SHZDCFW_24H" property="shzdcfw_24h"/>
  8529. <result column="SHJBCW_3D" property="shjbcw_3d"/>
  8530. <result column="ZKJBCW_3D" property="zkjbcw_3d"/>
  8531. <result column="ZKJLW_24" property="zkjlw_24"/>
  8532. <result column="BWZHJLBCW_MD" property="bwzhjlbcw_md"/>
  8533. <result column="SXHWJL" property="sxhwjl"/>
  8534. <result column="SXPJW_24" property="sxpjw_24"/>
  8535. <result column="WJZWJL" property="wjzwjl"/>
  8536. <result column="WYWWCXJ" property="wywwcxj"/>
  8537. </collection>
  8538. </collection>
  8539. </resultMap>
  8540. <!-- 病历稽查表最新导出-->
  8541. <select id="getMedicalCheckExport" resultMap="MedicalCheckExcelMap">
  8542. SELECT
  8543. a.beh_dept_id AS deptId,
  8544. a.beh_dept_name AS deptName,
  8545. GROUP_CONCAT( DISTINCT a.doctor_name) as doctorName,
  8546. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2658 THEN a.behospital_code else null END ) as RYJLW_24,
  8547. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2686 THEN a.behospital_code else null END ) as SCBCJLW_8H,
  8548. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2657 THEN a.behospital_code else null END ) as ZRSCCFW_72H,
  8549. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3010 THEN a.behospital_code else null END ) as RYHLJBCW_3D,
  8550. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2655 THEN a.behospital_code else null END ) as ZRCFW_2W,
  8551. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2654 THEN a.behospital_code else null END ) as ZZCFW_3W,
  8552. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2852 THEN a.behospital_code else null END ) as QJJLW_6H,
  8553. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2287 THEN a.behospital_code else null END ) as HZJLW_24H,
  8554. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3025 THEN a.behospital_code else null END ) as SQTLXJW,
  8555. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2170 THEN a.behospital_code else null END ) as SXJLSW_24H,
  8556. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2930 THEN a.behospital_code else null END ) as XHSCW_30M,
  8557. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2900 THEN a.behospital_code else null END ) as SHZDCFW_24H,
  8558. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2229 THEN a.behospital_code else null END ) as SHJBCW_3D,
  8559. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2217 THEN a.behospital_code else null END ) as ZKJBCW_3D,
  8560. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2218 THEN a.behospital_code else null END ) as ZKJLW_24,
  8561. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2220 THEN a.behospital_code else null END ) as BWZHJLBCW_MD,
  8562. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2486 THEN a.behospital_code else null END ) as SXHWJL,
  8563. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3063 THEN a.behospital_code else null END ) as SXPJW_24,
  8564. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 3062 THEN a.behospital_code else null END ) as WJZWJL,
  8565. GROUP_CONCAT(DISTINCT case when c.cases_entry_id = 2495 THEN a.behospital_code else null END ) as WYWWCXJ
  8566. -- sum(c.cases_entry_id = 2658) as RYJLW_24,
  8567. -- sum(c.cases_entry_id = 2686) as SCBCJLW_8H,
  8568. -- sum(c.cases_entry_id = 2657) as ZRSCCFW_72H,
  8569. -- sum(c.cases_entry_id = 3010) as RYHLJBCW_3D,
  8570. -- sum(c.cases_entry_id = 2655) as ZRCFW_2W,
  8571. -- sum(c.cases_entry_id = 2654) as ZZCFW_3W,
  8572. -- sum(c.cases_entry_id = 2852) as QJJLW_6H,
  8573. -- sum(c.cases_entry_id = 2287) as HZJLW_24H,
  8574. -- sum(c.cases_entry_id = 3025) as SQTLXJW,
  8575. -- sum(c.cases_entry_id = 2170) as SXJLSW_24H,
  8576. -- sum(c.cases_entry_id = 2930) as XHSCW_30M,
  8577. -- sum(c.cases_entry_id = 2900) as SHZDCFW_24H,
  8578. -- sum(c.cases_entry_id = 2229) as SHJBCW_3D,
  8579. -- sum(c.cases_entry_id = 2217) as ZKJBCW_3D,
  8580. -- sum(c.cases_entry_id = 2218) as ZKJLW_24,
  8581. -- sum(c.cases_entry_id = 2220) as BWZHJLBCW_MD,
  8582. -- sum(c.cases_entry_id = 2486) as SXHWJL,
  8583. -- sum(c.cases_entry_id = 3063) as SXPJW_24,
  8584. -- sum(c.cases_entry_id = 3062) as WJZWJL,
  8585. -- sum(c.cases_entry_id = 2495) as WYWWCXJ
  8586. FROM
  8587. med_behospital_info a,
  8588. med_qcresult_info b,
  8589. med_qcresult_detail c,
  8590. qc_cases_entry d,
  8591. bas_doctor_info e
  8592. WHERE
  8593. a.is_deleted = 'N'
  8594. AND b.is_deleted = 'N'
  8595. AND c.is_deleted = 'N'
  8596. AND d.is_deleted = 'N'
  8597. AND e.is_deleted = 'N'
  8598. AND a.hospital_id = b.hospital_id
  8599. AND a.hospital_id = c.hospital_id
  8600. AND a.hospital_id = e.hospital_id
  8601. AND a.behospital_code = b.behospital_code
  8602. AND a.behospital_code = c.behospital_code
  8603. AND a.beh_dept_id = e.dept_id
  8604. AND c.cases_entry_id = d.id
  8605. and a.doctor_id=e.doctor_id
  8606. and e.group_id is not NULL
  8607. AND LENGTH(e.group_id)>0
  8608. AND a.qc_type_id != 0
  8609. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile != ''">
  8610. and a.is_placefile = #{filterVO.isPlacefile}
  8611. </if>
  8612. <if test="filterVO.hospitalId != null and filterVO.hospitalId != ''">
  8613. AND a.hospital_id = #{filterVO.hospitalId}
  8614. </if>
  8615. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 0">
  8616. <if test="filterVO.startDate != null ">
  8617. <![CDATA[ AND a.behospital_date >= #{filterVO.startDate}]]>
  8618. </if>
  8619. <if test="filterVO.endDate != null ">
  8620. <![CDATA[ AND a.behospital_date <= #{filterVO.endDate}]]>
  8621. </if>
  8622. </if>
  8623. <if test="filterVO.isPlacefile != null and filterVO.isPlacefile == 1">
  8624. <if test="filterVO.startDate != null ">
  8625. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  8626. </if>
  8627. <if test="filterVO.endDate != null ">
  8628. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  8629. </if>
  8630. </if>
  8631. <if test="filterVO.deptName != null and filterVO.deptName != ''">
  8632. AND a.beh_dept_name like CONCAT('%', #{filterVO.deptName}, '%')
  8633. </if>
  8634. GROUP BY
  8635. a.beh_dept_id,
  8636. e.group_id
  8637. </select>
  8638. <!-- 未整改病历统计-->
  8639. <select id="unModifyMRStatistics" resultType="com.diagbot.dto.UnModifyMRDetailDTO" parameterType="com.diagbot.vo.FilterUnModifyMRVO">
  8640. SELECT
  8641. a.beh_dept_id AS deptId,
  8642. a.beh_dept_name AS deptName,
  8643. d.id AS casesEntryId,
  8644. d.NAME AS casesEntryName,
  8645. count(*) AS casesEntryNum
  8646. FROM
  8647. med_behospital_info a,
  8648. med_qcresult_info b,
  8649. med_qcresult_detail c,
  8650. qc_cases_entry d
  8651. WHERE
  8652. a.is_deleted = 'N'
  8653. AND b.is_deleted = 'N'
  8654. AND c.is_deleted = 'N'
  8655. AND d.is_deleted = 'N'
  8656. AND a.hospital_id = b.hospital_id
  8657. AND a.hospital_id = c.hospital_id
  8658. AND a.behospital_code = b.behospital_code
  8659. AND a.behospital_code = c.behospital_code
  8660. AND c.cases_entry_id = d.id
  8661. AND a.qc_type_id != 0
  8662. <if test="isPlacefile != null and isPlacefile != ''">
  8663. and a.is_placefile = #{isPlacefile}
  8664. </if>
  8665. <if test="hospitalId != null and hospitalId != ''">
  8666. AND a.hospital_id = #{hospitalId}
  8667. </if>
  8668. <if test="isPlacefile != null and isPlacefile == 0">
  8669. <if test="startDate != null ">
  8670. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8671. </if>
  8672. <if test="endDate != null ">
  8673. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8674. </if>
  8675. </if>
  8676. <if test="isPlacefile != null and isPlacefile == 1">
  8677. <if test="startDate != null ">
  8678. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8679. </if>
  8680. <if test="endDate != null ">
  8681. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8682. </if>
  8683. </if>
  8684. <if test="deptName != null and deptName != ''">
  8685. AND a.beh_dept_name like CONCAT('%', #{deptName}, '%')
  8686. </if>
  8687. <if test="casesEntryIds != null and casesEntryIds.size()>0">
  8688. AND c.cases_entry_id IN
  8689. <foreach collection="casesEntryIds" item="item" open="(" close=")" separator=",">
  8690. #{item}
  8691. </foreach>
  8692. </if>
  8693. GROUP BY
  8694. a.beh_dept_id,
  8695. a.beh_dept_name,
  8696. c.cases_entry_id,
  8697. d.NAME
  8698. </select>
  8699. <!-- 不合格/合格数病历号(内页)科室-->
  8700. <select id="getIsGoodLevelByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  8701. SELECT t.*
  8702. FROM
  8703. (SELECT DISTINCT
  8704. t1.hospital_id AS hospitalId,
  8705. t1.behospital_code AS behospitalCode,
  8706. t1.bed_code AS bedCode,
  8707. t1.LEVEL AS LEVEL,
  8708. t1.grade_type AS gradeType,
  8709. t1.score_res AS scoreRes,
  8710. t1.scoreBn,
  8711. t1.NAME AS NAME,
  8712. t1.sex AS sex,
  8713. t1.medoupName,
  8714. t1.beh_dept_id AS behDeptId,
  8715. t1.beh_dept_name AS behDeptName,
  8716. t1.doctor_id AS doctorId,
  8717. t1.doctor_name AS doctorName,
  8718. t1.beh_doctor_id AS behDoctorId,
  8719. t1.beh_doctor_name AS behDoctorName,
  8720. t1.director_doctor_id AS directorDoctorId,
  8721. t1.director_doctor_name AS directorDoctorName,
  8722. t1.birthday AS birthday,
  8723. t1.behospital_date AS behospitalDate,
  8724. t1.leave_hospital_date AS leaveHospitalDate,
  8725. t1.placefile_date AS placefileDate,
  8726. t1.gmt_create AS gradeTime,
  8727. t1.diagnose,
  8728. t1.ward_name AS wardName,
  8729. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  8730. t1.file_code AS fileCode,
  8731. t1.checkStatus,
  8732. t1.mrStatus,
  8733. t1.chName,
  8734. t1.mrName,
  8735. t1.chTime,
  8736. t1.mrTime
  8737. FROM
  8738. (SELECT
  8739. be.*,
  8740. t3.name as medoupName,
  8741. b.LEVEL,
  8742. b.grade_type,
  8743. b.score_res,
  8744. b.gmt_create,
  8745. ifnull(mci.status,0) AS checkStatus,
  8746. ifnull(hm_mci.status,0) AS mrStatus,
  8747. mci.check_name as chName,
  8748. hm_mci.check_name as mrName,
  8749. mci.gmt_create as chTime,
  8750. hm_mci.gmt_create as mrTime
  8751. FROM
  8752. (
  8753. SELECT DISTINCT
  8754. a.hospital_id,
  8755. a.behospital_code,
  8756. a.bed_code,
  8757. a.file_code,
  8758. e.score_res as scoreBn,
  8759. a.NAME,
  8760. a.sex,
  8761. a.beh_dept_id,
  8762. a.beh_dept_name,
  8763. a.birthday,
  8764. a.behospital_date,
  8765. a.leave_hospital_date,
  8766. a.doctor_id,
  8767. a.doctor_name,
  8768. a.beh_doctor_id,
  8769. a.beh_doctor_name,
  8770. a.director_doctor_id,
  8771. a.director_doctor_name,
  8772. a.diagnose,
  8773. a.placefile_date,
  8774. a.ward_name
  8775. FROM
  8776. med_behospital_info a,
  8777. sys_user_dept c,
  8778. med_qcresult_cases e
  8779. WHERE
  8780. a.is_deleted = 'N'
  8781. AND c.is_deleted = 'N'
  8782. AND e.is_deleted = 'N'
  8783. AND a.hospital_id = c.hospital_id
  8784. AND a.hospital_id = e.hospital_id
  8785. AND a.beh_dept_id = c.dept_id
  8786. AND a.behospital_code = e.behospital_code
  8787. AND a.qc_type_id != 0
  8788. AND e.cases_id = 243
  8789. <if test="userId!=null">
  8790. AND c.user_id = #{userId}
  8791. </if>
  8792. <if test="deptName != null and deptName != ''">
  8793. and a.beh_dept_name = #{deptName}
  8794. </if>
  8795. <if test="deptClass != null and deptClass != ''">
  8796. and a.beh_dept_id = #{deptClass}
  8797. </if>
  8798. <if test="deptId != null and deptId != ''">
  8799. and a.beh_dept_id = #{deptId}
  8800. </if>
  8801. <if test="titleName != null and titleName != '' ">
  8802. <if test="titleName == '不合格数'">
  8803. AND e.`level`='不合格'
  8804. </if>
  8805. <if test="titleName == '合格数'">
  8806. AND e.`level`='合格'
  8807. </if>
  8808. </if>
  8809. <if test="isPlacefile != null and isPlacefile != ''">
  8810. and a.is_placefile = #{isPlacefile}
  8811. </if>
  8812. <if test="doctorId != null and doctorId != ''">
  8813. AND a.doctor_id = #{doctorId}
  8814. </if>
  8815. <if test="doctorName != null and doctorName != ''">
  8816. AND a.doctor_name = #{doctorName}
  8817. </if>
  8818. <if test="hospitalId != null and hospitalId != ''">
  8819. AND a.hospital_id = #{hospitalId}
  8820. </if>
  8821. <if test="isPlacefile != null and isPlacefile == 0">
  8822. <if test="startDate != null ">
  8823. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8824. </if>
  8825. <if test="endDate != null ">
  8826. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8827. </if>
  8828. </if>
  8829. <if test="isPlacefile != null and isPlacefile == 1">
  8830. <if test="startDate != null ">
  8831. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8832. </if>
  8833. <if test="endDate != null">
  8834. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8835. </if>
  8836. </if>
  8837. <if test="diagnose != null and diagnose != ''">
  8838. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  8839. </if>
  8840. <if test="wardName != null and wardName != ''">
  8841. AND a.ward_name LIKE CONCAT( '%', #{wardName}, '%' )
  8842. </if>
  8843. <if test="behospitalCode != null and behospitalCode != ''">
  8844. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  8845. </if>
  8846. <if test="patName != null and patName != ''">
  8847. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  8848. </if>
  8849. )be
  8850. left join med_check_info mci
  8851. on mci.is_deleted = 'N'
  8852. and mci.check_type in (0,2)
  8853. and be.hospital_id = mci.hospital_id
  8854. and be.behospital_code = mci.behospital_code
  8855. left join med_check_info hm_mci
  8856. on hm_mci.is_deleted = 'N'
  8857. and hm_mci.check_type = 1
  8858. and be.hospital_id = hm_mci.hospital_id
  8859. and be.behospital_code = hm_mci.behospital_code
  8860. left join med_qcresult_info b
  8861. on b.is_deleted = 'N'
  8862. AND be.hospital_id = b.hospital_id
  8863. AND be.behospital_code = b.behospital_code
  8864. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  8865. and be.hospital_id = t2.hospital_id
  8866. AND t2.is_deleted = 'N'
  8867. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  8868. AND t3.is_deleted = 'N'
  8869. where
  8870. 1=1
  8871. <if test="level != null and level != ''">
  8872. AND b.`level` = #{level}
  8873. </if>
  8874. <if test="medoupName != null and medoupName != ''">
  8875. AND t3.name LIKE CONCAT( '%', #{medoupName}, '%' )
  8876. </if>
  8877. ) t1
  8878. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  8879. AND t1.behospital_code = t2.behospital_code
  8880. AND t2.is_deleted = 'N'
  8881. ) t,
  8882. (
  8883. SELECT
  8884. a.doctor_id as doctorId,
  8885. a.doctor_name as doctorName
  8886. FROM
  8887. med_behospital_info a,
  8888. sys_user_dept b,
  8889. med_qcresult_cases c,
  8890. med_qcresult_detail d,
  8891. qc_cases_entry e
  8892. WHERE
  8893. a.is_deleted = 'N'
  8894. AND b.is_deleted = 'N'
  8895. AND c.is_deleted = 'N'
  8896. AND d.is_deleted = 'N'
  8897. AND e.is_deleted = 'N'
  8898. AND a.hospital_id = b.hospital_id
  8899. AND a.hospital_id = c.hospital_id
  8900. AND a.hospital_id = d.hospital_id
  8901. AND a.behospital_code = c.behospital_code
  8902. AND a.behospital_code = d.behospital_code
  8903. AND a.beh_dept_id = b.dept_id
  8904. AND c.cases_id = d.cases_id
  8905. AND d.cases_id = e.cases_id
  8906. AND d.cases_entry_id = e.id
  8907. AND d.cases_id = 243
  8908. AND a.qc_type_id != 0
  8909. <if test="userId!=null">
  8910. AND b.user_id = #{userId}
  8911. </if>
  8912. <if test="deptName != null and deptName != ''">
  8913. and a.beh_dept_name = #{deptName}
  8914. </if>
  8915. <if test="doctorName != null and doctorName != ''">
  8916. AND a.doctor_name = #{doctorName}
  8917. </if>
  8918. <if test="doctorId != null and doctorId != ''">
  8919. AND a.doctor_id = #{doctorId}
  8920. </if>
  8921. <if test="deptClass != null and deptClass != ''">
  8922. and a.beh_dept_id = #{deptClass}
  8923. </if>
  8924. <if test="deptId != null and deptId != ''">
  8925. and a.beh_dept_id = #{deptId}
  8926. </if>
  8927. <if test="isPlacefile != null and isPlacefile != ''">
  8928. and a.is_placefile = #{isPlacefile}
  8929. </if>
  8930. <if test="hospitalId != null and hospitalId != ''">
  8931. AND a.hospital_id = #{hospitalId}
  8932. </if>
  8933. <if test="isPlacefile != null and isPlacefile == 0">
  8934. <if test="startDate != null ">
  8935. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  8936. </if>
  8937. <if test="endDate != null ">
  8938. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  8939. </if>
  8940. </if>
  8941. <if test="isPlacefile != null and isPlacefile == 1">
  8942. <if test="startDate != null ">
  8943. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  8944. </if>
  8945. <if test="endDate != null">
  8946. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  8947. </if>
  8948. </if>
  8949. <if test="diagnose != null and diagnose != ''">
  8950. AND a.diagnose LIKE CONCAT( '%', #{diagnose}, '%' )
  8951. </if>
  8952. <if test="wardName != null and wardName != ''">
  8953. AND a.ward_name LIKE CONCAT( '%', #{wardName}, '%' )
  8954. </if>
  8955. <if test="behospitalCode != null and behospitalCode != ''">
  8956. AND a.behospital_code LIKE CONCAT( '%', #{behospitalCode}, '%' )
  8957. </if>
  8958. <if test="patName != null and patName != ''">
  8959. AND a.NAME LIKE CONCAT( '%', #{patName}, '%' )
  8960. </if>
  8961. GROUP BY
  8962. a.doctor_id,
  8963. a.doctor_name
  8964. ) t2
  8965. where
  8966. t.doctorId = t2.doctorId
  8967. AND t.doctorName = t2.doctorName
  8968. <if test="checkStatus != null">
  8969. AND t.checkStatus = #{checkStatus}
  8970. </if>
  8971. <if test="mrStatus != null">
  8972. AND t.mrStatus = #{mrStatus}
  8973. </if>
  8974. <if test="chName != null and chName!=''">
  8975. AND t.chName like concat('%', #{chName}, '%')
  8976. </if>
  8977. <if test="mrName != null and mrName!=''">
  8978. AND t.mrName like concat('%', #{mrName}, '%')
  8979. </if>
  8980. <if test="chTimeStart != null ">
  8981. <![CDATA[ AND t.chTime >= #{chTimeStart}]]>
  8982. </if>
  8983. <if test="chTimeEnd != null ">
  8984. <![CDATA[ AND t.chTime <= #{chTimeEnd}]]>
  8985. </if>
  8986. <if test="mrTimeStart != null ">
  8987. <![CDATA[ AND t.mrTime >= #{mrTimeStart}]]>
  8988. </if>
  8989. <if test="mrTimeEnd != null ">
  8990. <![CDATA[ AND t.mrTime <= #{mrTimeEnd}]]>
  8991. </if>
  8992. </select>
  8993. <!-- 不合格/合格数病历号(内页)全院-->
  8994. <select id="badLevelPage" resultType="com.diagbot.dto.QcResultShortDTO">
  8995. SELECT t.*
  8996. FROM
  8997. (SELECT DISTINCT
  8998. t1.hospital_id AS hospitalId,
  8999. t1.behospital_code AS behospitalCode,
  9000. t1.bed_code AS bedCode,
  9001. t1.LEVEL AS LEVEL,
  9002. t1.grade_type AS gradeType,
  9003. t1.score_res AS scoreRes,
  9004. t1.scoreBn,
  9005. t1.NAME AS NAME,
  9006. t1.sex AS sex,
  9007. t1.beh_dept_id AS behDeptId,
  9008. t1.beh_dept_name AS behDeptName,
  9009. t1.doctor_id AS doctorId,
  9010. t1.doctor_name AS doctorName,
  9011. t1.beh_doctor_id AS behDoctorId,
  9012. t1.beh_doctor_name AS behDoctorName,
  9013. t1.director_doctor_id AS directorDoctorId,
  9014. t1.director_doctor_name AS directorDoctorName,
  9015. t1.birthday AS birthday,
  9016. t1.behospital_date AS behospitalDate,
  9017. t1.leave_hospital_date AS leaveHospitalDate,
  9018. t1.placefile_date AS placefileDate,
  9019. t1.gmt_create AS gradeTime,
  9020. t1.diagnose,
  9021. t1.ward_name AS wardName,
  9022. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  9023. t1.file_code AS fileCode,
  9024. t1.checkStatus,
  9025. t1.mrStatus,
  9026. t1.chName,
  9027. t1.mrName,
  9028. t1.chTime,
  9029. t1.mrTime
  9030. FROM
  9031. (SELECT
  9032. be.*,
  9033. b.LEVEL,
  9034. b.grade_type,
  9035. b.score_res,
  9036. b.gmt_create,
  9037. ifnull(mci.status,0) AS checkStatus,
  9038. ifnull(hm_mci.status,0) AS mrStatus,
  9039. mci.check_name as chName,
  9040. hm_mci.check_name as mrName,
  9041. mci.gmt_create as chTime,
  9042. hm_mci.gmt_create as mrTime
  9043. FROM
  9044. (
  9045. SELECT DISTINCT
  9046. a.hospital_id,
  9047. a.behospital_code,
  9048. a.bed_code,
  9049. a.file_code,
  9050. e.score_res as scoreBn,
  9051. a.NAME,
  9052. a.sex,
  9053. a.beh_dept_id,
  9054. a.beh_dept_name,
  9055. a.birthday,
  9056. a.behospital_date,
  9057. a.leave_hospital_date,
  9058. a.doctor_id,
  9059. a.doctor_name,
  9060. a.beh_doctor_id,
  9061. a.beh_doctor_name,
  9062. a.director_doctor_id,
  9063. a.director_doctor_name,
  9064. a.diagnose,
  9065. a.placefile_date,
  9066. a.ward_name
  9067. FROM
  9068. med_behospital_info a,
  9069. med_qcresult_cases e
  9070. WHERE
  9071. a.is_deleted = 'N'
  9072. AND e.is_deleted = 'N'
  9073. AND a.hospital_id = e.hospital_id
  9074. AND a.behospital_code = e.behospital_code
  9075. AND a.qc_type_id != 0
  9076. AND e.cases_id = 243
  9077. <if test="qcResultPageVO.titleName != null ">
  9078. <if test="qcResultPageVO.titleName == '不合格数'">
  9079. AND e.`level`='不合格'
  9080. </if>
  9081. <if test="qcResultPageVO.titleName == '合格数'">
  9082. AND e.`level`='合格'
  9083. </if>
  9084. </if>
  9085. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  9086. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  9087. </if>
  9088. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  9089. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  9090. </if>
  9091. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  9092. <if test="qcResultPageVO.startDate != null ">
  9093. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  9094. </if>
  9095. <if test="qcResultPageVO.endDate != null ">
  9096. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  9097. </if>
  9098. </if>
  9099. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  9100. <if test="qcResultPageVO.startDate != null ">
  9101. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  9102. </if>
  9103. <if test="qcResultPageVO.endDate != null">
  9104. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  9105. </if>
  9106. </if>
  9107. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  9108. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  9109. </if>
  9110. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  9111. AND a.beh_dept_name = #{qcResultPageVO.deptName}
  9112. </if>
  9113. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  9114. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  9115. </if>
  9116. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  9117. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  9118. </if>
  9119. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  9120. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  9121. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  9122. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  9123. </if>
  9124. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  9125. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  9126. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  9127. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  9128. </if>
  9129. )be
  9130. left join med_check_info mci
  9131. on mci.is_deleted = 'N'
  9132. and mci.check_type = 0
  9133. and be.hospital_id = mci.hospital_id
  9134. and be.behospital_code = mci.behospital_code
  9135. left join med_check_info hm_mci
  9136. on hm_mci.is_deleted = 'N'
  9137. and hm_mci.check_type = 1
  9138. and be.hospital_id = hm_mci.hospital_id
  9139. and be.behospital_code = hm_mci.behospital_code
  9140. left join med_qcresult_info b
  9141. on b.is_deleted = 'N'
  9142. AND be.hospital_id = b.hospital_id
  9143. AND be.behospital_code = b.behospital_code
  9144. where
  9145. 1=1
  9146. <if test="qcResultPageVO.level != null and qcResultPageVO.level != ''">
  9147. AND b.`level` = #{qcResultPageVO.level}
  9148. </if>
  9149. ) t1
  9150. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9151. AND t1.behospital_code = t2.behospital_code
  9152. AND t2.is_deleted = 'N'
  9153. ) t,
  9154. (
  9155. SELECT
  9156. a.beh_dept_id AS deptId,
  9157. a.beh_dept_name AS deptName
  9158. FROM
  9159. med_behospital_info a,
  9160. med_qcresult_cases c,
  9161. med_qcresult_detail d,
  9162. qc_cases_entry e
  9163. WHERE
  9164. a.is_deleted = 'N'
  9165. AND c.is_deleted = 'N'
  9166. AND d.is_deleted = 'N'
  9167. AND e.is_deleted = 'N'
  9168. AND a.hospital_id = c.hospital_id
  9169. AND a.hospital_id = d.hospital_id
  9170. AND a.behospital_code = c.behospital_code
  9171. AND a.behospital_code = d.behospital_code
  9172. AND c.cases_id = d.cases_id
  9173. AND d.cases_id = e.cases_id
  9174. AND d.cases_entry_id = e.id
  9175. AND d.cases_id = 243
  9176. AND a.qc_type_id != 0
  9177. <!-- <if test="qcResultPageVO.titleName != null ">-->
  9178. <!-- <if test="qcResultPageVO.titleName == '不合格数'">-->
  9179. <!-- AND c.`level`='不合格'-->
  9180. <!-- </if>-->
  9181. <!-- <if test="qcResultPageVO.titleName == '合格数'">-->
  9182. <!-- AND c.`level`='合格'-->
  9183. <!-- </if>-->
  9184. <!-- </if>-->
  9185. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
  9186. and a.is_placefile = #{qcResultPageVO.isPlacefile}
  9187. </if>
  9188. <if test="qcResultPageVO.hospitalId != null and qcResultPageVO.hospitalId != ''">
  9189. AND a.hospital_id = #{qcResultPageVO.hospitalId}
  9190. </if>
  9191. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 0">
  9192. <if test="qcResultPageVO.startDate != null ">
  9193. <![CDATA[ AND a.behospital_date >= #{qcResultPageVO.startDate}]]>
  9194. </if>
  9195. <if test="qcResultPageVO.endDate != null ">
  9196. <![CDATA[ AND a.behospital_date <= #{qcResultPageVO.endDate}]]>
  9197. </if>
  9198. </if>
  9199. <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile == 1">
  9200. <if test="qcResultPageVO.startDate != null ">
  9201. <![CDATA[ AND a.leave_hospital_date >= #{qcResultPageVO.startDate}]]>
  9202. </if>
  9203. <if test="qcResultPageVO.endDate != null">
  9204. <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
  9205. </if>
  9206. </if>
  9207. <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
  9208. AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
  9209. </if>
  9210. <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
  9211. AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
  9212. </if>
  9213. <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
  9214. AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
  9215. </if>
  9216. <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
  9217. AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
  9218. </if>
  9219. <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
  9220. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  9221. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
  9222. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
  9223. </if>
  9224. <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
  9225. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  9226. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
  9227. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
  9228. </if>
  9229. GROUP BY
  9230. a.beh_dept_id,
  9231. a.beh_dept_name
  9232. ) t2
  9233. where
  9234. t.behDeptId = t2.deptId
  9235. AND t.behDeptName = t2.deptName
  9236. <if test="qcResultPageVO.checkStatus != null">
  9237. AND t.checkStatus = #{qcResultPageVO.checkStatus}
  9238. </if>
  9239. <if test="qcResultPageVO.mrStatus != null">
  9240. AND t.mrStatus = #{qcResultPageVO.mrStatus}
  9241. </if>
  9242. <if test="qcResultPageVO.chName != null and qcResultPageVO.chName!=''">
  9243. AND t.chName like concat('%', #{qcResultPageVO.chName}, '%')
  9244. </if>
  9245. <if test="qcResultPageVO.mrName != null and qcResultPageVO.mrName!=''">
  9246. AND t.mrName like concat('%', #{qcResultPageVO.mrName}, '%')
  9247. </if>
  9248. <if test="qcResultPageVO.chTimeStart != null ">
  9249. <![CDATA[ AND t.chTime >= #{qcResultPageVO.chTimeStart}]]>
  9250. </if>
  9251. <if test="qcResultPageVO.chTimeEnd != null ">
  9252. <![CDATA[ AND t.chTime <= #{qcResultPageVO.chTimeEnd}]]>
  9253. </if>
  9254. <if test="qcResultPageVO.mrTimeStart != null ">
  9255. <![CDATA[ AND t.mrTime >= #{qcResultPageVO.mrTimeStart}]]>
  9256. </if>
  9257. <if test="qcResultPageVO.mrTimeEnd != null ">
  9258. <![CDATA[ AND t.mrTime <= #{qcResultPageVO.mrTimeEnd}]]>
  9259. </if>
  9260. </select>
  9261. <!-- 未整改病历质控评分页(内页)-->
  9262. <select id="unModifyMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  9263. SELECT t.*
  9264. FROM
  9265. (SELECT DISTINCT
  9266. t1.hospital_id AS hospitalId,
  9267. t1.behospital_code AS behospitalCode,
  9268. t1.bed_code AS bedCode,
  9269. t1.LEVEL AS LEVEL,
  9270. t1.grade_type AS gradeType,
  9271. t1.score_res AS scoreRes,
  9272. t1.scoreBn,
  9273. t1.NAME AS NAME,
  9274. t1.sex AS sex,
  9275. t1.beh_dept_id AS behDeptId,
  9276. t1.beh_dept_name AS behDeptName,
  9277. t1.doctor_id AS doctorId,
  9278. t1.doctor_name AS doctorName,
  9279. t1.beh_doctor_id AS behDoctorId,
  9280. t1.beh_doctor_name AS behDoctorName,
  9281. t1.director_doctor_id AS directorDoctorId,
  9282. t1.director_doctor_name AS directorDoctorName,
  9283. t1.birthday AS birthday,
  9284. t1.behospital_date AS behospitalDate,
  9285. t1.leave_hospital_date AS leaveHospitalDate,
  9286. t1.placefile_date AS placefileDate,
  9287. t1.gmt_create AS gradeTime,
  9288. t1.diagnose,
  9289. t1.ward_name AS wardName,
  9290. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  9291. t1.file_code AS fileCode,
  9292. t1.checkStatus,
  9293. t1.mrStatus,
  9294. t1.chName,
  9295. t1.mrName,
  9296. t1.chTime,
  9297. t1.mrTime
  9298. FROM
  9299. (SELECT
  9300. be.*,
  9301. ifnull(mci.status,0) AS checkStatus,
  9302. ifnull(hm_mci.status,0) AS mrStatus,
  9303. mci.check_name as chName,
  9304. e.score_res as scoreBn,
  9305. hm_mci.check_name as mrName,
  9306. mci.gmt_create as chTime,
  9307. hm_mci.gmt_create as mrTime
  9308. FROM
  9309. (
  9310. SELECT DISTINCT
  9311. a.hospital_id,
  9312. a.behospital_code,
  9313. a.bed_code,
  9314. a.file_code,
  9315. b.LEVEL,
  9316. b.grade_type,
  9317. b.score_res,
  9318. a.NAME,
  9319. a.sex,
  9320. a.beh_dept_id,
  9321. a.beh_dept_name,
  9322. a.birthday,
  9323. a.behospital_date,
  9324. a.leave_hospital_date,
  9325. a.doctor_id,
  9326. a.doctor_name,
  9327. a.beh_doctor_id,
  9328. a.beh_doctor_name,
  9329. a.director_doctor_id,
  9330. a.director_doctor_name,
  9331. a.diagnose,
  9332. a.placefile_date,
  9333. a.ward_name,
  9334. b.gmt_create
  9335. FROM
  9336. med_behospital_info a,
  9337. med_qcresult_info b,
  9338. med_qcresult_detail c,
  9339. qc_cases_entry d
  9340. WHERE
  9341. a.is_deleted = 'N'
  9342. AND b.is_deleted = 'N'
  9343. AND c.is_deleted = 'N'
  9344. AND d.is_deleted = 'N'
  9345. AND a.hospital_id = b.hospital_id
  9346. AND a.hospital_id = c.hospital_id
  9347. AND a.behospital_code = b.behospital_code
  9348. AND a.behospital_code = c.behospital_code
  9349. AND c.cases_id = d.cases_id
  9350. AND c.cases_entry_id = d.id
  9351. AND a.qc_type_id != 0
  9352. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9353. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9354. </if>
  9355. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9356. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9357. </if>
  9358. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9359. <if test="qcResultShortPageVO.startDate != null ">
  9360. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9361. </if>
  9362. <if test="qcResultShortPageVO.endDate != null ">
  9363. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9364. </if>
  9365. </if>
  9366. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9367. <if test="qcResultShortPageVO.startDate != null ">
  9368. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9369. </if>
  9370. <if test="qcResultShortPageVO.endDate != null">
  9371. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9372. </if>
  9373. </if>
  9374. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9375. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9376. </if>
  9377. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9378. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9379. </if>
  9380. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9381. AND b.`level` = #{qcResultShortPageVO.level}
  9382. </if>
  9383. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9384. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9385. </if>
  9386. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9387. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9388. </if>
  9389. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9390. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  9391. </if>
  9392. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9393. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9394. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9395. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9396. </if>
  9397. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9398. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9399. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9400. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9401. </if>
  9402. <if test="qcResultShortPageVO.casesEntryId != null ">
  9403. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9404. </if>
  9405. <if test="qcResultShortPageVO.isReject != null">
  9406. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9407. </if>
  9408. <if test="qcResultShortPageVO.ruleType != null">
  9409. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9410. </if>
  9411. )be
  9412. left join med_check_info mci
  9413. on mci.is_deleted = 'N'
  9414. and mci.check_type = 0
  9415. and be.hospital_id = mci.hospital_id
  9416. and be.behospital_code = mci.behospital_code
  9417. left join med_check_info hm_mci
  9418. on hm_mci.is_deleted = 'N'
  9419. and hm_mci.check_type = 1
  9420. and be.hospital_id = hm_mci.hospital_id
  9421. and be.behospital_code = hm_mci.behospital_code
  9422. LEFT JOIN med_qcresult_cases e
  9423. on be.behospital_code = e.behospital_code
  9424. and be.hospital_id = e.hospital_id
  9425. AND e.is_deleted = 'N'
  9426. and e.cases_id = 243
  9427. ) t1
  9428. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9429. AND t1.behospital_code = t2.behospital_code
  9430. AND t2.is_deleted = 'N'
  9431. ) t
  9432. where 1=1
  9433. <if test="qcResultShortPageVO.checkStatus != null">
  9434. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9435. </if>
  9436. <if test="qcResultShortPageVO.mrStatus != null">
  9437. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9438. </if>
  9439. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9440. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9441. </if>
  9442. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9443. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9444. </if>
  9445. <if test="qcResultShortPageVO.chTimeStart != null ">
  9446. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9447. </if>
  9448. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9449. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9450. </if>
  9451. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9452. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9453. </if>
  9454. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9455. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9456. </if>
  9457. </select>
  9458. <!-- 未整改病历质控评分页-科室(内页)-->
  9459. <select id="unModifyMRByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  9460. SELECT t.*
  9461. FROM
  9462. (SELECT DISTINCT
  9463. t1.hospital_id AS hospitalId,
  9464. t1.behospital_code AS behospitalCode,
  9465. t1.bed_code AS bedCode,
  9466. t1.LEVEL AS LEVEL,
  9467. t1.grade_type AS gradeType,
  9468. t1.score_res AS scoreRes,
  9469. t1.scoreBn,
  9470. t1.NAME AS NAME,
  9471. t1.sex AS sex,
  9472. t1.beh_dept_id AS behDeptId,
  9473. t1.beh_dept_name AS behDeptName,
  9474. t1.doctor_id AS doctorId,
  9475. t1.doctor_name AS doctorName,
  9476. t1.beh_doctor_id AS behDoctorId,
  9477. t1.beh_doctor_name AS behDoctorName,
  9478. t1.director_doctor_id AS directorDoctorId,
  9479. t1.director_doctor_name AS directorDoctorName,
  9480. t1.birthday AS birthday,
  9481. t1.behospital_date AS behospitalDate,
  9482. t1.leave_hospital_date AS leaveHospitalDate,
  9483. t1.placefile_date AS placefileDate,
  9484. t1.gmt_create AS gradeTime,
  9485. t1.diagnose,
  9486. t1.medoupName,
  9487. t1.ward_name AS wardName,
  9488. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  9489. t1.file_code AS fileCode,
  9490. t1.checkStatus,
  9491. t1.mrStatus,
  9492. t1.chName,
  9493. t1.mrName,
  9494. t1.chTime,
  9495. t1.mrTime
  9496. FROM
  9497. (SELECT
  9498. be.*,
  9499. t3.name as medoupName,
  9500. ifnull(mci.status,0) AS checkStatus,
  9501. ifnull(hm_mci.status,0) AS mrStatus,
  9502. mci.check_name as chName,
  9503. e.score_res as scoreBn,
  9504. hm_mci.check_name as mrName,
  9505. mci.gmt_create as chTime,
  9506. hm_mci.gmt_create as mrTime
  9507. FROM
  9508. (
  9509. SELECT DISTINCT
  9510. a.hospital_id,
  9511. a.behospital_code,
  9512. a.bed_code,
  9513. a.file_code,
  9514. b.LEVEL,
  9515. b.grade_type,
  9516. b.score_res,
  9517. a.NAME,
  9518. a.sex,
  9519. a.beh_dept_id,
  9520. a.beh_dept_name,
  9521. a.birthday,
  9522. a.behospital_date,
  9523. a.leave_hospital_date,
  9524. a.doctor_id,
  9525. a.doctor_name,
  9526. a.beh_doctor_id,
  9527. a.beh_doctor_name,
  9528. a.director_doctor_id,
  9529. a.director_doctor_name,
  9530. a.diagnose,
  9531. a.placefile_date,
  9532. a.ward_name,
  9533. b.gmt_create
  9534. FROM
  9535. med_behospital_info a,
  9536. med_qcresult_info b,
  9537. med_qcresult_detail c,
  9538. qc_cases_entry d,
  9539. sys_user_dept f
  9540. WHERE
  9541. a.is_deleted = 'N'
  9542. AND b.is_deleted = 'N'
  9543. AND c.is_deleted = 'N'
  9544. AND d.is_deleted = 'N'
  9545. AND f.is_deleted = 'N'
  9546. AND a.hospital_id = b.hospital_id
  9547. AND a.hospital_id = c.hospital_id
  9548. AND a.hospital_id = f.hospital_id
  9549. AND a.behospital_code = b.behospital_code
  9550. AND a.behospital_code = c.behospital_code
  9551. AND c.cases_id = d.cases_id
  9552. AND a.beh_dept_id = f.dept_id
  9553. AND c.cases_entry_id = d.id
  9554. AND a.qc_type_id != 0
  9555. <if test="qcResultShortPageVO.userId!=null">
  9556. AND f.user_id = #{qcResultShortPageVO.userId}
  9557. </if>
  9558. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9559. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9560. </if>
  9561. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  9562. and a.ward_name LIKE CONCAT( '%',#{qcResultShortPageVO.wardName}, '%' )
  9563. </if>
  9564. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9565. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9566. </if>
  9567. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9568. <if test="qcResultShortPageVO.startDate != null ">
  9569. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9570. </if>
  9571. <if test="qcResultShortPageVO.endDate != null ">
  9572. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9573. </if>
  9574. </if>
  9575. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9576. <if test="qcResultShortPageVO.startDate != null ">
  9577. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9578. </if>
  9579. <if test="qcResultShortPageVO.endDate != null">
  9580. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9581. </if>
  9582. </if>
  9583. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9584. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9585. </if>
  9586. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9587. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9588. </if>
  9589. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  9590. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  9591. </if>
  9592. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9593. AND b.`level` = #{qcResultShortPageVO.level}
  9594. </if>
  9595. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9596. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9597. </if>
  9598. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9599. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9600. </if>
  9601. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9602. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  9603. </if>
  9604. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9605. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  9606. </if>
  9607. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9608. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  9609. </if>
  9610. <if test="qcResultShortPageVO.casesEntryId != null ">
  9611. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9612. </if>
  9613. <if test="qcResultShortPageVO.isReject != null">
  9614. AND c.is_reject = #{qcResultShortPageVO.isReject}
  9615. </if>
  9616. <if test="qcResultShortPageVO.ruleType != null">
  9617. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9618. </if>
  9619. )be
  9620. left join med_check_info mci
  9621. on mci.is_deleted = 'N'
  9622. and mci.check_type = 0
  9623. and be.hospital_id = mci.hospital_id
  9624. and be.behospital_code = mci.behospital_code
  9625. left join med_check_info hm_mci
  9626. on hm_mci.is_deleted = 'N'
  9627. and hm_mci.check_type = 1
  9628. and be.hospital_id = hm_mci.hospital_id
  9629. and be.behospital_code = hm_mci.behospital_code
  9630. LEFT JOIN med_qcresult_cases e
  9631. on be.behospital_code = e.behospital_code
  9632. and be.hospital_id = e.hospital_id
  9633. AND e.is_deleted = 'N'
  9634. and e.cases_id = 243
  9635. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  9636. and be.hospital_id = t2.hospital_id
  9637. AND t2.is_deleted = 'N'
  9638. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  9639. AND t3.is_deleted = 'N'
  9640. ) t1
  9641. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9642. AND t1.behospital_code = t2.behospital_code
  9643. AND t2.is_deleted = 'N'
  9644. ) t
  9645. where 1=1
  9646. <if test="qcResultShortPageVO.checkStatus != null">
  9647. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9648. </if>
  9649. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  9650. AND t.medoupName like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  9651. </if>
  9652. <if test="qcResultShortPageVO.mrStatus != null">
  9653. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9654. </if>
  9655. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9656. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9657. </if>
  9658. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9659. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9660. </if>
  9661. <if test="qcResultShortPageVO.chTimeStart != null ">
  9662. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9663. </if>
  9664. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9665. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9666. </if>
  9667. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9668. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9669. </if>
  9670. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9671. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9672. </if>
  9673. </select>
  9674. <!-- 病案首页不合格/合格数病历详情页导出-->
  9675. <select id="badLevelPagePageExport" resultMap="ExportExcelMap">
  9676. SELECT
  9677. f1.behDeptId,
  9678. f1.behDeptName,
  9679. f1.doctorName,
  9680. f1.patName,
  9681. f1.behospitalCode,
  9682. f1.hospitalId,
  9683. f1.behospitalDate,
  9684. f1.leaveHospitalDate,
  9685. f1.score,
  9686. f1.scoreBn,
  9687. f2.avgScore,
  9688. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9689. f1.msg,
  9690. f1.caseName,
  9691. </if>
  9692. f1.checkStatus,
  9693. f1.mrStatus,
  9694. f1.chName,
  9695. f1.mrName,
  9696. f1.chTime,
  9697. f1.mrTime
  9698. FROM
  9699. (SELECT
  9700. t.doctorName,
  9701. t.`name` AS patName,
  9702. t.behospitalCode AS behospitalCode,
  9703. t.behospitalDate AS behospitalDate,
  9704. t.leaveHospitalDate AS leaveHospitalDate,
  9705. qi.score_res AS score,
  9706. t.scoreBn,
  9707. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9708. qd.msg AS msg,
  9709. qc.NAME AS caseName,
  9710. </if>
  9711. t.behDeptId,
  9712. t.behDeptName,
  9713. t.hospitalId,
  9714. t.checkStatus,
  9715. t.mrStatus,
  9716. t.chName,
  9717. t.mrName,
  9718. t.chTime,
  9719. t.mrTime
  9720. FROM
  9721. (SELECT DISTINCT
  9722. t1.hospital_id AS hospitalId,
  9723. t1.behospital_code AS behospitalCode,
  9724. t1.bed_code AS bedCode,
  9725. t1.LEVEL AS LEVEL,
  9726. t1.grade_type AS gradeType,
  9727. t1.score_res AS scoreRes,
  9728. t1.scoreBn,
  9729. t1.NAME AS NAME,
  9730. t1.sex AS sex,
  9731. t1.beh_dept_id AS behDeptId,
  9732. t1.beh_dept_name AS behDeptName,
  9733. t1.doctor_id AS doctorId,
  9734. t1.doctor_name AS doctorName,
  9735. t1.beh_doctor_id AS behDoctorId,
  9736. t1.beh_doctor_name AS behDoctorName,
  9737. t1.director_doctor_id AS directorDoctorId,
  9738. t1.director_doctor_name AS directorDoctorName,
  9739. t1.birthday AS birthday,
  9740. t1.behospital_date AS behospitalDate,
  9741. t1.leave_hospital_date AS leaveHospitalDate,
  9742. t1.placefile_date AS placefileDate,
  9743. t1.gmt_create AS gradeTime,
  9744. t1.diagnose,
  9745. t1.ward_name AS wardName,
  9746. t2.age,
  9747. t1.file_code AS fileCode,
  9748. t1.checkStatus,
  9749. t1.mrStatus,
  9750. t1.chName,
  9751. t1.mrName,
  9752. t1.chTime,
  9753. t1.mrTime
  9754. FROM
  9755. (SELECT
  9756. be.*,
  9757. b.LEVEL,
  9758. b.grade_type,
  9759. b.score_res,
  9760. b.gmt_create,
  9761. ifnull(mci.status,0) AS checkStatus,
  9762. ifnull(hm_mci.status,0) AS mrStatus,
  9763. mci.check_name as chName,
  9764. hm_mci.check_name as mrName,
  9765. mci.gmt_create as chTime,
  9766. hm_mci.gmt_create as mrTime
  9767. FROM
  9768. (
  9769. SELECT DISTINCT
  9770. a.hospital_id,
  9771. a.behospital_code,
  9772. a.bed_code,
  9773. a.file_code,
  9774. c.score_res as scoreBn,
  9775. c.cases_id,
  9776. a.NAME,
  9777. a.sex,
  9778. a.beh_dept_id,
  9779. a.beh_dept_name,
  9780. a.birthday,
  9781. a.behospital_date,
  9782. a.leave_hospital_date,
  9783. a.doctor_id,
  9784. a.doctor_name,
  9785. a.beh_doctor_id,
  9786. a.beh_doctor_name,
  9787. a.director_doctor_id,
  9788. a.director_doctor_name,
  9789. a.diagnose,
  9790. a.placefile_date,
  9791. a.ward_name
  9792. FROM
  9793. med_behospital_info a,
  9794. med_qcresult_cases c
  9795. WHERE
  9796. a.is_deleted = 'N'
  9797. AND c.is_deleted = 'N'
  9798. AND a.hospital_id = c.hospital_id
  9799. AND a.behospital_code = c.behospital_code
  9800. AND a.qc_type_id != 0
  9801. AND c.cases_id = 243
  9802. <if test="qcResultShortPageVO.titleName != null ">
  9803. <if test="qcResultShortPageVO.titleName == '不合格数'">
  9804. AND c.`level`='不合格'
  9805. </if>
  9806. <if test="qcResultShortPageVO.titleName == '合格数'">
  9807. AND c.`level`='合格'
  9808. </if>
  9809. </if>
  9810. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  9811. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  9812. </if>
  9813. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  9814. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  9815. </if>
  9816. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  9817. <if test="qcResultShortPageVO.startDate != null ">
  9818. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  9819. </if>
  9820. <if test="qcResultShortPageVO.endDate != null ">
  9821. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  9822. </if>
  9823. </if>
  9824. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  9825. <if test="qcResultShortPageVO.startDate != null ">
  9826. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  9827. </if>
  9828. <if test="qcResultShortPageVO.endDate != null">
  9829. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  9830. </if>
  9831. </if>
  9832. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  9833. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  9834. </if>
  9835. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  9836. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  9837. </if>
  9838. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  9839. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  9840. </if>
  9841. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  9842. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  9843. </if>
  9844. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  9845. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9846. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  9847. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  9848. </if>
  9849. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  9850. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9851. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  9852. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  9853. </if>
  9854. )be
  9855. left join med_check_info mci
  9856. on mci.is_deleted = 'N'
  9857. and mci.check_type = 0
  9858. and be.hospital_id = mci.hospital_id
  9859. and be.behospital_code = mci.behospital_code
  9860. left join med_check_info hm_mci
  9861. on hm_mci.is_deleted = 'N'
  9862. and hm_mci.check_type = 1
  9863. and be.hospital_id = hm_mci.hospital_id
  9864. and be.behospital_code = hm_mci.behospital_code
  9865. left join med_qcresult_info b
  9866. on b.is_deleted = 'N'
  9867. AND be.hospital_id = b.hospital_id
  9868. AND be.behospital_code = b.behospital_code
  9869. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  9870. AND b.`level` = #{qcResultPageVO.level}
  9871. </if>
  9872. left join qc_cases_entry d
  9873. on d.is_deleted = 'N'
  9874. AND be.cases_id = d.cases_id
  9875. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9876. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  9877. </if>
  9878. <if test="qcResultShortPageVO.casesEntryId != null ">
  9879. AND d.id = #{qcResultShortPageVO.casesEntryId}
  9880. </if>
  9881. <if test="qcResultShortPageVO.ruleType != null">
  9882. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  9883. </if>
  9884. ) t1
  9885. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  9886. AND t1.behospital_code = t2.behospital_code
  9887. AND t2.is_deleted = 'N'
  9888. ) t
  9889. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  9890. AND t.hospitalId = qi.hospital_id
  9891. AND t.behospitalCode = qi.behospital_code
  9892. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  9893. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  9894. AND t.hospitalId = qd.hospital_id
  9895. AND t.behospitalCode = qd.behospital_code
  9896. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  9897. AND qd.cases_id = qc.id
  9898. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  9899. AND qd.cases_id = qce.cases_id
  9900. AND qd.cases_entry_id = qce.id
  9901. </if>
  9902. where 1=1
  9903. <if test="qcResultShortPageVO.checkStatus != null">
  9904. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  9905. </if>
  9906. <if test="qcResultShortPageVO.mrStatus != null">
  9907. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  9908. </if>
  9909. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  9910. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  9911. </if>
  9912. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  9913. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  9914. </if>
  9915. <if test="qcResultShortPageVO.chTimeStart != null ">
  9916. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  9917. </if>
  9918. <if test="qcResultShortPageVO.chTimeEnd != null ">
  9919. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  9920. </if>
  9921. <if test="qcResultShortPageVO.mrTimeStart != null ">
  9922. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  9923. </if>
  9924. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  9925. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  9926. </if>
  9927. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  9928. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  9929. </if>
  9930. <if test="qcResultShortPageVO.casesEntryId != null ">
  9931. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  9932. </if>
  9933. )f1,
  9934. (SELECT
  9935. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  9936. t.behDeptId,
  9937. t.behDeptName
  9938. FROM
  9939. (SELECT DISTINCT
  9940. t1.hospital_id AS hospitalId,
  9941. t1.behospital_code AS behospitalCode,
  9942. t1.bed_code AS bedCode,
  9943. t1.LEVEL AS LEVEL,
  9944. t1.grade_type AS gradeType,
  9945. t1.score_res AS scoreRes,
  9946. t1.NAME AS NAME,
  9947. t1.sex AS sex,
  9948. t1.beh_dept_id AS behDeptId,
  9949. t1.beh_dept_name AS behDeptName,
  9950. t1.doctor_id AS doctorId,
  9951. t1.doctor_name AS doctorName,
  9952. t1.beh_doctor_id AS behDoctorId,
  9953. t1.beh_doctor_name AS behDoctorName,
  9954. t1.director_doctor_id AS directorDoctorId,
  9955. t1.director_doctor_name AS directorDoctorName,
  9956. t1.birthday AS birthday,
  9957. t1.behospital_date AS behospitalDate,
  9958. t1.leave_hospital_date AS leaveHospitalDate,
  9959. t1.placefile_date AS placefileDate,
  9960. t1.gmt_create AS gradeTime,
  9961. t1.diagnose,
  9962. t1.ward_name AS wardName,
  9963. t2.age,
  9964. t1.file_code AS fileCode,
  9965. t1.checkStatus,
  9966. t1.mrStatus,
  9967. t1.chName,
  9968. t1.mrName,
  9969. t1.chTime,
  9970. t1.mrTime
  9971. FROM
  9972. (SELECT
  9973. be.*,
  9974. b.grade_type,
  9975. b.score_res,
  9976. b.gmt_create,
  9977. b.LEVEL,
  9978. ifnull(mci.status,0) AS checkStatus,
  9979. ifnull(hm_mci.status,0) AS mrStatus,
  9980. mci.check_name as chName,
  9981. hm_mci.check_name as mrName,
  9982. mci.gmt_create as chTime,
  9983. hm_mci.gmt_create as mrTime
  9984. FROM
  9985. (
  9986. SELECT DISTINCT
  9987. a.hospital_id,
  9988. a.behospital_code,
  9989. a.bed_code,
  9990. a.file_code,
  9991. a.NAME,
  9992. a.sex,
  9993. a.beh_dept_id,
  9994. a.beh_dept_name,
  9995. a.birthday,
  9996. a.behospital_date,
  9997. a.leave_hospital_date,
  9998. a.doctor_id,
  9999. a.doctor_name,
  10000. a.beh_doctor_id,
  10001. a.beh_doctor_name,
  10002. a.director_doctor_id,
  10003. a.director_doctor_name,
  10004. a.diagnose,
  10005. a.placefile_date,
  10006. a.ward_name
  10007. FROM
  10008. med_behospital_info a,
  10009. med_qcresult_detail k,
  10010. med_qcresult_cases c,
  10011. qc_cases_entry d
  10012. WHERE
  10013. a.is_deleted = 'N'
  10014. AND c.is_deleted = 'N'
  10015. AND d.is_deleted = 'N'
  10016. AND a.hospital_id = c.hospital_id
  10017. AND a.behospital_code = c.behospital_code
  10018. AND c.cases_id = d.cases_id
  10019. AND a.hospital_id = k.hospital_id
  10020. AND a.behospital_code = k.behospital_code
  10021. AND c.cases_id = k.cases_id
  10022. AND k.cases_id = d.cases_id
  10023. AND k.cases_entry_id = d.id
  10024. <!-- <if test="qcResultShortPageVO.titleName != null ">-->
  10025. <!-- <if test="qcResultShortPageVO.titleName == '不合格数'">-->
  10026. <!-- AND c.`level`='不合格'-->
  10027. <!-- </if>-->
  10028. <!-- <if test="qcResultShortPageVO.titleName == '合格数'">-->
  10029. <!-- AND c.`level`='合格'-->
  10030. <!-- </if>-->
  10031. <!-- </if>-->
  10032. AND a.qc_type_id != 0
  10033. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10034. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10035. </if>
  10036. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10037. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10038. </if>
  10039. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10040. <if test="qcResultShortPageVO.startDate != null ">
  10041. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10042. </if>
  10043. <if test="qcResultShortPageVO.endDate != null ">
  10044. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10045. </if>
  10046. </if>
  10047. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10048. <if test="qcResultShortPageVO.startDate != null ">
  10049. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10050. </if>
  10051. <if test="qcResultShortPageVO.endDate != null">
  10052. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10053. </if>
  10054. </if>
  10055. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10056. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10057. </if>
  10058. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10059. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10060. </if>
  10061. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10062. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10063. </if>
  10064. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10065. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10066. </if>
  10067. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10068. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10069. </if>
  10070. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10071. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10072. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10073. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10074. </if>
  10075. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10076. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10077. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10078. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10079. </if>
  10080. <if test="qcResultShortPageVO.casesEntryId != null ">
  10081. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10082. </if>
  10083. <if test="qcResultShortPageVO.ruleType != null">
  10084. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10085. </if>
  10086. )be
  10087. left join med_check_info mci
  10088. on mci.is_deleted = 'N'
  10089. and mci.check_type = 0
  10090. and be.hospital_id = mci.hospital_id
  10091. and be.behospital_code = mci.behospital_code
  10092. left join med_check_info hm_mci
  10093. on hm_mci.is_deleted = 'N'
  10094. and hm_mci.check_type = 1
  10095. and be.hospital_id = hm_mci.hospital_id
  10096. and be.behospital_code = hm_mci.behospital_code
  10097. left join med_qcresult_info b
  10098. on b.is_deleted = 'N'
  10099. AND be.hospital_id = b.hospital_id
  10100. AND be.behospital_code = b.behospital_code
  10101. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10102. AND b.`level` = #{qcResultPageVO.level}
  10103. </if>
  10104. ) t1
  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. ) t
  10109. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10110. AND t.hospitalId = qi.hospital_id
  10111. AND t.behospitalCode = qi.behospital_code
  10112. where 1=1
  10113. <if test="qcResultShortPageVO.checkStatus != null">
  10114. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10115. </if>
  10116. <if test="qcResultShortPageVO.mrStatus != null">
  10117. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10118. </if>
  10119. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10120. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10121. </if>
  10122. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10123. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10124. </if>
  10125. <if test="qcResultShortPageVO.chTimeStart != null ">
  10126. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10127. </if>
  10128. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10129. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10130. </if>
  10131. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10132. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10133. </if>
  10134. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10135. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10136. </if>
  10137. GROUP BY
  10138. t.behDeptId,
  10139. t.behDeptName
  10140. )f2
  10141. WHERE
  10142. f1.behDeptId = f2.behDeptId
  10143. AND f1.behDeptName = f2.behDeptName
  10144. </select>
  10145. <!-- 病案首页不合格/合格数病历详情页导出-科室-->
  10146. <select id="homePageOrLevelExportByDept" resultMap="ExportExcelMapByDept">
  10147. SELECT
  10148. f1.behDeptId,
  10149. f1.behDeptName,
  10150. f1.doctorName,
  10151. f1.patName,
  10152. f1.behospitalCode,
  10153. f1.hospitalId,
  10154. f1.wardName,
  10155. f1.medoupName,
  10156. f1.behospitalDate,
  10157. f1.leaveHospitalDate,
  10158. f1.score,
  10159. f1.scoreBn,
  10160. f2.avgScore,
  10161. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  10162. f1.msg,
  10163. f1.caseName,
  10164. </if>
  10165. f1.checkStatus,
  10166. f1.mrStatus,
  10167. f1.chName,
  10168. f1.mrName,
  10169. f1.chTime,
  10170. f1.mrTime
  10171. FROM
  10172. (SELECT
  10173. t.doctorName AS doctorName,
  10174. t.doctorId,
  10175. t.`name` AS patName,
  10176. t.wardName,
  10177. t.behospitalCode AS behospitalCode,
  10178. t.behospitalDate AS behospitalDate,
  10179. t.leaveHospitalDate AS leaveHospitalDate,
  10180. qi.score_res AS score,
  10181. t.scoreBn,
  10182. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  10183. qd.msg AS msg,
  10184. qc.NAME AS caseName,
  10185. </if>
  10186. t.behDeptId,
  10187. t.behDeptName,
  10188. t.hospitalId,
  10189. t.checkStatus,
  10190. t.mrStatus,
  10191. t.chName,
  10192. t.mrName,
  10193. t.chTime,
  10194. t.mrTime,
  10195. t3.name as medoupName
  10196. FROM
  10197. (SELECT DISTINCT
  10198. t1.hospital_id AS hospitalId,
  10199. t1.behospital_code AS behospitalCode,
  10200. t1.bed_code AS bedCode,
  10201. t1.LEVEL AS LEVEL,
  10202. t1.grade_type AS gradeType,
  10203. t1.score_res AS scoreRes,
  10204. t1.scoreBn,
  10205. t1.NAME AS NAME,
  10206. t1.sex AS sex,
  10207. t1.beh_dept_id AS behDeptId,
  10208. t1.beh_dept_name AS behDeptName,
  10209. t1.doctor_id AS doctorId,
  10210. t1.doctor_name AS doctorName,
  10211. t1.beh_doctor_id AS behDoctorId,
  10212. t1.beh_doctor_name AS behDoctorName,
  10213. t1.director_doctor_id AS directorDoctorId,
  10214. t1.director_doctor_name AS directorDoctorName,
  10215. t1.birthday AS birthday,
  10216. t1.behospital_date AS behospitalDate,
  10217. t1.leave_hospital_date AS leaveHospitalDate,
  10218. t1.placefile_date AS placefileDate,
  10219. t1.gmt_create AS gradeTime,
  10220. t1.diagnose,
  10221. t1.ward_name AS wardName,
  10222. t2.age,
  10223. t1.file_code AS fileCode,
  10224. t1.checkStatus,
  10225. t1.mrStatus,
  10226. t1.chName,
  10227. t1.mrName,
  10228. t1.chTime,
  10229. t1.mrTime
  10230. FROM
  10231. (SELECT
  10232. be.*,
  10233. b.LEVEL,
  10234. b.grade_type,
  10235. b.score_res,
  10236. b.gmt_create,
  10237. ifnull(mci.status,0) AS checkStatus,
  10238. ifnull(hm_mci.status,0) AS mrStatus,
  10239. mci.check_name as chName,
  10240. hm_mci.check_name as mrName,
  10241. mci.gmt_create as chTime,
  10242. hm_mci.gmt_create as mrTime
  10243. FROM
  10244. (
  10245. SELECT DISTINCT
  10246. a.hospital_id,
  10247. a.behospital_code,
  10248. a.bed_code,
  10249. a.file_code,
  10250. c.score_res as scoreBn,
  10251. c.cases_id,
  10252. a.NAME,
  10253. a.sex,
  10254. a.beh_dept_id,
  10255. a.beh_dept_name,
  10256. a.birthday,
  10257. a.behospital_date,
  10258. a.leave_hospital_date,
  10259. a.doctor_id,
  10260. a.doctor_name,
  10261. a.beh_doctor_id,
  10262. a.beh_doctor_name,
  10263. a.director_doctor_id,
  10264. a.director_doctor_name,
  10265. a.diagnose,
  10266. a.placefile_date,
  10267. a.ward_name
  10268. FROM
  10269. med_behospital_info a,
  10270. sys_user_dept b,
  10271. med_qcresult_cases c
  10272. WHERE
  10273. a.is_deleted = 'N'
  10274. AND b.is_deleted = 'N'
  10275. AND c.is_deleted = 'N'
  10276. AND a.hospital_id = b.hospital_id
  10277. AND a.beh_dept_id = b.dept_id
  10278. AND a.hospital_id = c.hospital_id
  10279. AND a.behospital_code = c.behospital_code
  10280. AND a.qc_type_id != 0
  10281. AND c.cases_id = 243
  10282. <if test="qcResultShortPageVO.userId!=null">
  10283. AND b.user_id = #{qcResultShortPageVO.userId}
  10284. </if>
  10285. <if test="qcResultShortPageVO.titleName != null ">
  10286. <if test="qcResultShortPageVO.titleName == '不合格数'">
  10287. AND c.`level`='不合格'
  10288. </if>
  10289. <if test="qcResultShortPageVO.titleName == '合格数'">
  10290. AND c.`level`='合格'
  10291. </if>
  10292. </if>
  10293. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10294. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10295. </if>
  10296. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10297. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10298. </if>
  10299. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10300. <if test="qcResultShortPageVO.startDate != null ">
  10301. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10302. </if>
  10303. <if test="qcResultShortPageVO.endDate != null ">
  10304. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10305. </if>
  10306. </if>
  10307. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10308. <if test="qcResultShortPageVO.startDate != null ">
  10309. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10310. </if>
  10311. <if test="qcResultShortPageVO.endDate != null">
  10312. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10313. </if>
  10314. </if>
  10315. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10316. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10317. </if>
  10318. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  10319. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  10320. </if>
  10321. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10322. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10323. </if>
  10324. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  10325. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  10326. </if>
  10327. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10328. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10329. </if>
  10330. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10331. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10332. </if>
  10333. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10334. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  10335. </if>
  10336. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10337. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  10338. </if>
  10339. )be
  10340. left join med_check_info mci
  10341. on mci.is_deleted = 'N'
  10342. and mci.check_type = 0
  10343. and be.hospital_id = mci.hospital_id
  10344. and be.behospital_code = mci.behospital_code
  10345. left join med_check_info hm_mci
  10346. on hm_mci.is_deleted = 'N'
  10347. and hm_mci.check_type = 1
  10348. and be.hospital_id = hm_mci.hospital_id
  10349. and be.behospital_code = hm_mci.behospital_code
  10350. left join med_qcresult_info b
  10351. on b.is_deleted = 'N'
  10352. AND be.hospital_id = b.hospital_id
  10353. AND be.behospital_code = b.behospital_code
  10354. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10355. AND b.`level` = #{qcResultPageVO.level}
  10356. </if>
  10357. left join qc_cases_entry d
  10358. on d.is_deleted = 'N'
  10359. AND be.cases_id = d.cases_id
  10360. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10361. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10362. </if>
  10363. <if test="qcResultShortPageVO.casesEntryId != null ">
  10364. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10365. </if>
  10366. <if test="qcResultShortPageVO.ruleType != null">
  10367. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10368. </if>
  10369. ) t1
  10370. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10371. AND t1.behospital_code = t2.behospital_code
  10372. AND t2.is_deleted = 'N'
  10373. ) t
  10374. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10375. AND t.hospitalId = qi.hospital_id
  10376. AND t.behospitalCode = qi.behospital_code
  10377. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  10378. AND t.hospitalId = t2.hospital_id
  10379. AND t2.is_deleted = 'N'
  10380. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  10381. AND t3.is_deleted = 'N'
  10382. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  10383. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10384. AND t.hospitalId = qd.hospital_id
  10385. AND t.behospitalCode = qd.behospital_code
  10386. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10387. AND qd.cases_id = qc.id
  10388. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10389. AND qd.cases_id = qce.cases_id
  10390. AND qd.cases_entry_id = qce.id
  10391. </if>
  10392. where 1=1
  10393. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  10394. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  10395. </if>
  10396. <if test="qcResultShortPageVO.checkStatus != null">
  10397. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10398. </if>
  10399. <if test="qcResultShortPageVO.mrStatus != null">
  10400. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10401. </if>
  10402. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10403. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10404. </if>
  10405. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10406. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10407. </if>
  10408. <if test="qcResultShortPageVO.chTimeStart != null ">
  10409. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10410. </if>
  10411. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10412. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10413. </if>
  10414. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10415. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10416. </if>
  10417. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10418. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10419. </if>
  10420. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10421. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10422. </if>
  10423. <if test="qcResultShortPageVO.casesEntryId != null ">
  10424. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10425. </if>
  10426. )f1,
  10427. (SELECT
  10428. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10429. t.doctorId,
  10430. t.doctorName
  10431. FROM
  10432. (SELECT DISTINCT
  10433. t1.hospital_id AS hospitalId,
  10434. t1.behospital_code AS behospitalCode,
  10435. t1.bed_code AS bedCode,
  10436. t1.LEVEL AS LEVEL,
  10437. t1.grade_type AS gradeType,
  10438. t1.score_res AS scoreRes,
  10439. t1.NAME AS NAME,
  10440. t1.sex AS sex,
  10441. t1.beh_dept_id AS behDeptId,
  10442. t1.beh_dept_name AS behDeptName,
  10443. t1.doctor_id AS doctorId,
  10444. t1.doctor_name AS doctorName,
  10445. t1.beh_doctor_id AS behDoctorId,
  10446. t1.beh_doctor_name AS behDoctorName,
  10447. t1.director_doctor_id AS directorDoctorId,
  10448. t1.director_doctor_name AS directorDoctorName,
  10449. t1.birthday AS birthday,
  10450. t1.behospital_date AS behospitalDate,
  10451. t1.leave_hospital_date AS leaveHospitalDate,
  10452. t1.placefile_date AS placefileDate,
  10453. t1.gmt_create AS gradeTime,
  10454. t1.diagnose,
  10455. t1.ward_name AS wardName,
  10456. t2.age,
  10457. t1.file_code AS fileCode,
  10458. t1.checkStatus,
  10459. t1.mrStatus,
  10460. t1.chName,
  10461. t1.mrName,
  10462. t1.chTime,
  10463. t1.mrTime
  10464. FROM
  10465. (SELECT
  10466. be.*,
  10467. b.grade_type,
  10468. b.score_res,
  10469. b.gmt_create,
  10470. b.LEVEL,
  10471. ifnull(mci.status,0) AS checkStatus,
  10472. ifnull(hm_mci.status,0) AS mrStatus,
  10473. mci.check_name as chName,
  10474. hm_mci.check_name as mrName,
  10475. mci.gmt_create as chTime,
  10476. hm_mci.gmt_create as mrTime
  10477. FROM
  10478. (
  10479. SELECT DISTINCT
  10480. a.hospital_id,
  10481. a.behospital_code,
  10482. a.bed_code,
  10483. a.file_code,
  10484. a.NAME,
  10485. a.sex,
  10486. a.beh_dept_id,
  10487. a.beh_dept_name,
  10488. a.birthday,
  10489. a.behospital_date,
  10490. a.leave_hospital_date,
  10491. a.doctor_id,
  10492. a.doctor_name,
  10493. a.beh_doctor_id,
  10494. a.beh_doctor_name,
  10495. a.director_doctor_id,
  10496. a.director_doctor_name,
  10497. a.diagnose,
  10498. a.placefile_date,
  10499. a.ward_name
  10500. FROM
  10501. med_behospital_info a,
  10502. med_qcresult_detail k,
  10503. sys_user_dept b,
  10504. med_qcresult_cases c,
  10505. qc_cases_entry d
  10506. WHERE
  10507. a.is_deleted = 'N'
  10508. AND b.is_deleted = 'N'
  10509. AND c.is_deleted = 'N'
  10510. AND d.is_deleted = 'N'
  10511. AND a.hospital_id = b.hospital_id
  10512. AND a.hospital_id = c.hospital_id
  10513. AND a.behospital_code = c.behospital_code
  10514. AND a.beh_dept_id = b.dept_id
  10515. AND c.cases_id = d.cases_id
  10516. AND a.hospital_id = k.hospital_id
  10517. AND a.behospital_code = k.behospital_code
  10518. AND c.cases_id = k.cases_id
  10519. AND k.cases_id = d.cases_id
  10520. AND k.cases_entry_id = d.id
  10521. AND a.qc_type_id != 0
  10522. <if test="qcResultShortPageVO.userId!=null">
  10523. AND b.user_id = #{qcResultShortPageVO.userId}
  10524. </if>
  10525. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10526. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10527. </if>
  10528. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10529. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10530. </if>
  10531. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10532. <if test="qcResultShortPageVO.startDate != null ">
  10533. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10534. </if>
  10535. <if test="qcResultShortPageVO.endDate != null ">
  10536. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10537. </if>
  10538. </if>
  10539. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10540. <if test="qcResultShortPageVO.startDate != null ">
  10541. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10542. </if>
  10543. <if test="qcResultShortPageVO.endDate != null">
  10544. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10545. </if>
  10546. </if>
  10547. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10548. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10549. </if>
  10550. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  10551. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  10552. </if>
  10553. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10554. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10555. </if>
  10556. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  10557. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  10558. </if>
  10559. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10560. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10561. </if>
  10562. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10563. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10564. </if>
  10565. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10566. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10567. </if>
  10568. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10569. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  10570. </if>
  10571. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10572. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  10573. </if>
  10574. <if test="qcResultShortPageVO.casesEntryId != null ">
  10575. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10576. </if>
  10577. <if test="qcResultShortPageVO.ruleType != null">
  10578. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10579. </if>
  10580. )be
  10581. left join med_check_info mci
  10582. on mci.is_deleted = 'N'
  10583. and mci.check_type = 0
  10584. and be.hospital_id = mci.hospital_id
  10585. and be.behospital_code = mci.behospital_code
  10586. left join med_check_info hm_mci
  10587. on hm_mci.is_deleted = 'N'
  10588. and hm_mci.check_type = 1
  10589. and be.hospital_id = hm_mci.hospital_id
  10590. and be.behospital_code = hm_mci.behospital_code
  10591. left join med_qcresult_info b
  10592. on b.is_deleted = 'N'
  10593. AND be.hospital_id = b.hospital_id
  10594. AND be.behospital_code = b.behospital_code
  10595. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10596. AND b.`level` = #{qcResultPageVO.level}
  10597. </if>
  10598. ) t1
  10599. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10600. AND t1.behospital_code = t2.behospital_code
  10601. AND t2.is_deleted = 'N'
  10602. ) t
  10603. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10604. AND t.hospitalId = qi.hospital_id
  10605. AND t.behospitalCode = qi.behospital_code
  10606. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  10607. AND t.hospitalId = t2.hospital_id
  10608. AND t2.is_deleted = 'N'
  10609. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  10610. AND t3.is_deleted = 'N'
  10611. where 1=1
  10612. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  10613. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  10614. </if>
  10615. <if test="qcResultShortPageVO.checkStatus != null">
  10616. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10617. </if>
  10618. <if test="qcResultShortPageVO.mrStatus != null">
  10619. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10620. </if>
  10621. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10622. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10623. </if>
  10624. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10625. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10626. </if>
  10627. <if test="qcResultShortPageVO.chTimeStart != null ">
  10628. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10629. </if>
  10630. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10631. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10632. </if>
  10633. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10634. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10635. </if>
  10636. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10637. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10638. </if>
  10639. GROUP BY
  10640. t.behDeptId,
  10641. t.behDeptName,
  10642. t.doctorId,
  10643. t.doctorName
  10644. )f2
  10645. WHERE
  10646. f1.doctorId = f2.doctorId
  10647. AND f1.doctorName = f2.doctorName
  10648. </select>
  10649. <!-- 未整改病历缺陷评分详情页导出-->
  10650. <select id="unModifyMRPageExport" resultMap="ExportExcelMap">
  10651. SELECT
  10652. f1.behDeptId,
  10653. f1.behDeptName,
  10654. f1.doctorName,
  10655. f1.patName,
  10656. f1.behospitalCode,
  10657. f1.hospitalId,
  10658. f1.behospitalDate,
  10659. f1.leaveHospitalDate,
  10660. f1.score,
  10661. f1.scoreBn,
  10662. f2.avgScore,
  10663. f1.msg,
  10664. f1.caseName,
  10665. f1.checkStatus,
  10666. f1.mrStatus,
  10667. f1.chName,
  10668. f1.mrName,
  10669. f1.chTime,
  10670. f1.mrTime
  10671. FROM
  10672. (SELECT
  10673. t.doctorName,
  10674. t.`name` AS patName,
  10675. t.behospitalCode AS behospitalCode,
  10676. t.behospitalDate AS behospitalDate,
  10677. t.leaveHospitalDate AS leaveHospitalDate,
  10678. qi.score_res AS score,
  10679. t.scoreBn,
  10680. qd.msg AS msg,
  10681. qc.NAME AS caseName,
  10682. t.behDeptId,
  10683. t.behDeptName,
  10684. t.hospitalId,
  10685. t.checkStatus,
  10686. t.mrStatus,
  10687. t.chName,
  10688. t.mrName,
  10689. t.chTime,
  10690. t.mrTime
  10691. FROM
  10692. (SELECT DISTINCT
  10693. t1.hospital_id AS hospitalId,
  10694. t1.behospital_code AS behospitalCode,
  10695. t1.bed_code AS bedCode,
  10696. t1.LEVEL AS LEVEL,
  10697. t1.grade_type AS gradeType,
  10698. t1.score_res AS scoreRes,
  10699. t1.scoreBn,
  10700. t1.NAME AS NAME,
  10701. t1.sex AS sex,
  10702. t1.beh_dept_id AS behDeptId,
  10703. t1.beh_dept_name AS behDeptName,
  10704. t1.doctor_id AS doctorId,
  10705. t1.doctor_name AS doctorName,
  10706. t1.beh_doctor_id AS behDoctorId,
  10707. t1.beh_doctor_name AS behDoctorName,
  10708. t1.director_doctor_id AS directorDoctorId,
  10709. t1.director_doctor_name AS directorDoctorName,
  10710. t1.birthday AS birthday,
  10711. t1.behospital_date AS behospitalDate,
  10712. t1.leave_hospital_date AS leaveHospitalDate,
  10713. t1.placefile_date AS placefileDate,
  10714. t1.gmt_create AS gradeTime,
  10715. t1.diagnose,
  10716. t1.ward_name AS wardName,
  10717. t2.age,
  10718. t1.file_code AS fileCode,
  10719. t1.checkStatus,
  10720. t1.mrStatus,
  10721. t1.chName,
  10722. t1.mrName,
  10723. t1.chTime,
  10724. t1.mrTime
  10725. FROM
  10726. (SELECT
  10727. be.*,
  10728. ifnull(mci.status,0) AS checkStatus,
  10729. ifnull(hm_mci.status,0) AS mrStatus,
  10730. mci.check_name as chName,
  10731. e.score_res as scoreBn,
  10732. hm_mci.check_name as mrName,
  10733. mci.gmt_create as chTime,
  10734. hm_mci.gmt_create as mrTime
  10735. FROM
  10736. (
  10737. SELECT DISTINCT
  10738. a.hospital_id,
  10739. a.behospital_code,
  10740. a.bed_code,
  10741. a.file_code,
  10742. b.LEVEL,
  10743. b.grade_type,
  10744. b.score_res,
  10745. a.NAME,
  10746. a.sex,
  10747. a.beh_dept_id,
  10748. a.beh_dept_name,
  10749. a.birthday,
  10750. a.behospital_date,
  10751. a.leave_hospital_date,
  10752. a.doctor_id,
  10753. a.doctor_name,
  10754. a.beh_doctor_id,
  10755. a.beh_doctor_name,
  10756. a.director_doctor_id,
  10757. a.director_doctor_name,
  10758. a.diagnose,
  10759. a.placefile_date,
  10760. a.ward_name,
  10761. b.gmt_create
  10762. FROM
  10763. med_behospital_info a,
  10764. med_qcresult_info b,
  10765. med_qcresult_detail c,
  10766. qc_cases_entry d
  10767. WHERE
  10768. a.is_deleted = 'N'
  10769. AND b.is_deleted = 'N'
  10770. AND c.is_deleted = 'N'
  10771. AND d.is_deleted = 'N'
  10772. AND a.hospital_id = b.hospital_id
  10773. AND a.hospital_id = c.hospital_id
  10774. AND a.behospital_code = b.behospital_code
  10775. AND a.behospital_code = c.behospital_code
  10776. AND c.cases_id = d.cases_id
  10777. AND c.cases_entry_id = d.id
  10778. AND a.qc_type_id != 0
  10779. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10780. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10781. </if>
  10782. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10783. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10784. </if>
  10785. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10786. <if test="qcResultShortPageVO.startDate != null ">
  10787. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  10788. </if>
  10789. <if test="qcResultShortPageVO.endDate != null ">
  10790. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  10791. </if>
  10792. </if>
  10793. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  10794. <if test="qcResultShortPageVO.startDate != null ">
  10795. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  10796. </if>
  10797. <if test="qcResultShortPageVO.endDate != null">
  10798. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  10799. </if>
  10800. </if>
  10801. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  10802. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  10803. </if>
  10804. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  10805. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  10806. </if>
  10807. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  10808. AND b.`level` = #{qcResultShortPageVO.level}
  10809. </if>
  10810. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  10811. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  10812. </if>
  10813. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  10814. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  10815. </if>
  10816. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  10817. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10818. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  10819. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  10820. </if>
  10821. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  10822. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10823. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  10824. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  10825. </if>
  10826. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10827. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  10828. </if>
  10829. <if test="qcResultShortPageVO.casesEntryId != null ">
  10830. AND d.id = #{qcResultShortPageVO.casesEntryId}
  10831. </if>
  10832. <if test="qcResultShortPageVO.isReject != null">
  10833. AND c.is_reject = #{qcResultShortPageVO.isReject}
  10834. </if>
  10835. <if test="qcResultShortPageVO.ruleType != null">
  10836. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  10837. </if>
  10838. )be
  10839. left join med_check_info mci
  10840. on mci.is_deleted = 'N'
  10841. and mci.check_type = 0
  10842. and be.hospital_id = mci.hospital_id
  10843. and be.behospital_code = mci.behospital_code
  10844. left join med_check_info hm_mci
  10845. on hm_mci.is_deleted = 'N'
  10846. and hm_mci.check_type = 1
  10847. and be.hospital_id = hm_mci.hospital_id
  10848. and be.behospital_code = hm_mci.behospital_code
  10849. LEFT JOIN med_qcresult_cases e
  10850. on be.behospital_code = e.behospital_code
  10851. and be.hospital_id = e.hospital_id
  10852. AND e.is_deleted = 'N'
  10853. and e.cases_id = 243
  10854. ) t1
  10855. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  10856. AND t1.behospital_code = t2.behospital_code
  10857. AND t2.is_deleted = 'N'
  10858. ) t
  10859. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  10860. AND t.hospitalId = qi.hospital_id
  10861. AND t.behospitalCode = qi.behospital_code
  10862. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  10863. AND t.hospitalId = qd.hospital_id
  10864. AND t.behospitalCode = qd.behospital_code
  10865. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  10866. AND qd.cases_id = qc.id
  10867. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  10868. AND qd.cases_id = qce.cases_id
  10869. AND qd.cases_entry_id = qce.id
  10870. where 1=1
  10871. <if test="qcResultShortPageVO.checkStatus != null">
  10872. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  10873. </if>
  10874. <if test="qcResultShortPageVO.mrStatus != null">
  10875. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  10876. </if>
  10877. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  10878. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  10879. </if>
  10880. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  10881. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  10882. </if>
  10883. <if test="qcResultShortPageVO.chTimeStart != null ">
  10884. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  10885. </if>
  10886. <if test="qcResultShortPageVO.chTimeEnd != null ">
  10887. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  10888. </if>
  10889. <if test="qcResultShortPageVO.mrTimeStart != null ">
  10890. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  10891. </if>
  10892. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  10893. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  10894. </if>
  10895. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  10896. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  10897. </if>
  10898. <if test="qcResultShortPageVO.casesEntryId != null ">
  10899. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  10900. </if>
  10901. )f1,
  10902. (SELECT
  10903. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  10904. t.behDeptId,
  10905. t.behDeptName
  10906. FROM
  10907. (SELECT DISTINCT
  10908. t1.hospital_id AS hospitalId,
  10909. t1.behospital_code AS behospitalCode,
  10910. t1.bed_code AS bedCode,
  10911. t1.LEVEL AS LEVEL,
  10912. t1.grade_type AS gradeType,
  10913. t1.score_res AS scoreRes,
  10914. t1.NAME AS NAME,
  10915. t1.sex AS sex,
  10916. t1.beh_dept_id AS behDeptId,
  10917. t1.beh_dept_name AS behDeptName,
  10918. t1.doctor_id AS doctorId,
  10919. t1.doctor_name AS doctorName,
  10920. t1.beh_doctor_id AS behDoctorId,
  10921. t1.beh_doctor_name AS behDoctorName,
  10922. t1.director_doctor_id AS directorDoctorId,
  10923. t1.director_doctor_name AS directorDoctorName,
  10924. t1.birthday AS birthday,
  10925. t1.behospital_date AS behospitalDate,
  10926. t1.leave_hospital_date AS leaveHospitalDate,
  10927. t1.placefile_date AS placefileDate,
  10928. t1.gmt_create AS gradeTime,
  10929. t1.diagnose,
  10930. t1.ward_name AS wardName,
  10931. t2.age,
  10932. t1.file_code AS fileCode,
  10933. t1.checkStatus,
  10934. t1.mrStatus,
  10935. t1.chName,
  10936. t1.mrName,
  10937. t1.chTime,
  10938. t1.mrTime
  10939. FROM
  10940. (SELECT
  10941. be.*,
  10942. ifnull(mci.status,0) AS checkStatus,
  10943. ifnull(hm_mci.status,0) AS mrStatus,
  10944. mci.check_name as chName,
  10945. hm_mci.check_name as mrName,
  10946. mci.gmt_create as chTime,
  10947. hm_mci.gmt_create as mrTime
  10948. FROM
  10949. (
  10950. SELECT DISTINCT
  10951. a.hospital_id,
  10952. a.behospital_code,
  10953. a.bed_code,
  10954. a.file_code,
  10955. b.LEVEL,
  10956. b.grade_type,
  10957. b.score_res,
  10958. a.NAME,
  10959. a.sex,
  10960. a.beh_dept_id,
  10961. a.beh_dept_name,
  10962. a.birthday,
  10963. a.behospital_date,
  10964. a.leave_hospital_date,
  10965. a.doctor_id,
  10966. a.doctor_name,
  10967. a.beh_doctor_id,
  10968. a.beh_doctor_name,
  10969. a.director_doctor_id,
  10970. a.director_doctor_name,
  10971. a.diagnose,
  10972. a.placefile_date,
  10973. a.ward_name,
  10974. b.gmt_create
  10975. FROM
  10976. med_behospital_info a,
  10977. med_qcresult_info b,
  10978. med_qcresult_detail c,
  10979. qc_cases_entry d
  10980. WHERE
  10981. a.is_deleted = 'N'
  10982. AND b.is_deleted = 'N'
  10983. AND c.is_deleted = 'N'
  10984. AND d.is_deleted = 'N'
  10985. AND a.hospital_id = b.hospital_id
  10986. AND a.hospital_id = c.hospital_id
  10987. AND a.behospital_code = b.behospital_code
  10988. AND a.behospital_code = c.behospital_code
  10989. AND c.cases_id = d.cases_id
  10990. AND c.cases_entry_id = d.id
  10991. AND a.qc_type_id != 0
  10992. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  10993. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  10994. </if>
  10995. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  10996. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  10997. </if>
  10998. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  10999. <if test="qcResultShortPageVO.startDate != null ">
  11000. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11001. </if>
  11002. <if test="qcResultShortPageVO.endDate != null ">
  11003. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11004. </if>
  11005. </if>
  11006. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11007. <if test="qcResultShortPageVO.startDate != null ">
  11008. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11009. </if>
  11010. <if test="qcResultShortPageVO.endDate != null">
  11011. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11012. </if>
  11013. </if>
  11014. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11015. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11016. </if>
  11017. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11018. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11019. </if>
  11020. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11021. AND b.`level` = #{qcResultShortPageVO.level}
  11022. </if>
  11023. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11024. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11025. </if>
  11026. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11027. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11028. </if>
  11029. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11030. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11031. </if>
  11032. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11033. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11034. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  11035. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  11036. </if>
  11037. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11038. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11039. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  11040. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  11041. </if>
  11042. <if test="qcResultShortPageVO.casesEntryId != null ">
  11043. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11044. </if>
  11045. <if test="qcResultShortPageVO.isReject != null">
  11046. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11047. </if>
  11048. <if test="qcResultShortPageVO.ruleType != null">
  11049. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11050. </if>
  11051. )be
  11052. left join med_check_info mci
  11053. on mci.is_deleted = 'N'
  11054. and mci.check_type = 0
  11055. and be.hospital_id = mci.hospital_id
  11056. and be.behospital_code = mci.behospital_code
  11057. left join med_check_info hm_mci
  11058. on hm_mci.is_deleted = 'N'
  11059. and hm_mci.check_type = 1
  11060. and be.hospital_id = hm_mci.hospital_id
  11061. and be.behospital_code = hm_mci.behospital_code
  11062. ) t1
  11063. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11064. AND t1.behospital_code = t2.behospital_code
  11065. AND t2.is_deleted = 'N'
  11066. ) t
  11067. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11068. AND t.hospitalId = qi.hospital_id
  11069. AND t.behospitalCode = qi.behospital_code
  11070. where 1=1
  11071. <if test="qcResultShortPageVO.checkStatus != null">
  11072. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11073. </if>
  11074. <if test="qcResultShortPageVO.mrStatus != null">
  11075. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11076. </if>
  11077. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11078. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11079. </if>
  11080. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11081. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11082. </if>
  11083. <if test="qcResultShortPageVO.chTimeStart != null ">
  11084. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11085. </if>
  11086. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11087. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11088. </if>
  11089. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11090. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11091. </if>
  11092. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11093. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11094. </if>
  11095. GROUP BY
  11096. t.behDeptId,
  11097. t.behDeptName
  11098. )f2
  11099. WHERE
  11100. f1.behDeptId = f2.behDeptId
  11101. AND f1.behDeptName = f2.behDeptName
  11102. </select>
  11103. <!-- 未整改病历缺陷评分详情页导出-科室-->
  11104. <select id="unModifyExportByDept" resultMap="ExportExcelMapByDept">
  11105. SELECT
  11106. f1.behDeptId,
  11107. f1.behDeptName,
  11108. f1.wardName,
  11109. f1.medoupName,
  11110. f1.doctorName,
  11111. f1.patName,
  11112. f1.behospitalCode,
  11113. f1.hospitalId,
  11114. f1.behospitalDate,
  11115. f1.leaveHospitalDate,
  11116. f1.score,
  11117. f1.scoreBn,
  11118. f2.avgScore,
  11119. f1.msg,
  11120. f1.caseName,
  11121. f1.checkStatus,
  11122. f1.mrStatus,
  11123. f1.chName,
  11124. f1.mrName,
  11125. f1.chTime,
  11126. f1.mrTime
  11127. FROM
  11128. (SELECT
  11129. t.doctorName,
  11130. t.doctorId,
  11131. t.wardName,
  11132. t3.name as medoupName,
  11133. t.`name` AS patName,
  11134. t.behospitalCode AS behospitalCode,
  11135. t.behospitalDate AS behospitalDate,
  11136. t.leaveHospitalDate AS leaveHospitalDate,
  11137. qi.score_res AS score,
  11138. t.scoreBn,
  11139. qd.msg AS msg,
  11140. qc.NAME AS caseName,
  11141. t.behDeptId,
  11142. t.behDeptName,
  11143. t.hospitalId,
  11144. t.checkStatus,
  11145. t.mrStatus,
  11146. t.chName,
  11147. t.mrName,
  11148. t.chTime,
  11149. t.mrTime
  11150. FROM
  11151. (SELECT DISTINCT
  11152. t1.hospital_id AS hospitalId,
  11153. t1.behospital_code AS behospitalCode,
  11154. t1.bed_code AS bedCode,
  11155. t1.LEVEL AS LEVEL,
  11156. t1.grade_type AS gradeType,
  11157. t1.score_res AS scoreRes,
  11158. t1.scoreBn,
  11159. t1.NAME AS NAME,
  11160. t1.sex AS sex,
  11161. t1.beh_dept_id AS behDeptId,
  11162. t1.beh_dept_name AS behDeptName,
  11163. t1.doctor_id AS doctorId,
  11164. t1.doctor_name AS doctorName,
  11165. t1.beh_doctor_id AS behDoctorId,
  11166. t1.beh_doctor_name AS behDoctorName,
  11167. t1.director_doctor_id AS directorDoctorId,
  11168. t1.director_doctor_name AS directorDoctorName,
  11169. t1.birthday AS birthday,
  11170. t1.behospital_date AS behospitalDate,
  11171. t1.leave_hospital_date AS leaveHospitalDate,
  11172. t1.placefile_date AS placefileDate,
  11173. t1.gmt_create AS gradeTime,
  11174. t1.diagnose,
  11175. t1.ward_name AS wardName,
  11176. t2.age,
  11177. t1.file_code AS fileCode,
  11178. t1.checkStatus,
  11179. t1.mrStatus,
  11180. t1.chName,
  11181. t1.mrName,
  11182. t1.chTime,
  11183. t1.mrTime
  11184. FROM
  11185. (SELECT
  11186. be.*,
  11187. ifnull(mci.status,0) AS checkStatus,
  11188. ifnull(hm_mci.status,0) AS mrStatus,
  11189. mci.check_name as chName,
  11190. e.score_res as scoreBn,
  11191. hm_mci.check_name as mrName,
  11192. mci.gmt_create as chTime,
  11193. hm_mci.gmt_create as mrTime
  11194. FROM
  11195. (
  11196. SELECT DISTINCT
  11197. a.hospital_id,
  11198. a.behospital_code,
  11199. a.bed_code,
  11200. a.file_code,
  11201. b.LEVEL,
  11202. b.grade_type,
  11203. b.score_res,
  11204. a.NAME,
  11205. a.sex,
  11206. a.beh_dept_id,
  11207. a.beh_dept_name,
  11208. a.birthday,
  11209. a.behospital_date,
  11210. a.leave_hospital_date,
  11211. a.doctor_id,
  11212. a.doctor_name,
  11213. a.beh_doctor_id,
  11214. a.beh_doctor_name,
  11215. a.director_doctor_id,
  11216. a.director_doctor_name,
  11217. a.diagnose,
  11218. a.placefile_date,
  11219. a.ward_name,
  11220. b.gmt_create
  11221. FROM
  11222. med_behospital_info a,
  11223. med_qcresult_info b,
  11224. med_qcresult_detail c,
  11225. qc_cases_entry d,
  11226. sys_user_dept f
  11227. WHERE
  11228. a.is_deleted = 'N'
  11229. AND b.is_deleted = 'N'
  11230. AND c.is_deleted = 'N'
  11231. AND d.is_deleted = 'N'
  11232. AND f.is_deleted = 'N'
  11233. AND a.hospital_id = b.hospital_id
  11234. AND a.hospital_id = c.hospital_id
  11235. AND a.hospital_id = f.hospital_id
  11236. AND a.behospital_code = b.behospital_code
  11237. AND a.behospital_code = c.behospital_code
  11238. AND c.cases_id = d.cases_id
  11239. AND c.cases_entry_id = d.id
  11240. AND a.beh_dept_id = f.dept_id
  11241. AND a.qc_type_id != 0
  11242. <if test="qcResultShortPageVO.userId!=null">
  11243. AND f.user_id = #{qcResultShortPageVO.userId}
  11244. </if>
  11245. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11246. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11247. </if>
  11248. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11249. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11250. </if>
  11251. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11252. <if test="qcResultShortPageVO.startDate != null ">
  11253. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11254. </if>
  11255. <if test="qcResultShortPageVO.endDate != null ">
  11256. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11257. </if>
  11258. </if>
  11259. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11260. <if test="qcResultShortPageVO.startDate != null ">
  11261. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11262. </if>
  11263. <if test="qcResultShortPageVO.endDate != null">
  11264. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11265. </if>
  11266. </if>
  11267. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11268. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11269. </if>
  11270. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  11271. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  11272. </if>
  11273. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11274. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11275. </if>
  11276. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  11277. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  11278. </if>
  11279. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11280. AND b.`level` = #{qcResultShortPageVO.level}
  11281. </if>
  11282. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11283. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11284. </if>
  11285. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11286. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11287. </if>
  11288. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11289. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  11290. </if>
  11291. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11292. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  11293. </if>
  11294. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11295. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11296. </if>
  11297. <if test="qcResultShortPageVO.casesEntryId != null ">
  11298. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11299. </if>
  11300. <if test="qcResultShortPageVO.isReject != null">
  11301. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11302. </if>
  11303. <if test="qcResultShortPageVO.ruleType != null">
  11304. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11305. </if>
  11306. )be
  11307. left join med_check_info mci
  11308. on mci.is_deleted = 'N'
  11309. and mci.check_type = 0
  11310. and be.hospital_id = mci.hospital_id
  11311. and be.behospital_code = mci.behospital_code
  11312. left join med_check_info hm_mci
  11313. on hm_mci.is_deleted = 'N'
  11314. and hm_mci.check_type = 1
  11315. and be.hospital_id = hm_mci.hospital_id
  11316. and be.behospital_code = hm_mci.behospital_code
  11317. LEFT JOIN med_qcresult_cases e
  11318. on be.behospital_code = e.behospital_code
  11319. and be.hospital_id = e.hospital_id
  11320. AND e.is_deleted = 'N'
  11321. and e.cases_id = 243
  11322. ) t1
  11323. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11324. AND t1.behospital_code = t2.behospital_code
  11325. AND t2.is_deleted = 'N'
  11326. ) t
  11327. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11328. AND t.hospitalId = qi.hospital_id
  11329. AND t.behospitalCode = qi.behospital_code
  11330. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  11331. AND t.hospitalId = qd.hospital_id
  11332. AND t.behospitalCode = qd.behospital_code
  11333. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  11334. AND qd.cases_id = qc.id
  11335. LEFT JOIN qc_cases_entry qce ON qce.is_deleted = 'N'
  11336. AND qd.cases_id = qce.cases_id
  11337. AND qd.cases_entry_id = qce.id
  11338. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  11339. AND t.hospitalId = t2.hospital_id
  11340. AND t2.is_deleted = 'N'
  11341. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  11342. AND t3.is_deleted = 'N'
  11343. where 1=1
  11344. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  11345. AND t3.name like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  11346. </if>
  11347. <if test="qcResultShortPageVO.checkStatus != null">
  11348. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11349. </if>
  11350. <if test="qcResultShortPageVO.mrStatus != null">
  11351. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11352. </if>
  11353. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11354. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11355. </if>
  11356. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11357. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11358. </if>
  11359. <if test="qcResultShortPageVO.chTimeStart != null ">
  11360. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11361. </if>
  11362. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11363. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11364. </if>
  11365. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11366. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11367. </if>
  11368. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11369. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11370. </if>
  11371. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11372. AND qce.NAME = #{qcResultShortPageVO.casesEntryName}
  11373. </if>
  11374. <if test="qcResultShortPageVO.casesEntryId != null ">
  11375. AND qce.id = #{qcResultShortPageVO.casesEntryId}
  11376. </if>
  11377. )f1,
  11378. (SELECT
  11379. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  11380. t.behDeptId,
  11381. t.behDeptName,
  11382. t.doctorId,
  11383. t.doctorName
  11384. FROM
  11385. (SELECT DISTINCT
  11386. t1.hospital_id AS hospitalId,
  11387. t1.behospital_code AS behospitalCode,
  11388. t1.bed_code AS bedCode,
  11389. t1.LEVEL AS LEVEL,
  11390. t1.grade_type AS gradeType,
  11391. t1.score_res AS scoreRes,
  11392. t1.NAME AS NAME,
  11393. t1.sex AS sex,
  11394. t1.beh_dept_id AS behDeptId,
  11395. t1.beh_dept_name AS behDeptName,
  11396. t1.doctor_id AS doctorId,
  11397. t1.doctor_name AS doctorName,
  11398. t1.beh_doctor_id AS behDoctorId,
  11399. t1.beh_doctor_name AS behDoctorName,
  11400. t1.director_doctor_id AS directorDoctorId,
  11401. t1.director_doctor_name AS directorDoctorName,
  11402. t1.birthday AS birthday,
  11403. t1.behospital_date AS behospitalDate,
  11404. t1.leave_hospital_date AS leaveHospitalDate,
  11405. t1.placefile_date AS placefileDate,
  11406. t1.gmt_create AS gradeTime,
  11407. t1.diagnose,
  11408. t1.ward_name AS wardName,
  11409. t2.age,
  11410. t1.file_code AS fileCode,
  11411. t1.checkStatus,
  11412. t1.mrStatus,
  11413. t1.chName,
  11414. t1.mrName,
  11415. t1.chTime,
  11416. t1.mrTime
  11417. FROM
  11418. (SELECT
  11419. be.*,
  11420. ifnull(mci.status,0) AS checkStatus,
  11421. ifnull(hm_mci.status,0) AS mrStatus,
  11422. mci.check_name as chName,
  11423. hm_mci.check_name as mrName,
  11424. mci.gmt_create as chTime,
  11425. hm_mci.gmt_create as mrTime
  11426. FROM
  11427. (
  11428. SELECT DISTINCT
  11429. a.hospital_id,
  11430. a.behospital_code,
  11431. a.bed_code,
  11432. a.file_code,
  11433. b.LEVEL,
  11434. b.grade_type,
  11435. b.score_res,
  11436. a.NAME,
  11437. a.sex,
  11438. a.beh_dept_id,
  11439. a.beh_dept_name,
  11440. a.birthday,
  11441. a.behospital_date,
  11442. a.leave_hospital_date,
  11443. a.doctor_id,
  11444. a.doctor_name,
  11445. a.beh_doctor_id,
  11446. a.beh_doctor_name,
  11447. a.director_doctor_id,
  11448. a.director_doctor_name,
  11449. a.diagnose,
  11450. a.placefile_date,
  11451. a.ward_name,
  11452. b.gmt_create
  11453. FROM
  11454. med_behospital_info a,
  11455. med_qcresult_info b,
  11456. med_qcresult_detail c,
  11457. qc_cases_entry d,
  11458. sys_user_dept f
  11459. WHERE
  11460. a.is_deleted = 'N'
  11461. AND b.is_deleted = 'N'
  11462. AND c.is_deleted = 'N'
  11463. AND d.is_deleted = 'N'
  11464. AND f.is_deleted = 'N'
  11465. AND a.hospital_id = b.hospital_id
  11466. AND a.hospital_id = c.hospital_id
  11467. AND a.hospital_id = f.hospital_id
  11468. AND a.behospital_code = b.behospital_code
  11469. AND a.behospital_code = c.behospital_code
  11470. AND c.cases_id = d.cases_id
  11471. AND c.cases_entry_id = d.id
  11472. AND a.beh_dept_id = f.dept_id
  11473. AND a.qc_type_id != 0
  11474. <if test="qcResultShortPageVO.userId!=null">
  11475. AND f.user_id = #{qcResultShortPageVO.userId}
  11476. </if>
  11477. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  11478. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  11479. </if>
  11480. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  11481. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  11482. </if>
  11483. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  11484. <if test="qcResultShortPageVO.startDate != null ">
  11485. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  11486. </if>
  11487. <if test="qcResultShortPageVO.endDate != null ">
  11488. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  11489. </if>
  11490. </if>
  11491. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  11492. <if test="qcResultShortPageVO.startDate != null ">
  11493. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  11494. </if>
  11495. <if test="qcResultShortPageVO.endDate != null">
  11496. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  11497. </if>
  11498. </if>
  11499. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  11500. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  11501. </if>
  11502. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  11503. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  11504. </if>
  11505. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  11506. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  11507. </if>
  11508. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  11509. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  11510. </if>
  11511. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  11512. AND b.`level` = #{qcResultShortPageVO.level}
  11513. </if>
  11514. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  11515. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  11516. </if>
  11517. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  11518. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  11519. </if>
  11520. <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
  11521. AND d.NAME = #{qcResultShortPageVO.casesEntryName}
  11522. </if>
  11523. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  11524. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  11525. </if>
  11526. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  11527. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  11528. </if>
  11529. <if test="qcResultShortPageVO.casesEntryId != null ">
  11530. AND d.id = #{qcResultShortPageVO.casesEntryId}
  11531. </if>
  11532. <if test="qcResultShortPageVO.isReject != null">
  11533. AND c.is_reject = #{qcResultShortPageVO.isReject}
  11534. </if>
  11535. <if test="qcResultShortPageVO.ruleType != null">
  11536. AND d.rule_type = #{qcResultShortPageVO.ruleType}
  11537. </if>
  11538. )be
  11539. left join med_check_info mci
  11540. on mci.is_deleted = 'N'
  11541. and mci.check_type = 0
  11542. and be.hospital_id = mci.hospital_id
  11543. and be.behospital_code = mci.behospital_code
  11544. left join med_check_info hm_mci
  11545. on hm_mci.is_deleted = 'N'
  11546. and hm_mci.check_type = 1
  11547. and be.hospital_id = hm_mci.hospital_id
  11548. and be.behospital_code = hm_mci.behospital_code
  11549. ) t1
  11550. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  11551. AND t1.behospital_code = t2.behospital_code
  11552. AND t2.is_deleted = 'N'
  11553. ) t
  11554. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  11555. AND t.hospitalId = qi.hospital_id
  11556. AND t.behospitalCode = qi.behospital_code
  11557. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  11558. AND t.hospitalId = t2.hospital_id
  11559. AND t2.is_deleted = 'N'
  11560. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  11561. AND t3.is_deleted = 'N'
  11562. where 1=1
  11563. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  11564. AND t3.name like concat('%', #{qcResultShortPageVO.medoupName}, '%')
  11565. </if>
  11566. <if test="qcResultShortPageVO.checkStatus != null">
  11567. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  11568. </if>
  11569. <if test="qcResultShortPageVO.mrStatus != null">
  11570. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  11571. </if>
  11572. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  11573. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  11574. </if>
  11575. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  11576. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  11577. </if>
  11578. <if test="qcResultShortPageVO.chTimeStart != null ">
  11579. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  11580. </if>
  11581. <if test="qcResultShortPageVO.chTimeEnd != null ">
  11582. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  11583. </if>
  11584. <if test="qcResultShortPageVO.mrTimeStart != null ">
  11585. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  11586. </if>
  11587. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  11588. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  11589. </if>
  11590. GROUP BY
  11591. t.doctorId,
  11592. t.doctorName
  11593. )f2
  11594. WHERE
  11595. f1.doctorId = f2.doctorId
  11596. AND f1.doctorName = f2.doctorName
  11597. </select>
  11598. <!-- 31天再入院详情页-->
  11599. <select id="reHos31DaysPage" resultType="com.diagbot.dto.ReBeHosMergeDTO">
  11600. SELECT
  11601. t.fileCode,
  11602. t.diagnose,
  11603. t.diagnoseName,
  11604. t.NAME,
  11605. t.sex,
  11606. t.hospitalId,
  11607. t.behDeptId,
  11608. t.behDeptName,
  11609. t.behospitalCode,
  11610. t.behospitalDate,
  11611. t.lastDiagnose,
  11612. t.lastDiagnoseName,
  11613. t.leaveHospitalDate,
  11614. t.lastBehDeptId,
  11615. t.lastBehDeptName,
  11616. t.lastBehospitalCode,
  11617. t.lastBehospitalDate,
  11618. t.lastLeaveHospitalDate,
  11619. t.diffDays,
  11620. mqi.score_res AS scoreRes,
  11621. mqi.LEVEL AS LEVEL,
  11622. mqi_last.score_res AS lastScoreRes,
  11623. mqi_last.LEVEL AS lastLevel,
  11624. mhp.total_fee AS totleFee,
  11625. mhp.behospital_day_num AS behospitalDayNum,
  11626. mhp.again_behospital_plan AS againBehospitalPlan,
  11627. IF(mhp.age is null, null,CONCAT( ifnull(mhp.age,'') ,ifnull(mhp.age_unit,'') ))as age,
  11628. mhp_last.again_behospital_plan AS lastAgainBehospitalPlan,
  11629. IF(mhp_last.age is null, null,CONCAT( ifnull(mhp_last.age,'') ,ifnull(mhp_last.age_unit,'') ))as lastAge,
  11630. mhp_last.total_fee AS lastTotleFee,
  11631. mhp_last.behospital_day_num AS lastBehospitalDayNum
  11632. FROM
  11633. (
  11634. SELECT
  11635. be.fileCode,
  11636. be.diagnose,
  11637. be.diagnoseName,
  11638. be.NAME,
  11639. be.sex,
  11640. be.hospitalId,
  11641. be.behDeptId,
  11642. be.behDeptName,
  11643. be.behospitalCode,
  11644. be.behospitalDate,
  11645. be.leaveHospitalDate,
  11646. be.lastDiagnose,
  11647. be.lastDiagnoseName,
  11648. be.lastBehDeptId,
  11649. be.lastBehDeptName,
  11650. be.lastBehospitalCode,
  11651. be.lastBehospitalDate,
  11652. be.lastLeaveHospitalDate,
  11653. be.diffDays
  11654. FROM
  11655. (
  11656. SELECT
  11657. r1.file_code AS fileCode,
  11658. r1.diagnose,
  11659. r1.diagnose_name AS diagnoseName,
  11660. r1.NAME,
  11661. r1.sex,
  11662. r1.hospital_id AS hospitalId,
  11663. r1.beh_dept_id AS behDeptId,
  11664. r1.beh_dept_name AS behDeptName,
  11665. r1.behospital_code AS behospitalCode,
  11666. r1.behospital_date AS behospitalDate,
  11667. r1.leave_hospital_date AS leaveHospitalDate,
  11668. r2.diagnose AS lastDiagnose,
  11669. r2.diagnose_name AS lastDiagnoseName,
  11670. r2.beh_dept_id AS lastBehDeptId,
  11671. r2.beh_dept_name AS lastBehDeptName,
  11672. r2.behospital_code AS lastBehospitalCode,
  11673. r2.behospital_date AS lastBehospitalDate,
  11674. r2.leave_hospital_date AS lastLeaveHospitalDate,
  11675. TIMESTAMPDIFF( DAY, DATE( r2.leave_hospital_date ), DATE( r1.behospital_date ) ) AS diffDays
  11676. FROM
  11677. (
  11678. SELECT
  11679. ( @rownum := @rownum + 1 ) AS rownum,
  11680. t1.file_code,
  11681. t1.behospital_code,
  11682. t1.diagnose,
  11683. t1.diagnose_name,
  11684. t1.NAME,
  11685. t1.sex,
  11686. t1.hospital_id,
  11687. t1.beh_dept_id,
  11688. t1.beh_dept_name,
  11689. t1.behospital_date,
  11690. t1.leave_hospital_date
  11691. FROM(
  11692. select
  11693. tt3.file_code,
  11694. tt3.behospital_code,
  11695. tt3.diagnose,
  11696. tt3.NAME,
  11697. tt3.sex,
  11698. tt3.hospital_id,
  11699. tt3.beh_dept_id,
  11700. tt3.beh_dept_name,
  11701. tt3.behospital_date,
  11702. tt3.leave_hospital_date,
  11703. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  11704. FROM(
  11705. SELECT
  11706. tt2.file_code,
  11707. tt2.diagnose,
  11708. tt2.NAME,
  11709. tt2.sex,
  11710. tt2.hospital_id,
  11711. tt2.beh_dept_id,
  11712. tt2.beh_dept_name,
  11713. tt2.behospital_code,
  11714. tt2.behospital_date,
  11715. tt2.leave_hospital_date
  11716. FROM
  11717. (
  11718. SELECT
  11719. a.file_code
  11720. FROM
  11721. med_behospital_info a
  11722. WHERE
  11723. a.is_deleted = 'N'
  11724. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  11725. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  11726. </if>
  11727. AND a.qc_type_id != 0
  11728. AND IFNULL( a.diagnose, '' )!= ''
  11729. AND IFNULL( a.file_code, '' )!= ''
  11730. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  11731. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  11732. </if>
  11733. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  11734. <if test="reBeHosPageVO.startDate != null ">
  11735. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  11736. </if>
  11737. <if test="reBeHosPageVO.endDate != null ">
  11738. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  11739. </if>
  11740. </if>
  11741. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  11742. <if test="reBeHosPageVO.startDate != null ">
  11743. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  11744. </if>
  11745. <if test="reBeHosPageVO.endDate != null">
  11746. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  11747. </if>
  11748. </if>
  11749. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  11750. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  11751. </if>
  11752. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  11753. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  11754. </if>
  11755. GROUP BY
  11756. a.file_code
  11757. HAVING
  11758. count(*)> 1
  11759. ) tt1,
  11760. med_behospital_info tt2
  11761. WHERE
  11762. tt2.is_deleted = 'N'
  11763. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  11764. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  11765. </if>
  11766. AND tt2.qc_type_id != 0
  11767. AND tt1.file_code = tt2.file_code
  11768. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  11769. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  11770. </if>
  11771. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  11772. <if test="reBeHosPageVO.startDate != null ">
  11773. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  11774. </if>
  11775. <if test="reBeHosPageVO.endDate != null ">
  11776. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  11777. </if>
  11778. </if>
  11779. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  11780. <if test="reBeHosPageVO.startDate != null ">
  11781. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  11782. </if>
  11783. <if test="reBeHosPageVO.endDate != null">
  11784. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  11785. </if>
  11786. </if>
  11787. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  11788. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  11789. </if>
  11790. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  11791. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  11792. </if>
  11793. ORDER BY
  11794. tt1.file_code,
  11795. tt2.behospital_date DESC)tt3
  11796. left join med_home_page tt4 on tt4.is_deleted = 'N'
  11797. AND tt3.hospital_id = tt4.hospital_id
  11798. AND tt3.behospital_code = tt4.behospital_code
  11799. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  11800. AND tt4.hospital_id = tt5.hospital_id
  11801. AND tt4.home_page_id = tt5.home_page_id
  11802. GROUP by tt3.behospital_code
  11803. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  11804. ) t1,
  11805. ( SELECT @rownum := 0 ) r
  11806. ) r1
  11807. LEFT JOIN (
  11808. SELECT
  11809. ( @INDEX := @INDEX + 1 ) AS rownum,
  11810. t1.file_code,
  11811. t1.behospital_code,
  11812. t1.diagnose,
  11813. t1.diagnose_name,
  11814. t1.NAME,
  11815. t1.sex,
  11816. t1.hospital_id,
  11817. t1.beh_dept_id,
  11818. t1.beh_dept_name,
  11819. t1.behospital_date,
  11820. t1.leave_hospital_date
  11821. FROM(
  11822. select
  11823. tt3.file_code,
  11824. tt3.behospital_code,
  11825. tt3.diagnose,
  11826. tt3.NAME,
  11827. tt3.sex,
  11828. tt3.hospital_id,
  11829. tt3.beh_dept_id,
  11830. tt3.beh_dept_name,
  11831. tt3.behospital_date,
  11832. tt3.leave_hospital_date,
  11833. GROUP_CONCAT(case when tt5.diagnose_name is not null then tt5.diagnose_name else '' end) as diagnose_name
  11834. FROM(
  11835. SELECT
  11836. tt2.file_code,
  11837. tt2.diagnose,
  11838. tt2.NAME,
  11839. tt2.sex,
  11840. tt2.hospital_id,
  11841. tt2.beh_dept_id,
  11842. tt2.beh_dept_name,
  11843. tt2.behospital_code,
  11844. tt2.behospital_date,
  11845. tt2.leave_hospital_date
  11846. FROM
  11847. (
  11848. SELECT
  11849. a.file_code
  11850. FROM
  11851. med_behospital_info a
  11852. WHERE
  11853. a.is_deleted = 'N'
  11854. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  11855. and a.is_placefile = #{reBeHosPageVO.isPlacefile}
  11856. </if>
  11857. AND a.qc_type_id != 0
  11858. AND IFNULL( a.diagnose, '' )!= ''
  11859. AND IFNULL( a.file_code, '' )!= ''
  11860. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  11861. AND a.hospital_id = #{reBeHosPageVO.hospitalId}
  11862. </if>
  11863. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  11864. <if test="reBeHosPageVO.startDate != null ">
  11865. <![CDATA[ AND a.behospital_date >= #{reBeHosPageVO.startDate}]]>
  11866. </if>
  11867. <if test="reBeHosPageVO.endDate != null ">
  11868. <![CDATA[ AND a.behospital_date <= #{reBeHosPageVO.endDate}]]>
  11869. </if>
  11870. </if>
  11871. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  11872. <if test="reBeHosPageVO.startDate != null ">
  11873. <![CDATA[ AND a.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  11874. </if>
  11875. <if test="reBeHosPageVO.endDate != null">
  11876. <![CDATA[ AND a.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  11877. </if>
  11878. </if>
  11879. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  11880. AND a.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  11881. </if>
  11882. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  11883. AND a.name like concat('%', #{reBeHosPageVO.name},'%')
  11884. </if>
  11885. GROUP BY
  11886. a.file_code
  11887. HAVING
  11888. count(*)> 1
  11889. ) tt1,
  11890. med_behospital_info tt2
  11891. WHERE
  11892. tt2.is_deleted = 'N'
  11893. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile != ''">
  11894. and tt2.is_placefile = #{reBeHosPageVO.isPlacefile}
  11895. </if>
  11896. AND tt2.qc_type_id != 0
  11897. AND tt1.file_code = tt2.file_code
  11898. <if test="reBeHosPageVO.hospitalId != null and reBeHosPageVO.hospitalId != ''">
  11899. AND tt2.hospital_id = #{reBeHosPageVO.hospitalId}
  11900. </if>
  11901. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 0">
  11902. <if test="reBeHosPageVO.startDate != null ">
  11903. <![CDATA[ AND tt2.behospital_date >= #{reBeHosPageVO.startDate}]]>
  11904. </if>
  11905. <if test="reBeHosPageVO.endDate != null ">
  11906. <![CDATA[ AND tt2.behospital_date <= #{reBeHosPageVO.endDate}]]>
  11907. </if>
  11908. </if>
  11909. <if test="reBeHosPageVO.isPlacefile != null and reBeHosPageVO.isPlacefile == 1">
  11910. <if test="reBeHosPageVO.startDate != null ">
  11911. <![CDATA[ AND tt2.leave_hospital_date >= #{reBeHosPageVO.startDate}]]>
  11912. </if>
  11913. <if test="reBeHosPageVO.endDate != null">
  11914. <![CDATA[ AND tt2.leave_hospital_date <= #{reBeHosPageVO.endDate}]]>
  11915. </if>
  11916. </if>
  11917. <if test="reBeHosPageVO.fileCode != null and reBeHosPageVO.fileCode != ''">
  11918. AND tt2.file_code like concat('%', #{reBeHosPageVO.fileCode},'%')
  11919. </if>
  11920. <if test="reBeHosPageVO.name != null and reBeHosPageVO.name != ''">
  11921. AND tt2.name like concat('%', #{reBeHosPageVO.name},'%')
  11922. </if>
  11923. ORDER BY
  11924. tt1.file_code,
  11925. tt2.behospital_date DESC)tt3
  11926. left join med_home_page tt4 on tt4.is_deleted = 'N'
  11927. AND tt3.hospital_id = tt4.hospital_id
  11928. AND tt3.behospital_code = tt4.behospital_code
  11929. LEFT JOIN med_home_diagnose_info tt5 on tt5.is_deleted = 'N'
  11930. AND tt4.hospital_id = tt5.hospital_id
  11931. AND tt4.home_page_id = tt5.home_page_id
  11932. GROUP by tt3.behospital_code
  11933. ORDER BY tt3.file_code,tt3.leave_hospital_date DESC
  11934. ) t1,
  11935. ( SELECT @INDEX := 0 ) r
  11936. ) r2 ON r1.file_code = r2.file_code
  11937. AND r1.rownum = r2.rownum - 1
  11938. ) be
  11939. WHERE
  11940. be.diffDays IS NOT NULL
  11941. AND be.diffDays BETWEEN 0
  11942. AND 31
  11943. ) t
  11944. LEFT JOIN med_qcresult_info mqi ON mqi.is_deleted = 'N'
  11945. AND t.hospitalId = mqi.hospital_id
  11946. AND t.behospitalCode = mqi.behospital_code
  11947. LEFT JOIN med_qcresult_info mqi_last ON mqi_last.is_deleted = 'N'
  11948. AND t.hospitalId = mqi_last.hospital_id
  11949. AND t.lastBehospitalCode = mqi_last.behospital_code
  11950. LEFT JOIN med_home_page mhp ON mhp.is_deleted = 'N'
  11951. AND t.hospitalId = mhp.hospital_id
  11952. AND t.behospitalCode = mhp.behospital_code
  11953. LEFT JOIN med_home_page mhp_last ON mhp_last.is_deleted = 'N'
  11954. AND t.hospitalId = mhp_last.hospital_id
  11955. AND t.lastBehospitalCode = mhp_last.behospital_code
  11956. </select>
  11957. <!-- 单条条目缺陷统计-->
  11958. <select id="casesEntryStatisticsById" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
  11959. SELECT
  11960. a.beh_dept_id AS id,
  11961. a.beh_dept_name AS NAME,
  11962. count(*) AS num
  11963. FROM
  11964. med_behospital_info a,
  11965. med_qcresult_detail b
  11966. WHERE
  11967. a.is_deleted = 'N'
  11968. AND b.is_deleted = 'N'
  11969. AND a.hospital_id = b.hospital_id
  11970. AND a.behospital_code = b.behospital_code
  11971. AND a.qc_type_id != 0
  11972. and b.cases_entry_id=2658
  11973. <if test="isPlacefile != null and isPlacefile != ''">
  11974. and a.is_placefile = #{isPlacefile}
  11975. </if>
  11976. <if test="hospitalId != null and hospitalId != ''">
  11977. AND a.hospital_id = #{hospitalId}
  11978. </if>
  11979. <if test="isPlacefile != null and isPlacefile == 0">
  11980. <if test="startDate != null and startDate != ''">
  11981. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  11982. </if>
  11983. <if test="endDate != null and endDate != ''">
  11984. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  11985. </if>
  11986. </if>
  11987. <if test="isPlacefile != null and isPlacefile == 1">
  11988. <if test="startDate != null and startDate != ''">
  11989. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  11990. </if>
  11991. <if test="endDate != null and endDate != ''">
  11992. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  11993. </if>
  11994. </if>
  11995. GROUP BY
  11996. a.beh_dept_id,
  11997. a.beh_dept_name
  11998. </select>
  11999. <!-- 单条条目缺陷统计-->
  12000. <select id="casesEntryStatisticsByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.AdmissionCountDTO">
  12001. SELECT
  12002. a.beh_dept_id AS deptId,
  12003. a.beh_dept_name AS deptName,
  12004. a.doctor_id as doctorId,
  12005. a.doctor_name as doctorName,
  12006. count(*) AS num
  12007. FROM
  12008. med_behospital_info a,
  12009. med_qcresult_detail b,
  12010. sys_user_dept c
  12011. WHERE
  12012. a.is_deleted = 'N'
  12013. AND b.is_deleted = 'N'
  12014. AND c.is_deleted = 'N'
  12015. AND a.hospital_id = b.hospital_id
  12016. AND a.hospital_id = c.hospital_id
  12017. AND a.behospital_code = b.behospital_code
  12018. AND a.beh_dept_id = c.dept_id
  12019. AND a.qc_type_id != 0
  12020. and b.cases_entry_id=2658
  12021. <if test="isPlacefile != null and isPlacefile != ''">
  12022. and a.is_placefile = #{isPlacefile}
  12023. </if>
  12024. <if test="hospitalId != null and hospitalId != ''">
  12025. AND a.hospital_id = #{hospitalId}
  12026. </if>
  12027. <if test="userId!=null">
  12028. AND c.user_id = #{userId}
  12029. </if>
  12030. <if test="isPlacefile != null and isPlacefile == 0">
  12031. <if test="startDate != null and startDate != ''">
  12032. <![CDATA[ AND a.behospital_date >= #{startDate}]]>
  12033. </if>
  12034. <if test="endDate != null and endDate != ''">
  12035. <![CDATA[ AND a.behospital_date <= #{endDate}]]>
  12036. </if>
  12037. </if>
  12038. <if test="isPlacefile != null and isPlacefile == 1">
  12039. <if test="startDate != null and startDate != ''">
  12040. <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
  12041. </if>
  12042. <if test="endDate != null and endDate != ''">
  12043. <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
  12044. </if>
  12045. </if>
  12046. GROUP BY
  12047. a.beh_dept_id,
  12048. a.beh_dept_name,
  12049. a.doctor_id,
  12050. a.doctor_name
  12051. </select>
  12052. <!-- 病案首页改善率质控评分页(内页)-->
  12053. <select id="hmImproveMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12054. SELECT
  12055. t.*
  12056. FROM
  12057. (
  12058. SELECT DISTINCT
  12059. t1.hospital_id AS hospitalId,
  12060. t1.behospital_code AS behospitalCode,
  12061. t1.bed_code AS bedCode,
  12062. t1.LEVEL AS LEVEL,
  12063. t1.grade_type AS gradeType,
  12064. t1.score_res AS scoreRes,
  12065. t1.scoreBn,
  12066. t1.NAME AS NAME,
  12067. t1.sex AS sex,
  12068. t1.beh_dept_id AS behDeptId,
  12069. t1.beh_dept_name AS behDeptName,
  12070. t1.doctor_id AS doctorId,
  12071. t1.doctor_name AS doctorName,
  12072. t1.beh_doctor_id AS behDoctorId,
  12073. t1.beh_doctor_name AS behDoctorName,
  12074. t1.director_doctor_id AS directorDoctorId,
  12075. t1.director_doctor_name AS directorDoctorName,
  12076. t1.birthday AS birthday,
  12077. t1.behospital_date AS behospitalDate,
  12078. t1.leave_hospital_date AS leaveHospitalDate,
  12079. t1.placefile_date AS placefileDate,
  12080. t1.gmt_create AS gradeTime,
  12081. t1.diagnose,
  12082. t1.ward_name AS wardName,
  12083. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12084. t1.file_code AS fileCode,
  12085. t1.checkStatus,
  12086. t1.chName,
  12087. t1.chTime
  12088. FROM
  12089. (
  12090. SELECT
  12091. be.*,
  12092. ifnull( mci.STATUS, 0 ) AS checkStatus,
  12093. mci.check_name AS chName,
  12094. mci.gmt_create AS chTime
  12095. FROM
  12096. (
  12097. SELECT DISTINCT
  12098. a.hospital_id,
  12099. a.behospital_code,
  12100. a.bed_code,
  12101. a.file_code,
  12102. c.LEVEL,
  12103. c.grade_type,
  12104. c.score_res,
  12105. a.NAME,
  12106. a.sex,
  12107. a.beh_dept_id,
  12108. a.beh_dept_name,
  12109. a.birthday,
  12110. a.behospital_date,
  12111. a.leave_hospital_date,
  12112. a.doctor_id,
  12113. a.doctor_name,
  12114. a.beh_doctor_id,
  12115. a.beh_doctor_name,
  12116. a.director_doctor_id,
  12117. a.director_doctor_name,
  12118. a.diagnose,
  12119. a.placefile_date,
  12120. a.ward_name,
  12121. c.gmt_create,
  12122. d.score_res as scoreBn
  12123. FROM
  12124. med_behospital_info a,
  12125. med_home_page b,
  12126. med_qcresult_info c,
  12127. med_qcresult_cases d,
  12128. (
  12129. SELECT
  12130. m4.*
  12131. FROM
  12132. med_behospital_info m1,
  12133. med_home_page m2,
  12134. med_qcresult_info m3,
  12135. med_qcresult_cases m4
  12136. WHERE
  12137. m1.is_deleted = 'N'
  12138. AND m2.is_deleted = 'N'
  12139. AND m3.is_deleted = 'Y'
  12140. AND m4.is_deleted = 'Y'
  12141. AND m1.hospital_id = m2.hospital_id
  12142. AND m1.hospital_id = m3.hospital_id
  12143. AND m1.hospital_id = m4.hospital_id
  12144. AND m1.behospital_code = m2.behospital_code
  12145. AND m1.behospital_code = m3.behospital_code
  12146. AND m1.behospital_code = m4.behospital_code
  12147. AND m3.gmt_create = m4.gmt_create
  12148. AND m3.have_home_page = 1
  12149. AND m4.cases_id = 243
  12150. AND m1.qc_type_id != 0
  12151. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12152. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12153. </if>
  12154. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12155. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  12156. </if>
  12157. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12158. <if test="qcResultShortPageVO.startDate != null ">
  12159. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12160. </if>
  12161. <if test="qcResultShortPageVO.endDate != null ">
  12162. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12163. </if>
  12164. </if>
  12165. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12166. <if test="qcResultShortPageVO.startDate != null">
  12167. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12168. </if>
  12169. <if test="qcResultShortPageVO.endDate != null ">
  12170. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12171. </if>
  12172. </if>
  12173. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12174. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  12175. </if>
  12176. GROUP BY
  12177. m1.behospital_code
  12178. ORDER BY
  12179. m1.behospital_code,
  12180. m4.gmt_create
  12181. ) e
  12182. WHERE
  12183. a.is_deleted = 'N'
  12184. AND b.is_deleted = 'N'
  12185. AND c.is_deleted = 'N'
  12186. AND d.is_deleted = 'N'
  12187. AND a.hospital_id = b.hospital_id
  12188. AND a.hospital_id = c.hospital_id
  12189. AND a.hospital_id = d.hospital_id
  12190. AND a.hospital_id = e.hospital_id
  12191. AND a.behospital_code = b.behospital_code
  12192. AND a.behospital_code = c.behospital_code
  12193. AND a.behospital_code = d.behospital_code
  12194. AND a.behospital_code = e.behospital_code
  12195. AND d.cases_id = 243
  12196. AND d.score_res > e.score_res
  12197. AND a.qc_type_id != 0
  12198. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12199. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12200. </if>
  12201. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12202. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12203. </if>
  12204. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12205. <if test="qcResultShortPageVO.startDate != null ">
  12206. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12207. </if>
  12208. <if test="qcResultShortPageVO.endDate != null ">
  12209. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12210. </if>
  12211. </if>
  12212. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12213. <if test="qcResultShortPageVO.startDate != null ">
  12214. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12215. </if>
  12216. <if test="qcResultShortPageVO.endDate != null">
  12217. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12218. </if>
  12219. </if>
  12220. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12221. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12222. </if>
  12223. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12224. AND c.`level` = #{qcResultShortPageVO.level}
  12225. </if>
  12226. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12227. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12228. </if>
  12229. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12230. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12231. </if>
  12232. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12233. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12234. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12235. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12236. </if>
  12237. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12238. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12239. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12240. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12241. </if>
  12242. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  12243. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  12244. </if>
  12245. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  12246. AND d.score_res = 20
  12247. </if>
  12248. ) be
  12249. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  12250. AND mci.check_type in(0,2)
  12251. AND be.hospital_id = mci.hospital_id
  12252. AND be.behospital_code = mci.behospital_code
  12253. ) t1
  12254. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12255. AND t1.behospital_code = t2.behospital_code
  12256. AND t2.is_deleted = 'N'
  12257. ) t
  12258. WHERE
  12259. 1 = 1
  12260. <if test="qcResultShortPageVO.checkStatus != null">
  12261. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12262. </if>
  12263. <if test="qcResultShortPageVO.mrStatus != null">
  12264. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12265. </if>
  12266. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12267. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12268. </if>
  12269. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12270. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12271. </if>
  12272. <if test="qcResultShortPageVO.chTimeStart != null ">
  12273. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12274. </if>
  12275. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12276. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12277. </if>
  12278. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12279. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12280. </if>
  12281. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12282. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12283. </if>
  12284. </select>
  12285. <!-- 病案首页改善率质控评分页(内页)-科室-->
  12286. <select id="hmImproveMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  12287. SELECT
  12288. t.*
  12289. FROM
  12290. (
  12291. SELECT DISTINCT
  12292. t1.hospital_id AS hospitalId,
  12293. t1.behospital_code AS behospitalCode,
  12294. t1.bed_code AS bedCode,
  12295. t1.LEVEL AS LEVEL,
  12296. t1.grade_type AS gradeType,
  12297. t1.score_res AS scoreRes,
  12298. t1.NAME AS NAME,
  12299. t1.scoreBn,
  12300. t1.medoupName,
  12301. t1.sex AS sex,
  12302. t1.beh_dept_id AS behDeptId,
  12303. t1.beh_dept_name AS behDeptName,
  12304. t1.doctor_id AS doctorId,
  12305. t1.doctor_name AS doctorName,
  12306. t1.beh_doctor_id AS behDoctorId,
  12307. t1.beh_doctor_name AS behDoctorName,
  12308. t1.director_doctor_id AS directorDoctorId,
  12309. t1.director_doctor_name AS directorDoctorName,
  12310. t1.birthday AS birthday,
  12311. t1.behospital_date AS behospitalDate,
  12312. t1.leave_hospital_date AS leaveHospitalDate,
  12313. t1.placefile_date AS placefileDate,
  12314. t1.gmt_create AS gradeTime,
  12315. t1.diagnose,
  12316. t1.ward_name AS wardName,
  12317. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12318. t1.file_code AS fileCode,
  12319. t1.checkStatus,
  12320. t1.mrStatus,
  12321. t1.chName,
  12322. t1.mrName,
  12323. t1.chTime,
  12324. t1.mrTime
  12325. FROM
  12326. (
  12327. SELECT
  12328. be.*,
  12329. t3.name as medoupName,
  12330. ifnull( mci.STATUS, 0 ) AS checkStatus,
  12331. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  12332. mci.check_name AS chName,
  12333. hm_mci.check_name AS mrName,
  12334. e.score_res as scoreBn,
  12335. mci.gmt_create AS chTime,
  12336. hm_mci.gmt_create AS mrTime
  12337. FROM
  12338. (
  12339. SELECT DISTINCT
  12340. a.hospital_id,
  12341. a.behospital_code,
  12342. a.bed_code,
  12343. a.file_code,
  12344. c.LEVEL,
  12345. c.grade_type,
  12346. c.score_res,
  12347. a.NAME,
  12348. a.sex,
  12349. a.beh_dept_id,
  12350. a.beh_dept_name,
  12351. a.birthday,
  12352. a.behospital_date,
  12353. a.leave_hospital_date,
  12354. a.doctor_id,
  12355. a.doctor_name,
  12356. a.beh_doctor_id,
  12357. a.beh_doctor_name,
  12358. a.director_doctor_id,
  12359. a.director_doctor_name,
  12360. a.diagnose,
  12361. a.placefile_date,
  12362. a.ward_name,
  12363. c.gmt_create
  12364. FROM
  12365. med_behospital_info a,
  12366. med_home_page b,
  12367. med_qcresult_info c,
  12368. med_qcresult_cases d,
  12369. sys_user_dept f,
  12370. (
  12371. SELECT
  12372. m4.*
  12373. FROM
  12374. med_behospital_info m1,
  12375. med_home_page m2,
  12376. med_qcresult_info m3,
  12377. med_qcresult_cases m4
  12378. WHERE
  12379. m1.is_deleted = 'N'
  12380. AND m2.is_deleted = 'N'
  12381. AND m3.is_deleted = 'Y'
  12382. AND m4.is_deleted = 'Y'
  12383. AND m1.hospital_id = m2.hospital_id
  12384. AND m1.hospital_id = m3.hospital_id
  12385. AND m1.hospital_id = m4.hospital_id
  12386. AND m1.behospital_code = m2.behospital_code
  12387. AND m1.behospital_code = m3.behospital_code
  12388. AND m1.behospital_code = m4.behospital_code
  12389. AND m3.gmt_create = m4.gmt_create
  12390. AND m3.have_home_page = 1
  12391. AND m4.cases_id = 243
  12392. AND m1.qc_type_id != 0
  12393. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12394. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12395. </if>
  12396. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  12397. AND m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  12398. </if>
  12399. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12400. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  12401. </if>
  12402. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12403. AND m1.doctor_name = #{qcResultShortPageVO.doctorName}
  12404. </if>
  12405. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12406. <if test="qcResultShortPageVO.startDate != null ">
  12407. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12408. </if>
  12409. <if test="qcResultShortPageVO.endDate != null ">
  12410. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12411. </if>
  12412. </if>
  12413. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12414. <if test="qcResultShortPageVO.startDate != null">
  12415. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12416. </if>
  12417. <if test="qcResultShortPageVO.endDate != null ">
  12418. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12419. </if>
  12420. </if>
  12421. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12422. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  12423. </if>
  12424. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  12425. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  12426. </if>
  12427. GROUP BY
  12428. m1.behospital_code
  12429. ORDER BY
  12430. m1.behospital_code,
  12431. m4.gmt_create
  12432. ) e
  12433. WHERE
  12434. a.is_deleted = 'N'
  12435. AND b.is_deleted = 'N'
  12436. AND c.is_deleted = 'N'
  12437. AND d.is_deleted = 'N'
  12438. AND f.is_deleted = 'N'
  12439. AND a.hospital_id = b.hospital_id
  12440. AND a.hospital_id = c.hospital_id
  12441. AND a.hospital_id = d.hospital_id
  12442. AND a.hospital_id = f.hospital_id
  12443. AND a.hospital_id = e.hospital_id
  12444. AND a.behospital_code = b.behospital_code
  12445. AND a.behospital_code = c.behospital_code
  12446. AND a.behospital_code = d.behospital_code
  12447. AND a.beh_dept_id = f.dept_id
  12448. AND a.behospital_code = e.behospital_code
  12449. AND d.cases_id = 243
  12450. AND d.score_res > e.score_res
  12451. AND a.qc_type_id != 0
  12452. <if test="qcResultShortPageVO.userId!=null">
  12453. AND f.user_id = #{qcResultShortPageVO.userId}
  12454. </if>
  12455. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12456. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12457. </if>
  12458. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12459. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12460. </if>
  12461. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  12462. AND a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  12463. </if>
  12464. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12465. <if test="qcResultShortPageVO.startDate != null ">
  12466. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12467. </if>
  12468. <if test="qcResultShortPageVO.endDate != null ">
  12469. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12470. </if>
  12471. </if>
  12472. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12473. <if test="qcResultShortPageVO.startDate != null ">
  12474. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12475. </if>
  12476. <if test="qcResultShortPageVO.endDate != null">
  12477. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12478. </if>
  12479. </if>
  12480. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12481. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12482. </if>
  12483. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  12484. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  12485. </if>
  12486. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12487. AND c.`level` = #{qcResultShortPageVO.level}
  12488. </if>
  12489. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12490. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12491. </if>
  12492. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12493. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12494. </if>
  12495. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12496. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  12497. </if>
  12498. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12499. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  12500. </if>
  12501. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  12502. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  12503. </if>
  12504. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  12505. AND d.score_res = 20
  12506. </if>
  12507. ) be
  12508. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  12509. AND mci.check_type = 0
  12510. AND be.hospital_id = mci.hospital_id
  12511. AND be.behospital_code = mci.behospital_code
  12512. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  12513. AND hm_mci.check_type = 1
  12514. AND be.hospital_id = hm_mci.hospital_id
  12515. AND be.behospital_code = hm_mci.behospital_code
  12516. LEFT JOIN med_qcresult_cases e
  12517. on be.behospital_code = e.behospital_code
  12518. and be.hospital_id = e.hospital_id
  12519. AND e.is_deleted = 'N'
  12520. and e.cases_id = 243
  12521. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  12522. and be.hospital_id = t2.hospital_id
  12523. AND t2.is_deleted = 'N'
  12524. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  12525. AND t3.is_deleted = 'N'
  12526. ) t1
  12527. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12528. AND t1.behospital_code = t2.behospital_code
  12529. AND t2.is_deleted = 'N'
  12530. ) t
  12531. WHERE
  12532. 1 = 1
  12533. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  12534. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  12535. </if>
  12536. <if test="qcResultShortPageVO.checkStatus != null">
  12537. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12538. </if>
  12539. <if test="qcResultShortPageVO.mrStatus != null">
  12540. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12541. </if>
  12542. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12543. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12544. </if>
  12545. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12546. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12547. </if>
  12548. <if test="qcResultShortPageVO.chTimeStart != null ">
  12549. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12550. </if>
  12551. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12552. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12553. </if>
  12554. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12555. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12556. </if>
  12557. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12558. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12559. </if>
  12560. </select>
  12561. <!-- 质控核查质控评分页(内页)-->
  12562. <select id="qcCheckMRPage" resultType="com.diagbot.dto.QcResultShortDTO">
  12563. SELECT
  12564. t.*
  12565. FROM
  12566. (
  12567. SELECT DISTINCT
  12568. t1.hospital_id AS hospitalId,
  12569. t1.behospital_code AS behospitalCode,
  12570. t1.bed_code AS bedCode,
  12571. t1.LEVEL AS LEVEL,
  12572. t1.grade_type AS gradeType,
  12573. t1.score_res AS scoreRes,
  12574. t1.scoreBn,
  12575. t1.NAME AS NAME,
  12576. t1.sex AS sex,
  12577. t1.beh_dept_id AS behDeptId,
  12578. t1.beh_dept_name AS behDeptName,
  12579. t1.doctor_id AS doctorId,
  12580. t1.doctor_name AS doctorName,
  12581. t1.beh_doctor_id AS behDoctorId,
  12582. t1.beh_doctor_name AS behDoctorName,
  12583. t1.director_doctor_id AS directorDoctorId,
  12584. t1.director_doctor_name AS directorDoctorName,
  12585. t1.birthday AS birthday,
  12586. t1.behospital_date AS behospitalDate,
  12587. t1.leave_hospital_date AS leaveHospitalDate,
  12588. t1.placefile_date AS placefileDate,
  12589. t1.gmt_create AS gradeTime,
  12590. t1.diagnose,
  12591. t1.ward_name AS wardName,
  12592. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12593. t1.file_code AS fileCode,
  12594. t1.checkStatus,
  12595. t1.chName,
  12596. t1.chTime
  12597. FROM
  12598. (
  12599. SELECT
  12600. be.*,
  12601. ifnull( mci.STATUS, 0 ) AS checkStatus,
  12602. mci.check_name AS chName,
  12603. e.score_res as scoreBn,
  12604. mci.gmt_create AS chTime
  12605. FROM
  12606. (
  12607. SELECT DISTINCT
  12608. a.hospital_id,
  12609. a.behospital_code,
  12610. a.bed_code,
  12611. a.file_code,
  12612. b.LEVEL,
  12613. b.grade_type,
  12614. b.score_res,
  12615. a.NAME,
  12616. a.sex,
  12617. a.beh_dept_id,
  12618. a.beh_dept_name,
  12619. a.birthday,
  12620. a.behospital_date,
  12621. a.leave_hospital_date,
  12622. a.doctor_id,
  12623. a.doctor_name,
  12624. a.beh_doctor_id,
  12625. a.beh_doctor_name,
  12626. a.director_doctor_id,
  12627. a.director_doctor_name,
  12628. a.diagnose,
  12629. a.placefile_date,
  12630. a.ward_name,
  12631. b.gmt_create
  12632. FROM
  12633. med_behospital_info a,
  12634. med_qcresult_info b
  12635. WHERE
  12636. a.is_deleted = 'N'
  12637. AND b.is_deleted = 'N'
  12638. AND a.hospital_id = b.hospital_id
  12639. AND a.behospital_code = b.behospital_code
  12640. AND a.qc_type_id != 0
  12641. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12642. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12643. </if>
  12644. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12645. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12646. </if>
  12647. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12648. <if test="qcResultShortPageVO.startDate != null ">
  12649. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12650. </if>
  12651. <if test="qcResultShortPageVO.endDate != null ">
  12652. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12653. </if>
  12654. </if>
  12655. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12656. <if test="qcResultShortPageVO.startDate != null ">
  12657. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12658. </if>
  12659. <if test="qcResultShortPageVO.endDate != null">
  12660. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12661. </if>
  12662. </if>
  12663. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12664. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12665. </if>
  12666. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12667. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12668. </if>
  12669. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12670. AND b.`level` = #{qcResultShortPageVO.level}
  12671. </if>
  12672. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12673. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12674. </if>
  12675. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12676. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12677. </if>
  12678. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12679. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12680. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  12681. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  12682. </if>
  12683. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12684. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12685. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  12686. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  12687. </if>
  12688. ) be
  12689. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  12690. AND mci.check_type in(0,2)
  12691. AND be.hospital_id = mci.hospital_id
  12692. AND be.behospital_code = mci.behospital_code
  12693. LEFT JOIN med_qcresult_cases e
  12694. on be.behospital_code = e.behospital_code
  12695. and be.hospital_id = e.hospital_id
  12696. AND e.is_deleted = 'N'
  12697. and e.cases_id = 243
  12698. ) t1
  12699. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12700. AND t1.behospital_code = t2.behospital_code
  12701. AND t2.is_deleted = 'N'
  12702. ) t
  12703. WHERE
  12704. 1 = 1
  12705. <if test="qcResultShortPageVO.checkStatus != null">
  12706. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12707. </if>
  12708. <if test="qcResultShortPageVO.mrStatus != null">
  12709. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12710. </if>
  12711. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12712. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12713. </if>
  12714. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12715. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12716. </if>
  12717. <if test="qcResultShortPageVO.chTimeStart != null ">
  12718. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12719. </if>
  12720. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12721. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12722. </if>
  12723. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12724. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12725. </if>
  12726. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12727. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12728. </if>
  12729. </select>
  12730. <!-- 质控核查质控评分页-科室(内页)-->
  12731. <select id="qcCheckMRPageByDept" resultType="com.diagbot.dto.QcResultShortDeptDTO">
  12732. SELECT
  12733. t.*
  12734. FROM
  12735. (
  12736. SELECT DISTINCT
  12737. t1.hospital_id AS hospitalId,
  12738. t1.behospital_code AS behospitalCode,
  12739. t1.bed_code AS bedCode,
  12740. t1.LEVEL AS LEVEL,
  12741. t1.grade_type AS gradeType,
  12742. t1.score_res AS scoreRes,
  12743. t1.scoreBn,
  12744. t1.medoupName,
  12745. t1.NAME AS NAME,
  12746. t1.sex AS sex,
  12747. t1.beh_dept_id AS behDeptId,
  12748. t1.beh_dept_name AS behDeptName,
  12749. t1.doctor_id AS doctorId,
  12750. t1.doctor_name AS doctorName,
  12751. t1.beh_doctor_id AS behDoctorId,
  12752. t1.beh_doctor_name AS behDoctorName,
  12753. t1.director_doctor_id AS directorDoctorId,
  12754. t1.director_doctor_name AS directorDoctorName,
  12755. t1.birthday AS birthday,
  12756. t1.behospital_date AS behospitalDate,
  12757. t1.leave_hospital_date AS leaveHospitalDate,
  12758. t1.placefile_date AS placefileDate,
  12759. t1.gmt_create AS gradeTime,
  12760. t1.diagnose,
  12761. t1.ward_name AS wardName,
  12762. CONCAT( ifnull(t2.age,'') ,ifnull(t2.age_unit,'') )as age,
  12763. t1.file_code AS fileCode,
  12764. t1.checkStatus,
  12765. t1.mrStatus,
  12766. t1.chName,
  12767. t1.mrName,
  12768. t1.chTime,
  12769. t1.mrTime
  12770. FROM
  12771. (
  12772. SELECT
  12773. be.*,
  12774. t3.name as medoupName,
  12775. ifnull( mci.STATUS, 0 ) AS checkStatus,
  12776. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  12777. mci.check_name AS chName,
  12778. e.score_res as scoreBn,
  12779. hm_mci.check_name AS mrName,
  12780. mci.gmt_create AS chTime,
  12781. hm_mci.gmt_create AS mrTime
  12782. FROM
  12783. (
  12784. SELECT DISTINCT
  12785. a.hospital_id,
  12786. a.behospital_code,
  12787. a.bed_code,
  12788. a.file_code,
  12789. b.LEVEL,
  12790. b.grade_type,
  12791. b.score_res,
  12792. a.NAME,
  12793. a.sex,
  12794. a.beh_dept_id,
  12795. a.beh_dept_name,
  12796. a.birthday,
  12797. a.behospital_date,
  12798. a.leave_hospital_date,
  12799. a.doctor_id,
  12800. a.doctor_name,
  12801. a.beh_doctor_id,
  12802. a.beh_doctor_name,
  12803. a.director_doctor_id,
  12804. a.director_doctor_name,
  12805. a.diagnose,
  12806. a.placefile_date,
  12807. a.ward_name,
  12808. b.gmt_create
  12809. FROM
  12810. med_behospital_info a,
  12811. med_qcresult_info b,
  12812. sys_user_dept c
  12813. WHERE
  12814. a.is_deleted = 'N'
  12815. AND b.is_deleted = 'N'
  12816. AND c.is_deleted = 'N'
  12817. AND a.hospital_id = b.hospital_id
  12818. AND a.hospital_id = c.hospital_id
  12819. AND a.beh_dept_id = c.dept_id
  12820. AND a.behospital_code = b.behospital_code
  12821. AND a.qc_type_id != 0
  12822. <if test="qcResultShortPageVO.userId!=null">
  12823. AND c.user_id = #{qcResultShortPageVO.userId}
  12824. </if>
  12825. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  12826. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  12827. </if>
  12828. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  12829. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  12830. </if>
  12831. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  12832. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  12833. </if>
  12834. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  12835. <if test="qcResultShortPageVO.startDate != null ">
  12836. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  12837. </if>
  12838. <if test="qcResultShortPageVO.endDate != null ">
  12839. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  12840. </if>
  12841. </if>
  12842. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  12843. <if test="qcResultShortPageVO.startDate != null ">
  12844. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  12845. </if>
  12846. <if test="qcResultShortPageVO.endDate != null">
  12847. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  12848. </if>
  12849. </if>
  12850. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  12851. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  12852. </if>
  12853. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  12854. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  12855. </if>
  12856. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  12857. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  12858. </if>
  12859. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  12860. AND b.`level` = #{qcResultShortPageVO.level}
  12861. </if>
  12862. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  12863. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  12864. </if>
  12865. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  12866. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  12867. </if>
  12868. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  12869. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  12870. </if>
  12871. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  12872. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  12873. </if>
  12874. ) be
  12875. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  12876. AND mci.check_type = 0
  12877. AND be.hospital_id = mci.hospital_id
  12878. AND be.behospital_code = mci.behospital_code
  12879. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  12880. AND hm_mci.check_type = 1
  12881. AND be.hospital_id = hm_mci.hospital_id
  12882. AND be.behospital_code = hm_mci.behospital_code
  12883. LEFT JOIN med_qcresult_cases e
  12884. on be.behospital_code = e.behospital_code
  12885. and be.hospital_id = e.hospital_id
  12886. AND e.is_deleted = 'N'
  12887. and e.cases_id = 243
  12888. LEFT JOIN bas_doctor_info t2 ON be.doctor_id = t2.doctor_id
  12889. and be.hospital_id = t2.hospital_id
  12890. AND t2.is_deleted = 'N'
  12891. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  12892. AND t3.is_deleted = 'N'
  12893. ) t1
  12894. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  12895. AND t1.behospital_code = t2.behospital_code
  12896. AND t2.is_deleted = 'N'
  12897. ) t
  12898. WHERE
  12899. 1 = 1
  12900. <if test="qcResultShortPageVO.checkStatus != null">
  12901. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  12902. </if>
  12903. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  12904. AND t.medoupName LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  12905. </if>
  12906. <if test="qcResultShortPageVO.mrStatus != null">
  12907. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  12908. </if>
  12909. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  12910. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  12911. </if>
  12912. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  12913. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  12914. </if>
  12915. <if test="qcResultShortPageVO.chTimeStart != null ">
  12916. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  12917. </if>
  12918. <if test="qcResultShortPageVO.chTimeEnd != null ">
  12919. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  12920. </if>
  12921. <if test="qcResultShortPageVO.mrTimeStart != null ">
  12922. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  12923. </if>
  12924. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  12925. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  12926. </if>
  12927. </select>
  12928. <!-- 病案首页改善率质控评分页导出-->
  12929. <select id="hmImproveMRPageExport" resultMap="ExportExcelMap">
  12930. SELECT
  12931. f1.behDeptId,
  12932. f1.behDeptName,
  12933. f1.patName,
  12934. f1.behospitalCode,
  12935. f1.hospitalId,
  12936. f1.behospitalDate,
  12937. f1.leaveHospitalDate,
  12938. f1.score,
  12939. f1.scoreBn,
  12940. f2.avgScore,
  12941. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12942. f1.msg,
  12943. f1.caseName,
  12944. </if>
  12945. f1.checkStatus,
  12946. f1.chName,
  12947. f1.chTime
  12948. FROM
  12949. (SELECT
  12950. t.doctorName AS behDoctorName,
  12951. t.`name` AS patName,
  12952. t.behospitalCode AS behospitalCode,
  12953. t.behospitalDate AS behospitalDate,
  12954. t.leaveHospitalDate AS leaveHospitalDate,
  12955. qi.score_res AS score,
  12956. t.scoreBn,
  12957. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  12958. qd.msg AS msg,
  12959. qc.NAME AS caseName,
  12960. </if>
  12961. t.behDeptId,
  12962. t.behDeptName,
  12963. t.hospitalId,
  12964. t.checkStatus,
  12965. t.chName,
  12966. t.chTime
  12967. FROM
  12968. (
  12969. SELECT DISTINCT
  12970. t1.hospital_id AS hospitalId,
  12971. t1.behospital_code AS behospitalCode,
  12972. t1.bed_code AS bedCode,
  12973. t1.LEVEL AS LEVEL,
  12974. t1.grade_type AS gradeType,
  12975. t1.score_res AS scoreRes,
  12976. t1.scoreBn,
  12977. t1.NAME AS NAME,
  12978. t1.sex AS sex,
  12979. t1.beh_dept_id AS behDeptId,
  12980. t1.beh_dept_name AS behDeptName,
  12981. t1.doctor_id AS doctorId,
  12982. t1.doctor_name AS doctorName,
  12983. t1.beh_doctor_id AS behDoctorId,
  12984. t1.beh_doctor_name AS behDoctorName,
  12985. t1.director_doctor_id AS directorDoctorId,
  12986. t1.director_doctor_name AS directorDoctorName,
  12987. t1.birthday AS birthday,
  12988. t1.behospital_date AS behospitalDate,
  12989. t1.leave_hospital_date AS leaveHospitalDate,
  12990. t1.placefile_date AS placefileDate,
  12991. t1.gmt_create AS gradeTime,
  12992. t1.diagnose,
  12993. t1.ward_name AS wardName,
  12994. t2.age,
  12995. t1.file_code AS fileCode,
  12996. t1.checkStatus,
  12997. t1.chName,
  12998. t1.chTime
  12999. FROM
  13000. (
  13001. SELECT
  13002. be.*,
  13003. ifnull( mci.STATUS, 0 ) AS checkStatus,
  13004. mci.check_name AS chName,
  13005. mci.gmt_create AS chTime
  13006. FROM
  13007. (
  13008. SELECT DISTINCT
  13009. a.hospital_id,
  13010. a.behospital_code,
  13011. a.bed_code,
  13012. a.file_code,
  13013. c.LEVEL,
  13014. c.grade_type,
  13015. c.score_res,
  13016. a.NAME,
  13017. a.sex,
  13018. a.beh_dept_id,
  13019. a.beh_dept_name,
  13020. a.birthday,
  13021. a.behospital_date,
  13022. a.leave_hospital_date,
  13023. a.doctor_id,
  13024. a.doctor_name,
  13025. a.beh_doctor_id,
  13026. a.beh_doctor_name,
  13027. a.director_doctor_id,
  13028. a.director_doctor_name,
  13029. a.diagnose,
  13030. a.placefile_date,
  13031. a.ward_name,
  13032. c.gmt_create,
  13033. d.score_res as scoreBn
  13034. FROM
  13035. med_behospital_info a,
  13036. med_home_page b,
  13037. med_qcresult_info c,
  13038. med_qcresult_cases d,
  13039. (
  13040. SELECT
  13041. m4.*
  13042. FROM
  13043. med_behospital_info m1,
  13044. med_home_page m2,
  13045. med_qcresult_info m3,
  13046. med_qcresult_cases m4
  13047. WHERE
  13048. m1.is_deleted = 'N'
  13049. AND m2.is_deleted = 'N'
  13050. AND m3.is_deleted = 'Y'
  13051. AND m4.is_deleted = 'Y'
  13052. AND m1.hospital_id = m2.hospital_id
  13053. AND m1.hospital_id = m3.hospital_id
  13054. AND m1.hospital_id = m4.hospital_id
  13055. AND m1.behospital_code = m2.behospital_code
  13056. AND m1.behospital_code = m3.behospital_code
  13057. AND m1.behospital_code = m4.behospital_code
  13058. AND m3.gmt_create = m4.gmt_create
  13059. AND m3.have_home_page = 1
  13060. AND m4.cases_id = 243
  13061. AND m1.qc_type_id != 0
  13062. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13063. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13064. </if>
  13065. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13066. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  13067. </if>
  13068. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13069. <if test="qcResultShortPageVO.startDate != null ">
  13070. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13071. </if>
  13072. <if test="qcResultShortPageVO.endDate != null ">
  13073. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13074. </if>
  13075. </if>
  13076. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13077. <if test="qcResultShortPageVO.startDate != null">
  13078. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13079. </if>
  13080. <if test="qcResultShortPageVO.endDate != null ">
  13081. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13082. </if>
  13083. </if>
  13084. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13085. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  13086. </if>
  13087. GROUP BY
  13088. m1.behospital_code
  13089. ORDER BY
  13090. m1.behospital_code,
  13091. m4.gmt_create
  13092. ) e
  13093. WHERE
  13094. a.is_deleted = 'N'
  13095. AND b.is_deleted = 'N'
  13096. AND c.is_deleted = 'N'
  13097. AND d.is_deleted = 'N'
  13098. AND a.hospital_id = b.hospital_id
  13099. AND a.hospital_id = c.hospital_id
  13100. AND a.hospital_id = d.hospital_id
  13101. AND a.hospital_id = e.hospital_id
  13102. AND a.behospital_code = b.behospital_code
  13103. AND a.behospital_code = c.behospital_code
  13104. AND a.behospital_code = d.behospital_code
  13105. AND a.behospital_code = e.behospital_code
  13106. AND d.cases_id = 243
  13107. AND d.score_res > e.score_res
  13108. AND a.qc_type_id != 0
  13109. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13110. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13111. </if>
  13112. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13113. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13114. </if>
  13115. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13116. <if test="qcResultShortPageVO.startDate != null ">
  13117. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13118. </if>
  13119. <if test="qcResultShortPageVO.endDate != null ">
  13120. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13121. </if>
  13122. </if>
  13123. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13124. <if test="qcResultShortPageVO.startDate != null ">
  13125. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13126. </if>
  13127. <if test="qcResultShortPageVO.endDate != null">
  13128. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13129. </if>
  13130. </if>
  13131. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13132. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13133. </if>
  13134. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13135. AND c.`level` = #{qcResultShortPageVO.level}
  13136. </if>
  13137. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13138. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13139. </if>
  13140. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13141. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13142. </if>
  13143. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13144. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13145. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13146. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13147. </if>
  13148. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13149. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13150. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13151. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13152. </if>
  13153. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  13154. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  13155. </if>
  13156. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  13157. AND d.score_res = 20
  13158. </if>
  13159. ) be
  13160. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  13161. AND mci.check_type in(0,2)
  13162. AND be.hospital_id = mci.hospital_id
  13163. AND be.behospital_code = mci.behospital_code
  13164. ) t1
  13165. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13166. AND t1.behospital_code = t2.behospital_code
  13167. AND t2.is_deleted = 'N'
  13168. ) t
  13169. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13170. AND t.hospitalId = qi.hospital_id
  13171. AND t.behospitalCode = qi.behospital_code
  13172. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13173. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13174. AND t.hospitalId = qd.hospital_id
  13175. AND t.behospitalCode = qd.behospital_code
  13176. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13177. AND qd.cases_id = qc.id
  13178. </if>
  13179. where 1=1
  13180. <if test="qcResultShortPageVO.checkStatus != null">
  13181. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13182. </if>
  13183. <if test="qcResultShortPageVO.mrStatus != null">
  13184. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13185. </if>
  13186. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13187. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13188. </if>
  13189. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13190. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13191. </if>
  13192. <if test="qcResultShortPageVO.chTimeStart != null ">
  13193. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13194. </if>
  13195. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13196. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13197. </if>
  13198. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13199. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13200. </if>
  13201. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13202. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13203. </if>
  13204. )f1,
  13205. (SELECT
  13206. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13207. t.behDeptId,
  13208. t.behDeptName
  13209. FROM
  13210. (
  13211. SELECT DISTINCT
  13212. t1.hospital_id AS hospitalId,
  13213. t1.behospital_code AS behospitalCode,
  13214. t1.bed_code AS bedCode,
  13215. t1.LEVEL AS LEVEL,
  13216. t1.grade_type AS gradeType,
  13217. t1.score_res AS scoreRes,
  13218. t1.NAME AS NAME,
  13219. t1.sex AS sex,
  13220. t1.beh_dept_id AS behDeptId,
  13221. t1.beh_dept_name AS behDeptName,
  13222. t1.doctor_id AS doctorId,
  13223. t1.doctor_name AS doctorName,
  13224. t1.beh_doctor_id AS behDoctorId,
  13225. t1.beh_doctor_name AS behDoctorName,
  13226. t1.director_doctor_id AS directorDoctorId,
  13227. t1.director_doctor_name AS directorDoctorName,
  13228. t1.birthday AS birthday,
  13229. t1.behospital_date AS behospitalDate,
  13230. t1.leave_hospital_date AS leaveHospitalDate,
  13231. t1.placefile_date AS placefileDate,
  13232. t1.gmt_create AS gradeTime,
  13233. t1.diagnose,
  13234. t1.ward_name AS wardName,
  13235. t2.age,
  13236. t1.file_code AS fileCode,
  13237. t1.checkStatus,
  13238. t1.chName,
  13239. t1.chTime
  13240. FROM
  13241. (
  13242. SELECT
  13243. be.*,
  13244. ifnull( mci.STATUS, 0 ) AS checkStatus,
  13245. mci.check_name AS chName,
  13246. mci.gmt_create AS chTime
  13247. FROM
  13248. (
  13249. SELECT DISTINCT
  13250. a.hospital_id,
  13251. a.behospital_code,
  13252. a.bed_code,
  13253. a.file_code,
  13254. c.LEVEL,
  13255. c.grade_type,
  13256. c.score_res,
  13257. a.NAME,
  13258. a.sex,
  13259. a.beh_dept_id,
  13260. a.beh_dept_name,
  13261. a.birthday,
  13262. a.behospital_date,
  13263. a.leave_hospital_date,
  13264. a.doctor_id,
  13265. a.doctor_name,
  13266. a.beh_doctor_id,
  13267. a.beh_doctor_name,
  13268. a.director_doctor_id,
  13269. a.director_doctor_name,
  13270. a.diagnose,
  13271. a.placefile_date,
  13272. a.ward_name,
  13273. c.gmt_create
  13274. FROM
  13275. med_behospital_info a,
  13276. med_home_page b,
  13277. med_qcresult_info c,
  13278. med_qcresult_cases d,
  13279. (
  13280. SELECT
  13281. m4.*
  13282. FROM
  13283. med_behospital_info m1,
  13284. med_home_page m2,
  13285. med_qcresult_info m3,
  13286. med_qcresult_cases m4
  13287. WHERE
  13288. m1.is_deleted = 'N'
  13289. AND m2.is_deleted = 'N'
  13290. AND m3.is_deleted = 'Y'
  13291. AND m4.is_deleted = 'Y'
  13292. AND m1.hospital_id = m2.hospital_id
  13293. AND m1.hospital_id = m3.hospital_id
  13294. AND m1.hospital_id = m4.hospital_id
  13295. AND m1.behospital_code = m2.behospital_code
  13296. AND m1.behospital_code = m3.behospital_code
  13297. AND m1.behospital_code = m4.behospital_code
  13298. AND m3.gmt_create = m4.gmt_create
  13299. AND m3.have_home_page = 1
  13300. AND m4.cases_id = 243
  13301. AND m1.qc_type_id != 0
  13302. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13303. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13304. </if>
  13305. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13306. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  13307. </if>
  13308. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13309. <if test="qcResultShortPageVO.startDate != null ">
  13310. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13311. </if>
  13312. <if test="qcResultShortPageVO.endDate != null ">
  13313. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13314. </if>
  13315. </if>
  13316. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13317. <if test="qcResultShortPageVO.startDate != null">
  13318. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13319. </if>
  13320. <if test="qcResultShortPageVO.endDate != null ">
  13321. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13322. </if>
  13323. </if>
  13324. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13325. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  13326. </if>
  13327. GROUP BY
  13328. m1.behospital_code
  13329. ORDER BY
  13330. m1.behospital_code,
  13331. m4.gmt_create
  13332. ) e
  13333. WHERE
  13334. a.is_deleted = 'N'
  13335. AND b.is_deleted = 'N'
  13336. AND c.is_deleted = 'N'
  13337. AND d.is_deleted = 'N'
  13338. AND a.hospital_id = b.hospital_id
  13339. AND a.hospital_id = c.hospital_id
  13340. AND a.hospital_id = d.hospital_id
  13341. AND a.hospital_id = e.hospital_id
  13342. AND a.behospital_code = b.behospital_code
  13343. AND a.behospital_code = c.behospital_code
  13344. AND a.behospital_code = d.behospital_code
  13345. AND a.behospital_code = e.behospital_code
  13346. AND d.cases_id = 243
  13347. AND d.score_res > e.score_res
  13348. AND a.qc_type_id != 0
  13349. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13350. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13351. </if>
  13352. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13353. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13354. </if>
  13355. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13356. <if test="qcResultShortPageVO.startDate != null ">
  13357. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13358. </if>
  13359. <if test="qcResultShortPageVO.endDate != null ">
  13360. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13361. </if>
  13362. </if>
  13363. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13364. <if test="qcResultShortPageVO.startDate != null ">
  13365. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13366. </if>
  13367. <if test="qcResultShortPageVO.endDate != null">
  13368. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13369. </if>
  13370. </if>
  13371. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13372. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13373. </if>
  13374. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13375. AND c.`level` = #{qcResultShortPageVO.level}
  13376. </if>
  13377. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13378. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13379. </if>
  13380. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13381. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13382. </if>
  13383. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13384. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13385. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  13386. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  13387. </if>
  13388. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13389. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13390. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  13391. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  13392. </if>
  13393. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  13394. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  13395. </if>
  13396. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  13397. AND d.score_res = 20
  13398. </if>
  13399. ) be
  13400. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  13401. AND mci.check_type in(0,2)
  13402. AND be.hospital_id = mci.hospital_id
  13403. AND be.behospital_code = mci.behospital_code
  13404. ) t1
  13405. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13406. AND t1.behospital_code = t2.behospital_code
  13407. AND t2.is_deleted = 'N'
  13408. ) t
  13409. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13410. AND t.hospitalId = qi.hospital_id
  13411. AND t.behospitalCode = qi.behospital_code
  13412. where 1=1
  13413. <if test="qcResultShortPageVO.checkStatus != null">
  13414. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13415. </if>
  13416. <if test="qcResultShortPageVO.mrStatus != null">
  13417. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13418. </if>
  13419. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13420. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13421. </if>
  13422. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13423. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13424. </if>
  13425. <if test="qcResultShortPageVO.chTimeStart != null ">
  13426. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13427. </if>
  13428. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13429. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13430. </if>
  13431. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13432. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13433. </if>
  13434. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13435. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13436. </if>
  13437. GROUP BY
  13438. t.behDeptId,
  13439. t.behDeptName
  13440. )f2
  13441. WHERE
  13442. f1.behDeptId = f2.behDeptId
  13443. AND f1.behDeptName = f2.behDeptName
  13444. </select>
  13445. <!-- 病案首页改善率质控评分页导出-->
  13446. <select id="improveMRExportByDept" resultMap="ExportExcelMapByDept">
  13447. SELECT
  13448. f1.behDeptId,
  13449. f1.behDeptName,
  13450. f1.wardName,
  13451. f1.medoupName,
  13452. f1.doctorId,
  13453. f1.doctorName,
  13454. f1.patName,
  13455. f1.behospitalCode,
  13456. f1.hospitalId,
  13457. f1.scoreBn,
  13458. f1.behospitalDate,
  13459. f1.leaveHospitalDate,
  13460. f1.score,
  13461. f2.avgScore,
  13462. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13463. f1.msg,
  13464. f1.caseName,
  13465. </if>
  13466. f1.checkStatus,
  13467. f1.mrStatus,
  13468. f1.chName,
  13469. f1.mrName,
  13470. f1.chTime,
  13471. f1.mrTime
  13472. FROM
  13473. (SELECT
  13474. t.doctorId,
  13475. t.doctorName,
  13476. t.`name` AS patName,
  13477. t.behospitalCode AS behospitalCode,
  13478. t.behospitalDate AS behospitalDate,
  13479. t.leaveHospitalDate AS leaveHospitalDate,
  13480. qi.score_res AS score,
  13481. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13482. qd.msg AS msg,
  13483. qc.NAME AS caseName,
  13484. </if>
  13485. t.behDeptId,
  13486. t.behDeptName,
  13487. t.wardName,
  13488. t.scoreBn,
  13489. t3.name as medoupName,
  13490. t.hospitalId,
  13491. t.checkStatus,
  13492. t.mrStatus,
  13493. t.chName,
  13494. t.mrName,
  13495. t.chTime,
  13496. t.mrTime
  13497. FROM
  13498. (
  13499. SELECT DISTINCT
  13500. t1.hospital_id AS hospitalId,
  13501. t1.behospital_code AS behospitalCode,
  13502. t1.bed_code AS bedCode,
  13503. t1.LEVEL AS LEVEL,
  13504. t1.grade_type AS gradeType,
  13505. t1.score_res AS scoreRes,
  13506. t1.NAME AS NAME,
  13507. t1.sex AS sex,
  13508. t1.beh_dept_id AS behDeptId,
  13509. t1.beh_dept_name AS behDeptName,
  13510. t1.doctor_id AS doctorId,
  13511. t1.doctor_name AS doctorName,
  13512. t1.beh_doctor_id AS behDoctorId,
  13513. t1.beh_doctor_name AS behDoctorName,
  13514. t1.director_doctor_id AS directorDoctorId,
  13515. t1.director_doctor_name AS directorDoctorName,
  13516. t1.birthday AS birthday,
  13517. t1.behospital_date AS behospitalDate,
  13518. t1.leave_hospital_date AS leaveHospitalDate,
  13519. t1.placefile_date AS placefileDate,
  13520. t1.gmt_create AS gradeTime,
  13521. t1.diagnose,
  13522. t1.ward_name AS wardName,
  13523. t1.scoreBn,
  13524. t1.file_code AS fileCode,
  13525. t1.checkStatus,
  13526. t1.mrStatus,
  13527. t1.chName,
  13528. t1.mrName,
  13529. t1.chTime,
  13530. t1.mrTime
  13531. FROM
  13532. (
  13533. SELECT
  13534. be.*,
  13535. ifnull( mci.STATUS, 0 ) AS checkStatus,
  13536. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  13537. mci.check_name AS chName,
  13538. e.score_res as scoreBn,
  13539. hm_mci.check_name AS mrName,
  13540. mci.gmt_create AS chTime,
  13541. hm_mci.gmt_create AS mrTime
  13542. FROM
  13543. (
  13544. SELECT DISTINCT
  13545. a.hospital_id,
  13546. a.behospital_code,
  13547. a.bed_code,
  13548. a.file_code,
  13549. c.LEVEL,
  13550. c.grade_type,
  13551. c.score_res,
  13552. a.NAME,
  13553. a.sex,
  13554. a.beh_dept_id,
  13555. a.beh_dept_name,
  13556. a.birthday,
  13557. a.behospital_date,
  13558. a.leave_hospital_date,
  13559. a.doctor_id,
  13560. a.doctor_name,
  13561. a.beh_doctor_id,
  13562. a.beh_doctor_name,
  13563. a.director_doctor_id,
  13564. a.director_doctor_name,
  13565. a.diagnose,
  13566. a.placefile_date,
  13567. a.ward_name,
  13568. c.gmt_create
  13569. FROM
  13570. med_behospital_info a,
  13571. med_home_page b,
  13572. med_qcresult_info c,
  13573. med_qcresult_cases d,
  13574. sys_user_dept f,
  13575. (
  13576. SELECT
  13577. m4.*
  13578. FROM
  13579. med_behospital_info m1,
  13580. med_home_page m2,
  13581. med_qcresult_info m3,
  13582. med_qcresult_cases m4
  13583. WHERE
  13584. m1.is_deleted = 'N'
  13585. AND m2.is_deleted = 'N'
  13586. AND m3.is_deleted = 'Y'
  13587. AND m4.is_deleted = 'Y'
  13588. AND m1.hospital_id = m2.hospital_id
  13589. AND m1.hospital_id = m3.hospital_id
  13590. AND m1.hospital_id = m4.hospital_id
  13591. AND m1.behospital_code = m2.behospital_code
  13592. AND m1.behospital_code = m3.behospital_code
  13593. AND m1.behospital_code = m4.behospital_code
  13594. AND m3.gmt_create = m4.gmt_create
  13595. AND m3.have_home_page = 1
  13596. AND m4.cases_id = 243
  13597. AND m1.qc_type_id != 0
  13598. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13599. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13600. </if>
  13601. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13602. and m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13603. </if>
  13604. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13605. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  13606. </if>
  13607. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13608. AND m1.doctor_name = #{qcResultShortPageVO.doctorName}
  13609. </if>
  13610. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13611. <if test="qcResultShortPageVO.startDate != null ">
  13612. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13613. </if>
  13614. <if test="qcResultShortPageVO.endDate != null ">
  13615. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13616. </if>
  13617. </if>
  13618. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13619. <if test="qcResultShortPageVO.startDate != null">
  13620. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13621. </if>
  13622. <if test="qcResultShortPageVO.endDate != null ">
  13623. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13624. </if>
  13625. </if>
  13626. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13627. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  13628. </if>
  13629. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13630. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  13631. </if>
  13632. GROUP BY
  13633. m1.behospital_code
  13634. ORDER BY
  13635. m1.behospital_code,
  13636. m4.gmt_create
  13637. ) e
  13638. WHERE
  13639. a.is_deleted = 'N'
  13640. AND b.is_deleted = 'N'
  13641. AND c.is_deleted = 'N'
  13642. AND d.is_deleted = 'N'
  13643. AND f.is_deleted = 'N'
  13644. AND a.hospital_id = b.hospital_id
  13645. AND a.hospital_id = c.hospital_id
  13646. AND a.hospital_id = d.hospital_id
  13647. AND a.hospital_id = e.hospital_id
  13648. AND a.hospital_id = f.hospital_id
  13649. AND a.behospital_code = b.behospital_code
  13650. AND a.behospital_code = c.behospital_code
  13651. AND a.behospital_code = d.behospital_code
  13652. AND a.behospital_code = e.behospital_code
  13653. AND a.beh_dept_id = f.dept_id
  13654. AND d.cases_id = 243
  13655. AND d.score_res > e.score_res
  13656. AND a.qc_type_id != 0
  13657. <if test="qcResultShortPageVO.userId!=null">
  13658. AND f.user_id = #{qcResultShortPageVO.userId}
  13659. </if>
  13660. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13661. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13662. </if>
  13663. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13664. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13665. </if>
  13666. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13667. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13668. </if>
  13669. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13670. <if test="qcResultShortPageVO.startDate != null ">
  13671. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13672. </if>
  13673. <if test="qcResultShortPageVO.endDate != null ">
  13674. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13675. </if>
  13676. </if>
  13677. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13678. <if test="qcResultShortPageVO.startDate != null ">
  13679. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13680. </if>
  13681. <if test="qcResultShortPageVO.endDate != null">
  13682. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13683. </if>
  13684. </if>
  13685. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13686. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13687. </if>
  13688. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13689. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  13690. </if>
  13691. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13692. AND c.`level` = #{qcResultShortPageVO.level}
  13693. </if>
  13694. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13695. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13696. </if>
  13697. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13698. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13699. </if>
  13700. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13701. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  13702. </if>
  13703. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13704. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  13705. </if>
  13706. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  13707. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  13708. </if>
  13709. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  13710. AND d.score_res = 20
  13711. </if>
  13712. ) be
  13713. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  13714. AND mci.check_type = 0
  13715. AND be.hospital_id = mci.hospital_id
  13716. AND be.behospital_code = mci.behospital_code
  13717. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  13718. AND hm_mci.check_type = 1
  13719. AND be.hospital_id = hm_mci.hospital_id
  13720. AND be.behospital_code = hm_mci.behospital_code
  13721. LEFT JOIN med_qcresult_cases e
  13722. on be.behospital_code = e.behospital_code
  13723. and be.hospital_id = e.hospital_id
  13724. AND e.is_deleted = 'N'
  13725. and e.cases_id = 243
  13726. ) t1
  13727. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  13728. AND t1.behospital_code = t2.behospital_code
  13729. AND t2.is_deleted = 'N'
  13730. ) t
  13731. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  13732. AND t.hospitalId = qi.hospital_id
  13733. AND t.behospitalCode = qi.behospital_code
  13734. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  13735. AND t.hospitalId = t2.hospital_id
  13736. AND t2.is_deleted = 'N'
  13737. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  13738. AND t3.is_deleted = 'N'
  13739. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  13740. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  13741. AND t.hospitalId = qd.hospital_id
  13742. AND t.behospitalCode = qd.behospital_code
  13743. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  13744. AND qd.cases_id = qc.id
  13745. </if>
  13746. where 1=1
  13747. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  13748. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  13749. </if>
  13750. <if test="qcResultShortPageVO.checkStatus != null">
  13751. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  13752. </if>
  13753. <if test="qcResultShortPageVO.mrStatus != null">
  13754. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  13755. </if>
  13756. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  13757. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  13758. </if>
  13759. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  13760. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  13761. </if>
  13762. <if test="qcResultShortPageVO.chTimeStart != null ">
  13763. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  13764. </if>
  13765. <if test="qcResultShortPageVO.chTimeEnd != null ">
  13766. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  13767. </if>
  13768. <if test="qcResultShortPageVO.mrTimeStart != null ">
  13769. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  13770. </if>
  13771. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  13772. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  13773. </if>
  13774. )f1,
  13775. (SELECT
  13776. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  13777. t.behDeptId,
  13778. t.behDeptName,
  13779. t.doctorId,
  13780. t.doctorName
  13781. FROM
  13782. (
  13783. SELECT DISTINCT
  13784. t1.hospital_id AS hospitalId,
  13785. t1.behospital_code AS behospitalCode,
  13786. t1.bed_code AS bedCode,
  13787. t1.LEVEL AS LEVEL,
  13788. t1.grade_type AS gradeType,
  13789. t1.score_res AS scoreRes,
  13790. t1.NAME AS NAME,
  13791. t1.sex AS sex,
  13792. t1.beh_dept_id AS behDeptId,
  13793. t1.beh_dept_name AS behDeptName,
  13794. t1.doctor_id AS doctorId,
  13795. t1.doctor_name AS doctorName,
  13796. t1.beh_doctor_id AS behDoctorId,
  13797. t1.beh_doctor_name AS behDoctorName,
  13798. t1.director_doctor_id AS directorDoctorId,
  13799. t1.director_doctor_name AS directorDoctorName,
  13800. t1.birthday AS birthday,
  13801. t1.behospital_date AS behospitalDate,
  13802. t1.leave_hospital_date AS leaveHospitalDate,
  13803. t1.placefile_date AS placefileDate,
  13804. t1.gmt_create AS gradeTime,
  13805. t1.diagnose,
  13806. t1.ward_name AS wardName,
  13807. t2.age,
  13808. t1.file_code AS fileCode,
  13809. t1.checkStatus,
  13810. t1.mrStatus,
  13811. t1.chName,
  13812. t1.mrName,
  13813. t1.chTime,
  13814. t1.mrTime
  13815. FROM
  13816. (
  13817. SELECT
  13818. be.*,
  13819. ifnull( mci.STATUS, 0 ) AS checkStatus,
  13820. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  13821. mci.check_name AS chName,
  13822. hm_mci.check_name AS mrName,
  13823. mci.gmt_create AS chTime,
  13824. hm_mci.gmt_create AS mrTime
  13825. FROM
  13826. (
  13827. SELECT DISTINCT
  13828. a.hospital_id,
  13829. a.behospital_code,
  13830. a.bed_code,
  13831. a.file_code,
  13832. c.LEVEL,
  13833. c.grade_type,
  13834. c.score_res,
  13835. a.NAME,
  13836. a.sex,
  13837. a.beh_dept_id,
  13838. a.beh_dept_name,
  13839. a.birthday,
  13840. a.behospital_date,
  13841. a.leave_hospital_date,
  13842. a.doctor_id,
  13843. a.doctor_name,
  13844. a.beh_doctor_id,
  13845. a.beh_doctor_name,
  13846. a.director_doctor_id,
  13847. a.director_doctor_name,
  13848. a.diagnose,
  13849. a.placefile_date,
  13850. a.ward_name,
  13851. c.gmt_create
  13852. FROM
  13853. med_behospital_info a,
  13854. med_home_page b,
  13855. med_qcresult_info c,
  13856. med_qcresult_cases d,
  13857. sys_user_dept f,
  13858. (
  13859. SELECT
  13860. m4.*
  13861. FROM
  13862. med_behospital_info m1,
  13863. med_home_page m2,
  13864. med_qcresult_info m3,
  13865. med_qcresult_cases m4
  13866. WHERE
  13867. m1.is_deleted = 'N'
  13868. AND m2.is_deleted = 'N'
  13869. AND m3.is_deleted = 'Y'
  13870. AND m4.is_deleted = 'Y'
  13871. AND m1.hospital_id = m2.hospital_id
  13872. AND m1.hospital_id = m3.hospital_id
  13873. AND m1.hospital_id = m4.hospital_id
  13874. AND m1.behospital_code = m2.behospital_code
  13875. AND m1.behospital_code = m3.behospital_code
  13876. AND m1.behospital_code = m4.behospital_code
  13877. AND m3.gmt_create = m4.gmt_create
  13878. AND m3.have_home_page = 1
  13879. AND m4.cases_id = 243
  13880. AND m1.qc_type_id != 0
  13881. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13882. and m1.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13883. </if>
  13884. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13885. and m1.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13886. </if>
  13887. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13888. AND m1.hospital_id = #{qcResultShortPageVO.hospitalId}
  13889. </if>
  13890. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13891. AND m1.doctor_name = #{qcResultShortPageVO.doctorName}
  13892. </if>
  13893. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13894. <if test="qcResultShortPageVO.startDate != null ">
  13895. <![CDATA[ AND m1.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13896. </if>
  13897. <if test="qcResultShortPageVO.endDate != null ">
  13898. <![CDATA[ AND m1.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13899. </if>
  13900. </if>
  13901. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13902. <if test="qcResultShortPageVO.startDate != null">
  13903. <![CDATA[ AND m1.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13904. </if>
  13905. <if test="qcResultShortPageVO.endDate != null ">
  13906. <![CDATA[ AND m1.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13907. </if>
  13908. </if>
  13909. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13910. AND m1.beh_dept_name = #{qcResultShortPageVO.deptName}
  13911. </if>
  13912. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13913. AND m1.beh_dept_id = #{qcResultShortPageVO.deptId}
  13914. </if>
  13915. GROUP BY
  13916. m1.behospital_code
  13917. ORDER BY
  13918. m1.behospital_code,
  13919. m4.gmt_create
  13920. ) e
  13921. WHERE
  13922. a.is_deleted = 'N'
  13923. AND b.is_deleted = 'N'
  13924. AND c.is_deleted = 'N'
  13925. AND d.is_deleted = 'N'
  13926. AND f.is_deleted = 'N'
  13927. AND a.hospital_id = b.hospital_id
  13928. AND a.hospital_id = c.hospital_id
  13929. AND a.hospital_id = d.hospital_id
  13930. AND a.hospital_id = e.hospital_id
  13931. AND a.hospital_id = f.hospital_id
  13932. AND a.behospital_code = b.behospital_code
  13933. AND a.behospital_code = c.behospital_code
  13934. AND a.behospital_code = d.behospital_code
  13935. AND a.behospital_code = e.behospital_code
  13936. AND a.beh_dept_id = f.dept_id
  13937. AND d.cases_id = 243
  13938. AND d.score_res > e.score_res
  13939. AND a.qc_type_id != 0
  13940. <if test="qcResultShortPageVO.userId!=null">
  13941. AND f.user_id = #{qcResultShortPageVO.userId}
  13942. </if>
  13943. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  13944. and a.ward_nameLIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  13945. </if>
  13946. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  13947. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  13948. </if>
  13949. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  13950. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  13951. </if>
  13952. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  13953. <if test="qcResultShortPageVO.startDate != null ">
  13954. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  13955. </if>
  13956. <if test="qcResultShortPageVO.endDate != null ">
  13957. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  13958. </if>
  13959. </if>
  13960. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  13961. <if test="qcResultShortPageVO.startDate != null ">
  13962. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  13963. </if>
  13964. <if test="qcResultShortPageVO.endDate != null">
  13965. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  13966. </if>
  13967. </if>
  13968. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  13969. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  13970. </if>
  13971. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  13972. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  13973. </if>
  13974. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  13975. AND c.`level` = #{qcResultShortPageVO.level}
  13976. </if>
  13977. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  13978. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  13979. </if>
  13980. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  13981. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  13982. </if>
  13983. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  13984. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  13985. </if>
  13986. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  13987. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  13988. </if>
  13989. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 2">
  13990. <![CDATA[AND ( e.`level` = '不合格' AND d.`level` = '合格' AND d.score_res < 20 )]]>
  13991. </if>
  13992. <if test="qcResultShortPageVO.improveType != null and qcResultShortPageVO.improveType == 3">
  13993. AND d.score_res = 20
  13994. </if>
  13995. ) be
  13996. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  13997. AND mci.check_type = 0
  13998. AND be.hospital_id = mci.hospital_id
  13999. AND be.behospital_code = mci.behospital_code
  14000. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14001. AND hm_mci.check_type = 1
  14002. AND be.hospital_id = hm_mci.hospital_id
  14003. AND be.behospital_code = hm_mci.behospital_code
  14004. ) t1
  14005. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14006. AND t1.behospital_code = t2.behospital_code
  14007. AND t2.is_deleted = 'N'
  14008. ) t
  14009. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14010. AND t.hospitalId = qi.hospital_id
  14011. AND t.behospitalCode = qi.behospital_code
  14012. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  14013. AND t.hospitalId = t2.hospital_id
  14014. AND t2.is_deleted = 'N'
  14015. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  14016. AND t3.is_deleted = 'N'
  14017. where 1=1
  14018. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName!=''">
  14019. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  14020. </if>
  14021. <if test="qcResultShortPageVO.checkStatus != null">
  14022. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14023. </if>
  14024. <if test="qcResultShortPageVO.mrStatus != null">
  14025. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14026. </if>
  14027. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14028. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14029. </if>
  14030. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14031. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14032. </if>
  14033. <if test="qcResultShortPageVO.chTimeStart != null ">
  14034. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14035. </if>
  14036. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14037. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14038. </if>
  14039. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14040. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14041. </if>
  14042. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14043. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14044. </if>
  14045. GROUP BY
  14046. t.doctorId,
  14047. t.doctorName
  14048. )f2
  14049. WHERE
  14050. f1.doctorId = f2.doctorId
  14051. AND f1.doctorName = f2.doctorName
  14052. </select>
  14053. <!-- 质控核查质控评分页导出-->
  14054. <select id="qcCheckMRPageExport" resultMap="ExportExcelMap">
  14055. SELECT
  14056. f1.behDeptId,
  14057. f1.behDeptName,
  14058. f1.doctorName,
  14059. f1.patName,
  14060. f1.behospitalCode,
  14061. f1.hospitalId,
  14062. f1.behospitalDate,
  14063. f1.leaveHospitalDate,
  14064. f1.score,
  14065. f1.scoreBn,
  14066. f2.avgScore,
  14067. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14068. f1.msg,
  14069. f1.caseName,
  14070. </if>
  14071. f1.checkStatus,
  14072. f1.chName,
  14073. f1.chTime
  14074. FROM
  14075. (SELECT
  14076. t.doctorName,
  14077. t.`name` AS patName,
  14078. t.behospitalCode AS behospitalCode,
  14079. t.behospitalDate AS behospitalDate,
  14080. t.leaveHospitalDate AS leaveHospitalDate,
  14081. qi.score_res AS score,
  14082. t.scoreBn,
  14083. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14084. qd.msg AS msg,
  14085. qc.NAME AS caseName,
  14086. </if>
  14087. t.behDeptId,
  14088. t.behDeptName,
  14089. t.hospitalId,
  14090. t.checkStatus,
  14091. t.chName,
  14092. t.chTime
  14093. FROM
  14094. (
  14095. SELECT DISTINCT
  14096. t1.hospital_id AS hospitalId,
  14097. t1.behospital_code AS behospitalCode,
  14098. t1.bed_code AS bedCode,
  14099. t1.LEVEL AS LEVEL,
  14100. t1.grade_type AS gradeType,
  14101. t1.score_res AS scoreRes,
  14102. t1.scoreBn,
  14103. t1.NAME AS NAME,
  14104. t1.sex AS sex,
  14105. t1.beh_dept_id AS behDeptId,
  14106. t1.beh_dept_name AS behDeptName,
  14107. t1.doctor_id AS doctorId,
  14108. t1.doctor_name AS doctorName,
  14109. t1.beh_doctor_id AS behDoctorId,
  14110. t1.beh_doctor_name AS behDoctorName,
  14111. t1.director_doctor_id AS directorDoctorId,
  14112. t1.director_doctor_name AS directorDoctorName,
  14113. t1.birthday AS birthday,
  14114. t1.behospital_date AS behospitalDate,
  14115. t1.leave_hospital_date AS leaveHospitalDate,
  14116. t1.placefile_date AS placefileDate,
  14117. t1.gmt_create AS gradeTime,
  14118. t1.diagnose,
  14119. t1.ward_name AS wardName,
  14120. t2.age,
  14121. t1.file_code AS fileCode,
  14122. t1.checkStatus,
  14123. t1.chName,
  14124. t1.chTime
  14125. FROM
  14126. (
  14127. SELECT
  14128. be.*,
  14129. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14130. mci.check_name AS chName,
  14131. e.score_res as scoreBn,
  14132. mci.gmt_create AS chTime
  14133. FROM
  14134. (
  14135. SELECT DISTINCT
  14136. a.hospital_id,
  14137. a.behospital_code,
  14138. a.bed_code,
  14139. a.file_code,
  14140. b.LEVEL,
  14141. b.grade_type,
  14142. b.score_res,
  14143. a.NAME,
  14144. a.sex,
  14145. a.beh_dept_id,
  14146. a.beh_dept_name,
  14147. a.birthday,
  14148. a.behospital_date,
  14149. a.leave_hospital_date,
  14150. a.doctor_id,
  14151. a.doctor_name,
  14152. a.beh_doctor_id,
  14153. a.beh_doctor_name,
  14154. a.director_doctor_id,
  14155. a.director_doctor_name,
  14156. a.diagnose,
  14157. a.placefile_date,
  14158. a.ward_name,
  14159. b.gmt_create
  14160. FROM
  14161. med_behospital_info a,
  14162. med_qcresult_info b
  14163. WHERE
  14164. a.is_deleted = 'N'
  14165. AND b.is_deleted = 'N'
  14166. AND a.hospital_id = b.hospital_id
  14167. AND a.behospital_code = b.behospital_code
  14168. AND a.qc_type_id != 0
  14169. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14170. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14171. </if>
  14172. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14173. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14174. </if>
  14175. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14176. <if test="qcResultShortPageVO.startDate != null ">
  14177. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14178. </if>
  14179. <if test="qcResultShortPageVO.endDate != null ">
  14180. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14181. </if>
  14182. </if>
  14183. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14184. <if test="qcResultShortPageVO.startDate != null ">
  14185. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14186. </if>
  14187. <if test="qcResultShortPageVO.endDate != null">
  14188. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14189. </if>
  14190. </if>
  14191. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14192. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14193. </if>
  14194. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14195. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14196. </if>
  14197. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14198. AND c.`level` = #{qcResultShortPageVO.level}
  14199. </if>
  14200. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14201. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14202. </if>
  14203. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14204. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14205. </if>
  14206. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14207. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14208. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14209. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14210. </if>
  14211. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14212. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14213. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14214. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14215. </if>
  14216. ) be
  14217. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14218. AND mci.check_type in(0,2)
  14219. AND be.hospital_id = mci.hospital_id
  14220. AND be.behospital_code = mci.behospital_code
  14221. LEFT JOIN med_qcresult_cases e
  14222. on be.behospital_code = e.behospital_code
  14223. and be.hospital_id = e.hospital_id
  14224. AND e.is_deleted = 'N'
  14225. and e.cases_id = 243
  14226. ) t1
  14227. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14228. AND t1.behospital_code = t2.behospital_code
  14229. AND t2.is_deleted = 'N'
  14230. ) t
  14231. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14232. AND t.hospitalId = qi.hospital_id
  14233. AND t.behospitalCode = qi.behospital_code
  14234. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14235. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14236. AND t.hospitalId = qd.hospital_id
  14237. AND t.behospitalCode = qd.behospital_code
  14238. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14239. AND qd.cases_id = qc.id
  14240. </if>
  14241. where 1=1
  14242. <if test="qcResultShortPageVO.checkStatus != null">
  14243. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14244. </if>
  14245. <if test="qcResultShortPageVO.mrStatus != null">
  14246. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14247. </if>
  14248. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14249. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14250. </if>
  14251. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14252. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14253. </if>
  14254. <if test="qcResultShortPageVO.chTimeStart != null ">
  14255. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14256. </if>
  14257. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14258. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14259. </if>
  14260. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14261. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14262. </if>
  14263. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14264. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14265. </if>
  14266. )f1,
  14267. (SELECT
  14268. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14269. t.behDeptId,
  14270. t.behDeptName
  14271. FROM
  14272. (
  14273. SELECT DISTINCT
  14274. t1.hospital_id AS hospitalId,
  14275. t1.behospital_code AS behospitalCode,
  14276. t1.bed_code AS bedCode,
  14277. t1.LEVEL AS LEVEL,
  14278. t1.grade_type AS gradeType,
  14279. t1.score_res AS scoreRes,
  14280. t1.NAME AS NAME,
  14281. t1.sex AS sex,
  14282. t1.beh_dept_id AS behDeptId,
  14283. t1.beh_dept_name AS behDeptName,
  14284. t1.doctor_id AS doctorId,
  14285. t1.doctor_name AS doctorName,
  14286. t1.beh_doctor_id AS behDoctorId,
  14287. t1.beh_doctor_name AS behDoctorName,
  14288. t1.director_doctor_id AS directorDoctorId,
  14289. t1.director_doctor_name AS directorDoctorName,
  14290. t1.birthday AS birthday,
  14291. t1.behospital_date AS behospitalDate,
  14292. t1.leave_hospital_date AS leaveHospitalDate,
  14293. t1.placefile_date AS placefileDate,
  14294. t1.gmt_create AS gradeTime,
  14295. t1.diagnose,
  14296. t1.ward_name AS wardName,
  14297. t2.age,
  14298. t1.file_code AS fileCode,
  14299. t1.checkStatus,
  14300. t1.chName,
  14301. t1.chTime
  14302. FROM
  14303. (
  14304. SELECT
  14305. be.*,
  14306. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14307. mci.check_name AS chName,
  14308. mci.gmt_create AS chTime
  14309. FROM
  14310. (
  14311. SELECT DISTINCT
  14312. a.hospital_id,
  14313. a.behospital_code,
  14314. a.bed_code,
  14315. a.file_code,
  14316. b.LEVEL,
  14317. b.grade_type,
  14318. b.score_res,
  14319. a.NAME,
  14320. a.sex,
  14321. a.beh_dept_id,
  14322. a.beh_dept_name,
  14323. a.birthday,
  14324. a.behospital_date,
  14325. a.leave_hospital_date,
  14326. a.doctor_id,
  14327. a.doctor_name,
  14328. a.beh_doctor_id,
  14329. a.beh_doctor_name,
  14330. a.director_doctor_id,
  14331. a.director_doctor_name,
  14332. a.diagnose,
  14333. a.placefile_date,
  14334. a.ward_name,
  14335. b.gmt_create
  14336. FROM
  14337. med_behospital_info a,
  14338. med_qcresult_info b
  14339. WHERE
  14340. a.is_deleted = 'N'
  14341. AND b.is_deleted = 'N'
  14342. AND a.hospital_id = b.hospital_id
  14343. AND a.behospital_code = b.behospital_code
  14344. AND a.qc_type_id != 0
  14345. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14346. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14347. </if>
  14348. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14349. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14350. </if>
  14351. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14352. <if test="qcResultShortPageVO.startDate != null ">
  14353. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14354. </if>
  14355. <if test="qcResultShortPageVO.endDate != null ">
  14356. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14357. </if>
  14358. </if>
  14359. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14360. <if test="qcResultShortPageVO.startDate != null ">
  14361. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14362. </if>
  14363. <if test="qcResultShortPageVO.endDate != null">
  14364. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14365. </if>
  14366. </if>
  14367. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14368. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14369. </if>
  14370. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14371. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14372. </if>
  14373. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14374. AND c.`level` = #{qcResultShortPageVO.level}
  14375. </if>
  14376. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14377. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14378. </if>
  14379. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14380. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14381. </if>
  14382. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14383. AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14384. OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
  14385. OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
  14386. </if>
  14387. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14388. AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14389. OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
  14390. OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
  14391. </if>
  14392. ) be
  14393. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14394. AND mci.check_type in(0,2)
  14395. AND be.hospital_id = mci.hospital_id
  14396. AND be.behospital_code = mci.behospital_code
  14397. ) t1
  14398. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14399. AND t1.behospital_code = t2.behospital_code
  14400. AND t2.is_deleted = 'N'
  14401. ) t
  14402. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14403. AND t.hospitalId = qi.hospital_id
  14404. AND t.behospitalCode = qi.behospital_code
  14405. where 1=1
  14406. <if test="qcResultShortPageVO.checkStatus != null">
  14407. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14408. </if>
  14409. <if test="qcResultShortPageVO.mrStatus != null">
  14410. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14411. </if>
  14412. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14413. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14414. </if>
  14415. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14416. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14417. </if>
  14418. <if test="qcResultShortPageVO.chTimeStart != null ">
  14419. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14420. </if>
  14421. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14422. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14423. </if>
  14424. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14425. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14426. </if>
  14427. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14428. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14429. </if>
  14430. GROUP BY
  14431. t.behDeptId,
  14432. t.behDeptName
  14433. )f2
  14434. WHERE
  14435. f1.behDeptId = f2.behDeptId
  14436. AND f1.behDeptName = f2.behDeptName
  14437. </select>
  14438. <!-- 质控核查质控评分页导出 -科室-->
  14439. <select id="qcCheckMRPageExportByDept" resultMap="ExportExcelMapByDept">
  14440. SELECT
  14441. f1.behDeptId,
  14442. f1.behDeptName,
  14443. f1.doctorName,
  14444. f1.doctorId,
  14445. f1.patName,
  14446. f1.behospitalCode,
  14447. f1.hospitalId,
  14448. f1.behospitalDate,
  14449. f1.leaveHospitalDate,
  14450. f1.score,
  14451. f1.scoreBn,
  14452. f2.avgScore,
  14453. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14454. f1.msg,
  14455. f1.caseName,
  14456. </if>
  14457. f1.medoupName,
  14458. f1.wardName,
  14459. f1.checkStatus,
  14460. f1.mrStatus,
  14461. f1.chName,
  14462. f1.mrName,
  14463. f1.chTime,
  14464. f1.mrTime
  14465. FROM
  14466. (SELECT
  14467. t.doctorName,
  14468. t.doctorId,
  14469. t.`name` AS patName,
  14470. t.behospitalCode AS behospitalCode,
  14471. t.behospitalDate AS behospitalDate,
  14472. t.leaveHospitalDate AS leaveHospitalDate,
  14473. qi.score_res AS score,
  14474. t.scoreBn,
  14475. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14476. qd.msg AS msg,
  14477. qc.NAME AS caseName,
  14478. </if>
  14479. t.behDeptId,
  14480. t.behDeptName,
  14481. t.wardName,
  14482. t.hospitalId,
  14483. t.checkStatus,
  14484. t.mrStatus,
  14485. t.chName,
  14486. t.mrName,
  14487. t.chTime,
  14488. t.mrTime,
  14489. t3.name as medoupName
  14490. FROM
  14491. (
  14492. SELECT DISTINCT
  14493. t1.hospital_id AS hospitalId,
  14494. t1.behospital_code AS behospitalCode,
  14495. t1.bed_code AS bedCode,
  14496. t1.LEVEL AS LEVEL,
  14497. t1.grade_type AS gradeType,
  14498. t1.score_res AS scoreRes,
  14499. t1.scoreBn,
  14500. t1.NAME AS NAME,
  14501. t1.sex AS sex,
  14502. t1.beh_dept_id AS behDeptId,
  14503. t1.beh_dept_name AS behDeptName,
  14504. t1.doctor_id AS doctorId,
  14505. t1.doctor_name AS doctorName,
  14506. t1.beh_doctor_id AS behDoctorId,
  14507. t1.beh_doctor_name AS behDoctorName,
  14508. t1.director_doctor_id AS directorDoctorId,
  14509. t1.director_doctor_name AS directorDoctorName,
  14510. t1.birthday AS birthday,
  14511. t1.behospital_date AS behospitalDate,
  14512. t1.leave_hospital_date AS leaveHospitalDate,
  14513. t1.placefile_date AS placefileDate,
  14514. t1.gmt_create AS gradeTime,
  14515. t1.diagnose,
  14516. t1.ward_name AS wardName,
  14517. t2.age,
  14518. t1.file_code AS fileCode,
  14519. t1.checkStatus,
  14520. t1.mrStatus,
  14521. t1.chName,
  14522. t1.mrName,
  14523. t1.chTime,
  14524. t1.mrTime
  14525. FROM
  14526. (
  14527. SELECT
  14528. be.*,
  14529. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14530. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14531. mci.check_name AS chName,
  14532. e.score_res as scoreBn,
  14533. hm_mci.check_name AS mrName,
  14534. mci.gmt_create AS chTime,
  14535. hm_mci.gmt_create AS mrTime
  14536. FROM
  14537. (
  14538. SELECT DISTINCT
  14539. a.hospital_id,
  14540. a.behospital_code,
  14541. a.bed_code,
  14542. a.file_code,
  14543. b.LEVEL,
  14544. b.grade_type,
  14545. b.score_res,
  14546. a.NAME,
  14547. a.sex,
  14548. a.beh_dept_id,
  14549. a.beh_dept_name,
  14550. a.birthday,
  14551. a.behospital_date,
  14552. a.leave_hospital_date,
  14553. a.doctor_id,
  14554. a.doctor_name,
  14555. a.beh_doctor_id,
  14556. a.beh_doctor_name,
  14557. a.director_doctor_id,
  14558. a.director_doctor_name,
  14559. a.diagnose,
  14560. a.placefile_date,
  14561. a.ward_name,
  14562. b.gmt_create
  14563. FROM
  14564. med_behospital_info a,
  14565. med_qcresult_info b,
  14566. sys_user_dept c
  14567. WHERE
  14568. a.is_deleted = 'N'
  14569. AND b.is_deleted = 'N'
  14570. AND c.is_deleted = 'N'
  14571. AND a.hospital_id = b.hospital_id
  14572. AND a.hospital_id = c.hospital_id
  14573. AND a.behospital_code = b.behospital_code
  14574. AND a.beh_dept_id = c.dept_id
  14575. AND a.qc_type_id != 0
  14576. <if test="qcResultShortPageVO.userId!=null">
  14577. AND c.user_id = #{qcResultShortPageVO.userId}
  14578. </if>
  14579. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14580. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14581. </if>
  14582. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14583. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14584. </if>
  14585. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14586. <if test="qcResultShortPageVO.startDate != null ">
  14587. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14588. </if>
  14589. <if test="qcResultShortPageVO.endDate != null ">
  14590. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14591. </if>
  14592. </if>
  14593. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14594. <if test="qcResultShortPageVO.startDate != null ">
  14595. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14596. </if>
  14597. <if test="qcResultShortPageVO.endDate != null">
  14598. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14599. </if>
  14600. </if>
  14601. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14602. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14603. </if>
  14604. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  14605. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  14606. </if>
  14607. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14608. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14609. </if>
  14610. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14611. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14612. </if>
  14613. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14614. AND c.`level` = #{qcResultShortPageVO.level}
  14615. </if>
  14616. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14617. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14618. </if>
  14619. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14620. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14621. </if>
  14622. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14623. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14624. </if>
  14625. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14626. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  14627. </if>
  14628. ) be
  14629. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14630. AND mci.check_type = 0
  14631. AND be.hospital_id = mci.hospital_id
  14632. AND be.behospital_code = mci.behospital_code
  14633. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14634. AND hm_mci.check_type = 1
  14635. AND be.hospital_id = hm_mci.hospital_id
  14636. AND be.behospital_code = hm_mci.behospital_code
  14637. LEFT JOIN med_qcresult_cases e
  14638. on be.behospital_code = e.behospital_code
  14639. and be.hospital_id = e.hospital_id
  14640. AND e.is_deleted = 'N'
  14641. and e.cases_id = 243
  14642. ) t1
  14643. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14644. AND t1.behospital_code = t2.behospital_code
  14645. AND t2.is_deleted = 'N'
  14646. ) t
  14647. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14648. AND t.hospitalId = qi.hospital_id
  14649. AND t.behospitalCode = qi.behospital_code
  14650. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  14651. AND t.hospitalId = t2.hospital_id
  14652. AND t2.is_deleted = 'N'
  14653. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  14654. AND t3.is_deleted = 'N'
  14655. <if test="qcResultShortPageVO.radioCheck !=null and qcResultShortPageVO.radioCheck == 1">
  14656. LEFT JOIN med_qcresult_detail qd ON qd.is_deleted = 'N'
  14657. AND t.hospitalId = qd.hospital_id
  14658. AND t.behospitalCode = qd.behospital_code
  14659. LEFT JOIN qc_cases qc ON qc.is_deleted = 'N'
  14660. AND qd.cases_id = qc.id
  14661. </if>
  14662. where 1=1
  14663. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  14664. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  14665. </if>
  14666. <if test="qcResultShortPageVO.checkStatus != null">
  14667. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14668. </if>
  14669. <if test="qcResultShortPageVO.mrStatus != null">
  14670. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14671. </if>
  14672. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14673. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14674. </if>
  14675. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14676. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14677. </if>
  14678. <if test="qcResultShortPageVO.chTimeStart != null ">
  14679. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14680. </if>
  14681. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14682. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14683. </if>
  14684. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14685. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14686. </if>
  14687. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14688. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14689. </if>
  14690. )f1,
  14691. (SELECT
  14692. ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
  14693. t.behDeptId,
  14694. t.behDeptName,
  14695. t.doctorId,
  14696. t.doctorName
  14697. FROM
  14698. (
  14699. SELECT DISTINCT
  14700. t1.hospital_id AS hospitalId,
  14701. t1.behospital_code AS behospitalCode,
  14702. t1.bed_code AS bedCode,
  14703. t1.LEVEL AS LEVEL,
  14704. t1.grade_type AS gradeType,
  14705. t1.score_res AS scoreRes,
  14706. t1.NAME AS NAME,
  14707. t1.sex AS sex,
  14708. t1.beh_dept_id AS behDeptId,
  14709. t1.beh_dept_name AS behDeptName,
  14710. t1.doctor_id AS doctorId,
  14711. t1.doctor_name AS doctorName,
  14712. t1.beh_doctor_id AS behDoctorId,
  14713. t1.beh_doctor_name AS behDoctorName,
  14714. t1.director_doctor_id AS directorDoctorId,
  14715. t1.director_doctor_name AS directorDoctorName,
  14716. t1.birthday AS birthday,
  14717. t1.behospital_date AS behospitalDate,
  14718. t1.leave_hospital_date AS leaveHospitalDate,
  14719. t1.placefile_date AS placefileDate,
  14720. t1.gmt_create AS gradeTime,
  14721. t1.diagnose,
  14722. t1.ward_name AS wardName,
  14723. t2.age,
  14724. t1.file_code AS fileCode,
  14725. t1.checkStatus,
  14726. t1.mrStatus,
  14727. t1.chName,
  14728. t1.mrName,
  14729. t1.chTime,
  14730. t1.mrTime
  14731. FROM
  14732. (
  14733. SELECT
  14734. be.*,
  14735. ifnull( mci.STATUS, 0 ) AS checkStatus,
  14736. ifnull( hm_mci.STATUS, 0 ) AS mrStatus,
  14737. mci.check_name AS chName,
  14738. hm_mci.check_name AS mrName,
  14739. mci.gmt_create AS chTime,
  14740. hm_mci.gmt_create AS mrTime
  14741. FROM
  14742. (
  14743. SELECT DISTINCT
  14744. a.hospital_id,
  14745. a.behospital_code,
  14746. a.bed_code,
  14747. a.file_code,
  14748. b.LEVEL,
  14749. b.grade_type,
  14750. b.score_res,
  14751. a.NAME,
  14752. a.sex,
  14753. a.beh_dept_id,
  14754. a.beh_dept_name,
  14755. a.birthday,
  14756. a.behospital_date,
  14757. a.leave_hospital_date,
  14758. a.doctor_id,
  14759. a.doctor_name,
  14760. a.beh_doctor_id,
  14761. a.beh_doctor_name,
  14762. a.director_doctor_id,
  14763. a.director_doctor_name,
  14764. a.diagnose,
  14765. a.placefile_date,
  14766. a.ward_name,
  14767. b.gmt_create
  14768. FROM
  14769. med_behospital_info a,
  14770. med_qcresult_info b,
  14771. sys_user_dept c
  14772. WHERE
  14773. a.is_deleted = 'N'
  14774. AND b.is_deleted = 'N'
  14775. AND c.is_deleted = 'N'
  14776. AND a.hospital_id = b.hospital_id
  14777. AND a.hospital_id = c.hospital_id
  14778. AND a.behospital_code = b.behospital_code
  14779. AND a.beh_dept_id = c.dept_id
  14780. AND a.qc_type_id != 0
  14781. <if test="qcResultShortPageVO.userId!=null">
  14782. AND c.user_id = #{qcResultShortPageVO.userId}
  14783. </if>
  14784. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
  14785. and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
  14786. </if>
  14787. <if test="qcResultShortPageVO.wardName != null and qcResultShortPageVO.wardName != ''">
  14788. and a.ward_name LIKE CONCAT( '%', #{qcResultShortPageVO.wardName}, '%' )
  14789. </if>
  14790. <if test="qcResultShortPageVO.hospitalId != null and qcResultShortPageVO.hospitalId != ''">
  14791. AND a.hospital_id = #{qcResultShortPageVO.hospitalId}
  14792. </if>
  14793. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 0">
  14794. <if test="qcResultShortPageVO.startDate != null ">
  14795. <![CDATA[ AND a.behospital_date >= #{qcResultShortPageVO.startDate}]]>
  14796. </if>
  14797. <if test="qcResultShortPageVO.endDate != null ">
  14798. <![CDATA[ AND a.behospital_date <= #{qcResultShortPageVO.endDate}]]>
  14799. </if>
  14800. </if>
  14801. <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile == 1">
  14802. <if test="qcResultShortPageVO.startDate != null ">
  14803. <![CDATA[ AND a.leave_hospital_date >= #{qcResultShortPageVO.startDate}]]>
  14804. </if>
  14805. <if test="qcResultShortPageVO.endDate != null">
  14806. <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
  14807. </if>
  14808. </if>
  14809. <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
  14810. AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
  14811. </if>
  14812. <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
  14813. AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
  14814. </if>
  14815. <if test="qcResultShortPageVO.deptId != null and qcResultShortPageVO.deptId != ''">
  14816. AND a.beh_dept_id = #{qcResultShortPageVO.deptId}
  14817. </if>
  14818. <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
  14819. AND c.`level` = #{qcResultShortPageVO.level}
  14820. </if>
  14821. <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
  14822. AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
  14823. </if>
  14824. <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
  14825. AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
  14826. </if>
  14827. <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
  14828. AND a.doctor_id = #{qcResultShortPageVO.doctorId}
  14829. </if>
  14830. <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
  14831. AND a.doctor_name = #{qcResultShortPageVO.doctorName}
  14832. </if>
  14833. ) be
  14834. LEFT JOIN med_check_info mci ON mci.is_deleted = 'N'
  14835. AND mci.check_type = 0
  14836. AND be.hospital_id = mci.hospital_id
  14837. AND be.behospital_code = mci.behospital_code
  14838. LEFT JOIN med_check_info hm_mci ON hm_mci.is_deleted = 'N'
  14839. AND hm_mci.check_type = 1
  14840. AND be.hospital_id = hm_mci.hospital_id
  14841. AND be.behospital_code = hm_mci.behospital_code
  14842. ) t1
  14843. LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
  14844. AND t1.behospital_code = t2.behospital_code
  14845. AND t2.is_deleted = 'N'
  14846. ) t
  14847. LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
  14848. AND t.hospitalId = qi.hospital_id
  14849. AND t.behospitalCode = qi.behospital_code
  14850. LEFT JOIN bas_doctor_info t2 ON t.doctorId = t2.doctor_id
  14851. AND t.hospitalId = t2.hospital_id
  14852. AND t2.is_deleted = 'N'
  14853. LEFT JOIN sys_medoup t3 ON t2.group_id = t3.`code`
  14854. AND t3.is_deleted = 'N'
  14855. where 1=1
  14856. <if test="qcResultShortPageVO.medoupName != null and qcResultShortPageVO.medoupName != ''">
  14857. AND t3.name LIKE CONCAT( '%', #{qcResultShortPageVO.medoupName}, '%' )
  14858. </if>
  14859. <if test="qcResultShortPageVO.checkStatus != null">
  14860. AND t.checkStatus = #{qcResultShortPageVO.checkStatus}
  14861. </if>
  14862. <if test="qcResultShortPageVO.mrStatus != null">
  14863. AND t.mrStatus = #{qcResultShortPageVO.mrStatus}
  14864. </if>
  14865. <if test="qcResultShortPageVO.chName != null and qcResultShortPageVO.chName!=''">
  14866. AND t.chName like concat('%', #{qcResultShortPageVO.chName}, '%')
  14867. </if>
  14868. <if test="qcResultShortPageVO.mrName != null and qcResultShortPageVO.mrName!=''">
  14869. AND t.mrName like concat('%', #{qcResultShortPageVO.mrName}, '%')
  14870. </if>
  14871. <if test="qcResultShortPageVO.chTimeStart != null ">
  14872. <![CDATA[ AND t.chTime >= #{qcResultShortPageVO.chTimeStart}]]>
  14873. </if>
  14874. <if test="qcResultShortPageVO.chTimeEnd != null ">
  14875. <![CDATA[ AND t.chTime <= #{qcResultShortPageVO.chTimeEnd}]]>
  14876. </if>
  14877. <if test="qcResultShortPageVO.mrTimeStart != null ">
  14878. <![CDATA[ AND t.mrTime >= #{qcResultShortPageVO.mrTimeStart}]]>
  14879. </if>
  14880. <if test="qcResultShortPageVO.mrTimeEnd != null ">
  14881. <![CDATA[ AND t.mrTime <= #{qcResultShortPageVO.mrTimeEnd}]]>
  14882. </if>
  14883. GROUP BY
  14884. t.doctorId,
  14885. t.doctorName
  14886. )f2
  14887. WHERE
  14888. f1.doctorId = f2.doctorId
  14889. AND f1.doctorName = f2.doctorName
  14890. </select>
  14891. <!-- 入院,手术,出院病案情况-->
  14892. <select id="medicalRecordIndicator" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  14893. SELECT
  14894. count(
  14895. DISTINCT
  14896. CASE
  14897. WHEN q.type=5 THEN
  14898. a.behospital_code
  14899. ELSE
  14900. NULL
  14901. END
  14902. ) AS 'operationNote',
  14903. count(
  14904. DISTINCT
  14905. CASE
  14906. WHEN q.type = 4 THEN
  14907. a.behospital_code
  14908. ELSE
  14909. NULL
  14910. END
  14911. ) AS 'residentAdmitNote',
  14912. count(
  14913. DISTINCT
  14914. CASE
  14915. WHEN q.type = 6 THEN
  14916. a.behospital_code
  14917. ELSE
  14918. NULL
  14919. END
  14920. ) AS 'dischargeRecord',
  14921. count(
  14922. DISTINCT
  14923. CASE
  14924. WHEN q.type = 7 THEN
  14925. a.behospital_code
  14926. ELSE
  14927. NULL
  14928. END
  14929. ) AS 'medicalRecord'
  14930. FROM
  14931. (
  14932. SELECT
  14933. a.behospital_code,
  14934. a.cases_entry_id,
  14935. a.hospital_id
  14936. FROM
  14937. (
  14938. SELECT
  14939. a.behospital_code,
  14940. c.cases_entry_id,
  14941. a.hospital_id
  14942. FROM
  14943. (
  14944. SELECT
  14945. a.behospital_code,
  14946. a.hospital_id
  14947. FROM
  14948. med_behospital_info a,
  14949. med_qcresult_info c
  14950. WHERE
  14951. a.is_deleted = 'N'
  14952. AND c.is_deleted = 'N'
  14953. AND a.is_placefile = #{filterVO.isPlacefile}
  14954. <if test="filterVO.startDate != null and filterVO.endDate != null">
  14955. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  14956. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  14957. </if>
  14958. <![CDATA[ and a.qc_type_id <>'0' ]]>
  14959. AND a.behospital_code = c.behospital_code
  14960. AND a.hospital_id = #{filterVO.hospitalId}
  14961. AND a.hospital_id = c.hospital_id
  14962. ) a
  14963. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  14964. AND a.behospital_code = c.behospital_code
  14965. AND a.hospital_id = c.hospital_id
  14966. ) a
  14967. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  14968. AND d.is_deleted = 'N'
  14969. ) a
  14970. LEFT JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  14971. AND a.hospital_id = q.hospital_id
  14972. </select>
  14973. <!-- 时间段出院,住院, 手术费,抗菌药物,手术和病理费等含有人数 -->
  14974. <select id="selectOperationNum" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  14975. select
  14976. d.behospital_code behospitalCode,
  14977. b.operation_fee operationFee,
  14978. b.pathology_fee pathologyFee,
  14979. b.antibiosis_fee antibiosisFee
  14980. FROM
  14981. (
  14982. SELECT
  14983. a.behospital_code,
  14984. a.hospital_id,
  14985. a.behospital_date,
  14986. a.leave_hospital_date
  14987. FROM
  14988. med_behospital_info a,
  14989. med_qcresult_info c
  14990. WHERE
  14991. a.is_deleted = 'N'
  14992. AND c.is_deleted = 'N'
  14993. AND a.is_placefile = #{filterVO.isPlacefile}
  14994. <if test="filterVO.startDate != null and filterVO.endDate != null">
  14995. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  14996. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  14997. </if>
  14998. <![CDATA[ and a.qc_type_id <>'0' ]]>
  14999. AND a.hospital_id = c.hospital_id
  15000. AND a.hospital_id = #{filterVO.hospitalId}
  15001. and a.behospital_code = c.behospital_code
  15002. ) d
  15003. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  15004. AND d.hospital_id = b.hospital_id
  15005. AND b.is_deleted = 'N'
  15006. </select>
  15007. <!-- 关于触发规则不符合人数-->
  15008. <select id="triggeringRules" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  15009. SELECT
  15010. count(
  15011. DISTINCT
  15012. CASE
  15013. WHEN a.type=5 THEN
  15014. a.behospital_code
  15015. ELSE
  15016. NULL
  15017. END
  15018. ) AS 'operationNote',
  15019. count(
  15020. DISTINCT
  15021. CASE
  15022. WHEN a.type = 4 THEN
  15023. a.behospital_code
  15024. ELSE
  15025. NULL
  15026. END
  15027. ) AS 'residentAdmitNote',
  15028. count(
  15029. DISTINCT
  15030. CASE
  15031. WHEN a.type = 6 THEN
  15032. a.behospital_code
  15033. ELSE
  15034. NULL
  15035. END
  15036. ) AS 'dischargeRecord',
  15037. count(
  15038. DISTINCT
  15039. CASE
  15040. WHEN a.type = 7 THEN
  15041. a.behospital_code
  15042. ELSE
  15043. NULL
  15044. END
  15045. ) AS 'medicalRecord',
  15046. count(
  15047. DISTINCT
  15048. CASE
  15049. WHEN a.type=8 THEN
  15050. a.behospital_code
  15051. ELSE
  15052. NULL
  15053. END
  15054. ) AS 'CT',
  15055. count(
  15056. DISTINCT
  15057. CASE
  15058. WHEN a.type = 9 THEN
  15059. a.behospital_code
  15060. ELSE
  15061. NULL
  15062. END
  15063. ) AS 'MR',
  15064. count(
  15065. DISTINCT
  15066. CASE
  15067. WHEN a.type = 10 THEN
  15068. a.behospital_code
  15069. ELSE
  15070. NULL
  15071. END
  15072. ) AS 'operationPathologyFee',
  15073. count(
  15074. DISTINCT
  15075. CASE
  15076. WHEN a.type = 11 THEN
  15077. a.behospital_code
  15078. ELSE
  15079. NULL
  15080. END
  15081. ) AS 'bacterialCulture',
  15082. count(
  15083. DISTINCT
  15084. CASE
  15085. WHEN a.type = 12 THEN
  15086. a.behospital_code
  15087. ELSE
  15088. NULL
  15089. END
  15090. ) AS 'antibiosis',
  15091. count(
  15092. DISTINCT
  15093. CASE
  15094. WHEN a.type = 13 THEN
  15095. a.behospital_code
  15096. ELSE
  15097. NULL
  15098. END
  15099. ) AS 'chemotherapyMalignantTumors',
  15100. count(
  15101. DISTINCT
  15102. CASE
  15103. WHEN a.type = 15 THEN
  15104. a.behospital_code
  15105. ELSE
  15106. NULL
  15107. END
  15108. ) AS 'operationRecordNum',
  15109. count(
  15110. DISTINCT
  15111. CASE
  15112. WHEN a.type = 17 THEN
  15113. a.behospital_code
  15114. ELSE
  15115. NULL
  15116. END
  15117. ) AS 'bloodNum',
  15118. count(
  15119. DISTINCT
  15120. CASE
  15121. WHEN a.type = 18 THEN
  15122. a.behospital_code
  15123. ELSE
  15124. NULL
  15125. END
  15126. ) AS 'WardRoundNum',
  15127. count(
  15128. DISTINCT
  15129. CASE
  15130. WHEN a.type = 19 THEN
  15131. a.behospital_code
  15132. ELSE
  15133. NULL
  15134. END
  15135. ) AS 'rescueNum',
  15136. count(
  15137. DISTINCT
  15138. CASE
  15139. WHEN a.type = 22 THEN
  15140. a.behospital_code
  15141. ELSE
  15142. NULL
  15143. END
  15144. ) AS 'unreasonedCopyNum',
  15145. count(
  15146. DISTINCT
  15147. CASE
  15148. WHEN a.type = 14 THEN
  15149. a.behospital_code
  15150. ELSE
  15151. NULL
  15152. END
  15153. ) AS 'tumorRadiationNum',
  15154. count(
  15155. DISTINCT
  15156. CASE
  15157. WHEN a.type = 16 THEN
  15158. a.behospital_code
  15159. ELSE
  15160. NULL
  15161. END
  15162. ) AS 'implantsNum',
  15163. count(
  15164. DISTINCT
  15165. CASE
  15166. WHEN a.type = 23 THEN
  15167. a.behospital_code
  15168. ELSE
  15169. NULL
  15170. END
  15171. ) AS 'InformedNum'
  15172. FROM
  15173. (
  15174. SELECT
  15175. a.behospital_code,
  15176. a.hospital_id,
  15177. q.type
  15178. FROM
  15179. (
  15180. SELECT
  15181. a.behospital_code,
  15182. a.cases_entry_id,
  15183. a.hospital_id
  15184. FROM
  15185. (
  15186. SELECT
  15187. a.behospital_code,
  15188. c.cases_entry_id,
  15189. a.hospital_id
  15190. FROM
  15191. (
  15192. SELECT
  15193. a.behospital_code,
  15194. a.hospital_id
  15195. FROM
  15196. med_behospital_info a,
  15197. med_qcresult_info c
  15198. WHERE
  15199. a.is_deleted = 'N'
  15200. AND c.is_deleted = 'N'
  15201. AND a.is_placefile = #{filterVO.isPlacefile}
  15202. <if test="filterVO.startDate != null and filterVO.endDate != null">
  15203. <![CDATA[ and a.leave_hospital_date >= #{filterVO.startDate}]]>
  15204. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  15205. </if>
  15206. AND a.behospital_code = c.behospital_code
  15207. AND a.hospital_id = #{filterVO.hospitalId}
  15208. AND a.hospital_id = c.hospital_id
  15209. ) a
  15210. LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
  15211. AND a.behospital_code = c.behospital_code
  15212. AND a.hospital_id = c.hospital_id
  15213. ) a
  15214. JOIN qc_cases_entry d ON d.id = a.cases_entry_id
  15215. AND d.is_deleted = 'N'
  15216. ) a
  15217. JOIN qc_cases_relevance_entry q ON a.cases_entry_id = q.relevance_id
  15218. AND a.hospital_id = q.hospital_id
  15219. ) a
  15220. JOIN med_index_relevance r ON r.behospital_code = a.behospital_code
  15221. AND r.relevance_type = a.type
  15222. AND r.is_deleted = 'N'
  15223. AND a.hospital_id = r.hospital_id
  15224. </select>
  15225. <!-- 跟病案首页关联的出院病历-->
  15226. <select id="getMedicalRecords" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  15227. SELECT
  15228. d.behospital_code,
  15229. d.behospital_date,
  15230. d.leave_hospital_date,
  15231. b.behospital_code AS b_code,
  15232. b.operation_fee,
  15233. b.antibiosis_fee,
  15234. b.pathology_fee
  15235. FROM
  15236. (
  15237. SELECT
  15238. a.behospital_code,
  15239. a.hospital_id,
  15240. a.behospital_date,
  15241. a.leave_hospital_date
  15242. FROM
  15243. med_behospital_info a,
  15244. med_qcresult_info c
  15245. WHERE
  15246. a.behospital_code = c.behospital_code
  15247. AND a.hospital_id = #{filterVO.hospitalId}
  15248. AND a.is_placefile = #{filterVO.isPlacefile}
  15249. AND a.hospital_id = c.hospital_id
  15250. AND a.is_deleted = 'N'
  15251. AND c.is_deleted = 'N'
  15252. <![CDATA[ and a.qc_type_id <>'0' ]]>
  15253. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  15254. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  15255. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  15256. </if>
  15257. ) d
  15258. LEFT JOIN med_home_page b ON b.behospital_code = d.behospital_code
  15259. AND d.hospital_id = b.hospital_id
  15260. AND b.is_deleted = 'N'
  15261. where ISNULL(b.behospital_code)
  15262. </select>
  15263. <!-- 首页恶性肿瘤-->
  15264. <select id="malignancy" parameterType="com.diagbot.vo.FilterVO" resultType="java.util.Map">
  15265. select
  15266. a.behospital_code,
  15267. a.hospital_id,
  15268. d.diagnose_name,
  15269. d.diagnose_type,
  15270. d.icd_code
  15271. from(
  15272. SELECT
  15273. d.behospital_code,
  15274. d.hospital_id,
  15275. b.home_page_id
  15276. FROM
  15277. (
  15278. SELECT
  15279. a.behospital_code,
  15280. a.hospital_id,
  15281. a.behospital_date,
  15282. a.leave_hospital_date
  15283. FROM
  15284. med_behospital_info a,
  15285. med_qcresult_info c
  15286. WHERE
  15287. a.behospital_code = c.behospital_code
  15288. AND a.hospital_id = #{filterVO.hospitalId}
  15289. AND a.is_placefile = #{filterVO.isPlacefile}
  15290. AND a.hospital_id = c.hospital_id
  15291. AND a.is_deleted = 'N'
  15292. AND c.is_deleted = 'N'
  15293. <![CDATA[ and a.qc_type_id <>'0' ]]>
  15294. <if test="filterVO.startDate != null and filterVO.endDate != null ">
  15295. <![CDATA[ AND a.leave_hospital_date >= #{filterVO.startDate}]]>
  15296. <![CDATA[ AND a.leave_hospital_date <= #{filterVO.endDate}]]>
  15297. </if>
  15298. ) d
  15299. JOIN med_home_page b ON b.behospital_code = d.behospital_code
  15300. AND d.hospital_id = b.hospital_id
  15301. AND b.is_deleted = 'N'
  15302. )a join
  15303. med_home_diagnose_info d on a.hospital_id=d.hospital_id
  15304. where a.home_page_id =d.home_page_id
  15305. and d.is_deleted ='N'
  15306. and d.diagnose_name like '%恶性肿瘤%'
  15307. and d.icd_code like 'C%'
  15308. </select>
  15309. </mapper>