123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676 |
- package controllers
-
- import (
- "encoding/json"
- "fmt"
- "reflect"
- "strconv"
- "strings"
- "time"
-
- "XT_New/enums"
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "github.com/jinzhu/gorm"
-
- "github.com/astaxie/beego"
- )
-
- type ScheduleApiController struct {
- BaseAuthAPIController
- }
-
- func ScheduleApiRegistRouters() {
- beego.Router("/api/schedule/weekpanel", &ScheduleApiController{}, "Get:GetWeekPanels")
-
- beego.Router("/api/schedule/schedules", &ScheduleApiController{}, "Get:GetSchedules")
- beego.Router("/api/excel_date/init", &ScheduleApiController{}, "Get:GetInitExcelInitDate")
-
- beego.Router("/api/schedule/patients", &ScheduleApiController{}, "Get:GetPatients")
- beego.Router("/api/schedule/create", &ScheduleApiController{}, "Post:CreateSchedule")
- beego.Router("/api/schedule/delete", &ScheduleApiController{}, "Delete:DeleteSchedule")
- beego.Router("/api/schedule/change", &ScheduleApiController{}, "Put:ChangeSchedule")
- beego.Router("/api/schedule/urgentinit", &ScheduleApiController{}, "Get:UrgentScheduleData")
- beego.Router("/api/schedule/print/initdata", &ScheduleApiController{}, "get:PrintInitData")
- beego.Router("/api/schedule/search", &ScheduleApiController{}, "get:SearchSchedulePatients")
- beego.Router("/api/schedule/week", &ScheduleApiController{}, "get:GetWeekDaySchedule")
- beego.Router("/api/schedule/export", &ScheduleApiController{}, "post:ExportSchedule")
- beego.Router("/api/schedule_template/export", &ScheduleApiController{}, "post:ExportScheduleTemplate")
- beego.Router("/api/schedule_template/search", &ScheduleApiController{}, "get:SearchTemplateSchedulePatients")
- beego.Router("/api/schedule_template/cancel", &ScheduleApiController{}, "post:CancelScheduleTemplate")
- beego.Router("/api/schedule/getnextscheduleweekday", &ScheduleApiController{}, "Get:GetNextWeekDaySchedule")
- beego.Router("/api/schedule/getnextscheduleweekdayone", &ScheduleApiController{}, "Get:GetNextWeekDayScheduleOne")
-
- beego.Router("/api/schedule/getthreeweeklist", &ScheduleApiController{}, "Get:GetThreeWeekList")
-
- beego.Router("/api/schedule/getallzones", &ScheduleApiController{}, "Get:GetAllZones")
-
- beego.Router("/api/schedule/copypatientschedules", &ScheduleApiController{}, "Get:GetCopyPatientSchedules")
-
- beego.Router("/api/schedule/saveremindprint", &ScheduleApiController{}, "Get:SaveRemindPrint")
-
- beego.Router("/api/schedule/getremindprintlist", &ScheduleApiController{}, "Get:GetRemindPrintList")
-
- beego.Router("/api/schedule/getbloodschedulelist", &ScheduleApiController{}, "Get:GetBloodScheduleList")
-
- beego.Router("/api/schedule/getprintlist", &ScheduleApiController{}, "Get:GetPrintList")
-
- beego.Router("/api/schedule/getallzonelist", &ScheduleApiController{}, "Get:GetAllZoneList")
-
- beego.Router("/api/schedule/getpatientschedulecount", &ScheduleApiController{}, "Get:GetPatientScheduleCount")
-
- beego.Router("/api/schedule/weekpanelone", &ScheduleApiController{}, "Get:GetWeekPanelsOne")
- beego.Router("/api/schedule/schedulesone", &ScheduleApiController{}, "Get:GetScheduleOne")
- beego.Router("/api/schedule/scheduletwo", &ScheduleApiController{}, "Get:GetScheduleTwo")
- beego.Router("/api/schedule/getschedulethreeone", &ScheduleApiController{}, "Get:GetScheduleThreeList")
- beego.Router("/api/schedule/postscheduletemplate", &ScheduleApiController{}, "Get:SaveScheduleTemplate")
- beego.Router("/api/schedule/getscheduletemplate", &ScheduleApiController{}, "Get:GetScheduleTemplate")
- beego.Router("/api/order/changefuncprint", &ScheduleApiController{}, "Get:ChangeFuncPrint")
- beego.Router("/api/order/getdataprint", &ScheduleApiController{}, "Get:GetDataPrint")
- beego.Router("/api/schedule/getnextweekpanels", &ScheduleApiController{}, "Get:GetNextWeekPanels")
- beego.Router("/api/schedule/synchroschedule", &ScheduleApiController{}, "Get:SynchroSchedule")
- beego.Router("/api/schedule/getpatientscheduletemplate", &ScheduleApiController{}, "Get:GetPatientScheduleTempalate")
- beego.Router("/api/schedule/getsolutionschedule", &ScheduleApiController{}, "Get:GetSolutionSchedule")
-
- beego.Router("/api/schedule/smartpatientsch", &ScheduleApiController{}, "Get:GetPatient")
- beego.Router("/api/schedule/smartpatientschtemplate", &ScheduleApiController{}, "Get:GetPatientSchTemplate")
-
- beego.Router("/api/patient/smartpatientsch", &ScheduleApiController{}, "Get:GetPatientSmartSch")
-
- beego.Router("/api/patient/smartpatientschtemplate", &ScheduleApiController{}, "Get:GetPatientSmartSchTemplate")
-
- beego.Router("/api/device/get", &ScheduleApiController{}, "Get:GetDevicesNumbers")
- beego.Router("/api/smartsch/batch", &ScheduleApiController{}, "Post:BatchPostSmartSch")
- beego.Router("/api/smartsch/get", &ScheduleApiController{}, "Get:GetSmartSch")
- beego.Router("/api/sch/exchange", &ScheduleApiController{}, "Get:ExchangeSch")
- beego.Router("/api/sch/coversch", &ScheduleApiController{}, "Get:CoverSch")
- beego.Router("/api/schedule/delete_two", &ScheduleApiController{}, "Delete:DeleteScheduleTwo")
-
- beego.Router("/api/schedule/create_two", &ScheduleApiController{}, "Post:CreateScheduleTwo")
-
- beego.Router("/api/schedule/changeschedule", &ScheduleApiController{}, "Put:ChangeScheduleTen")
-
- beego.Router("/api/schedule/getordernumber", &ScheduleApiController{}, "Get:GetNumberListById")
-
- }
- func (c *ScheduleApiController) CoverSch() {
- id_one, _ := c.GetInt64("id_one")
- id_two, _ := c.GetInt64("id_two")
- sch, _ := service.GetScheduleTen(c.GetAdminUserInfo().CurrentOrgId, id_one)
- orgId := c.GetAdminUserInfo().CurrentOrgId
- //针对凤凰医院
- if orgId == 10579 || orgId == 10344 || orgId == 10206 {
- advice, _ := service.GetDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, orgId)
- if len(advice) > 0 {
- service.UpdateAdviceObj(sch.PatientId, sch.ScheduleDate, orgId)
- }
- }
-
- if orgId == 10206 || orgId == 10344 {
- hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(sch.PatientId, sch.ScheduleDate, orgId)
- project, _ := service.GetHisPrescriptionProjectList(sch.PatientId, sch.ScheduleDate, orgId)
- if len(hisAdvice) > 0 {
- service.UpdateHisAdviceObj(sch.PatientId, sch.ScheduleDate, orgId)
- }
- if len(project) > 0 {
- service.UpdateProjectObj(sch.PatientId, sch.ScheduleDate, orgId)
- }
- }
- sch_two, _ := service.GetScheduleTen(c.GetAdminUserInfo().CurrentOrgId, id_two)
- //order, _ := service.GetDialysisOrder(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
- //if order.ID > 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderOne)
- // return
- //}
- order, _ := service.GetOneDialysisOrderOne(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
- if order.ID > 0 {
- scheduleObj, _ := service.GetPatientScheduleByPatientId(sch.PatientId, sch.UserOrgId, sch.ScheduleDate)
- service.UpdateDialysiOrderByPatientId(order.ID, scheduleObj.ScheduleType, scheduleObj.PartitionId, scheduleObj.BedId)
- redis := service.RedisClient()
- key := strconv.FormatInt(sch.UserOrgId, 10) + ":" + strconv.FormatInt(sch.PatientId, 10) + ":" + strconv.FormatInt(sch.ScheduleDate, 10) + ":dialysis_order"
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(sch.UserOrgId, 10) + ":" + strconv.FormatInt(sch.ScheduleDate, 10) + ":dialysis_orders_list_all"
-
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- }
-
- orderOne, _ := service.GetOneDialysisOrderOne(sch_two.ScheduleDate, sch_two.PatientId, sch_two.UserOrgId)
- if orderOne.ID > 0 {
- scheduleObj, _ := service.GetPatientScheduleByPatientId(sch_two.PatientId, sch_two.UserOrgId, sch_two.ScheduleDate)
- service.UpdateDialysiOrderByPatientId(order.ID, scheduleObj.ScheduleType, scheduleObj.PartitionId, scheduleObj.BedId)
- redis := service.RedisClient()
- key := strconv.FormatInt(sch_two.UserOrgId, 10) + ":" + strconv.FormatInt(sch_two.PatientId, 10) + ":" + strconv.FormatInt(sch_two.ScheduleDate, 10) + ":dialysis_order"
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(sch_two.UserOrgId, 10) + ":" + strconv.FormatInt(sch_two.ScheduleDate, 10) + ":dialysis_orders_list_all"
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- }
- //替换者和被替换的排班日期不是同一天,则进行一个患者一天不能有多个排班提醒
- if sch.ScheduleDate != sch_two.ScheduleDate && sch.PatientId != sch_two.PatientId {
- count, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId, sch_two.ScheduleDate, sch.PatientId)
- if count > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
- return
- }
- }
-
- var new_sch models.Schedule
- new_sch = sch
- new_sch.BedId = sch_two.BedId
- new_sch.ScheduleDate = sch_two.ScheduleDate
- new_sch.ScheduleWeek = sch_two.ScheduleWeek
- new_sch.PartitionId = sch_two.PartitionId
- new_sch.ScheduleType = sch_two.ScheduleType
- new_sch.ID = 0
- //删除原来的排班
- err := service.SaveSchTwo(sch, sch_two)
- //生成新的排班
- if err == nil {
- err2 := service.SaveSch(&new_sch)
- if err2 == nil {
- //去除当天患者排班中重复数据,保留最后一条数据
- service.UpdateRepeatSchStatus(sch.UserOrgId, sch.ScheduleDate)
- service.UpdateRepeatSchStatus(sch_two.UserOrgId, sch_two.ScheduleDate)
- service.UpdateRepeatSchStatus(new_sch.UserOrgId, new_sch.ScheduleDate)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "覆盖成功",
- "new_sch": new_sch,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
- func (c *ScheduleApiController) ExchangeSch() {
- id_one, _ := c.GetInt64("id_one")
- id_two, _ := c.GetInt64("id_two")
- sch, _ := service.GetSchedule(c.GetAdminUserInfo().CurrentOrgId, id_one)
- sch_two, _ := service.GetSchedule(c.GetAdminUserInfo().CurrentOrgId, id_two)
-
- //order2, _ := service.GetDialysisOrder(sch_two.ScheduleDate, sch_two.PatientId, sch_two.UserOrgId)
- //if order2.ID > 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderTwo)
- // return
- //}
-
- //替换者和被替换的排班日期不是同一天,则进行一个患者一天不能有多个排班提醒
- if sch.ScheduleDate != sch_two.ScheduleDate && sch.PatientId != sch_two.PatientId {
- count, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId, sch_two.ScheduleDate, sch.PatientId)
- if count > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
- return
- }
-
- count1, _ := service.GetScheduleCountByDate(c.GetAdminUserInfo().CurrentOrgId, sch.ScheduleDate, sch_two.PatientId)
- if count1 > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientScheduleRepeat)
- return
- }
- }
-
- err := service.UpdateScheduleThree(sch, sch_two)
-
- fmt.Println("id_one======================", sch.PatientId)
- fmt.Println("id_one======================", sch_two.PatientId)
- order, _ := service.GetOneDialysisOrderOne(sch.UserOrgId, sch.ScheduleDate, sch.PatientId)
- if order.ID > 0 {
- //查询该患者的排班机位
- pSchedule, _ := service.GetPscheduleDate(sch.ScheduleDate, sch.PatientId, sch.UserOrgId)
- service.UpdateDialysiOrderByPatientId(order.ID, pSchedule.ScheduleType, pSchedule.PartitionId, pSchedule.BedId)
- redis := service.RedisClient()
- key := strconv.FormatInt(sch.UserOrgId, 10) + ":" + strconv.FormatInt(sch.PatientId, 10) + ":" + strconv.FormatInt(sch.ScheduleDate, 10) + ":dialysis_order"
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(sch.UserOrgId, 10) + ":" + strconv.FormatInt(sch.ScheduleDate, 10) + ":dialysis_orders_list_all"
-
- //清空key 值
- redis.Set(keyOne, "", time.Second)
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderOne)
- //return
- }
-
- orderOne, _ := service.GetOneDialysisOrderOne(sch_two.UserOrgId, sch_two.ScheduleDate, sch_two.PatientId)
- if orderOne.ID > 0 {
- //查询该患者的排班机位
- pSchedule, _ := service.GetPscheduleDate(sch_two.ScheduleDate, sch_two.PatientId, sch_two.UserOrgId)
- service.UpdateDialysiOrderByPatientId(orderOne.ID, pSchedule.ScheduleType, pSchedule.PartitionId, pSchedule.BedId)
- redis := service.RedisClient()
- key := strconv.FormatInt(sch_two.UserOrgId, 10) + ":" + strconv.FormatInt(sch_two.PatientId, 10) + ":" + strconv.FormatInt(sch_two.ScheduleDate, 10) + ":dialysis_order"
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(sch_two.UserOrgId, 10) + ":" + strconv.FormatInt(sch_two.ScheduleDate, 10) + ":dialysis_orders_list_all"
-
- //清空key 值
- redis.Set(keyOne, "", time.Second)
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrderOne)
- //return
- }
- if err == nil {
-
- //去除当天患者排班中重复数据,保留最后一条数据
- service.UpdateRepeatSchStatus(sch.UserOrgId, sch.ScheduleDate)
- service.UpdateRepeatSchStatus(sch_two.UserOrgId, sch_two.ScheduleDate)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "交换成功",
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
- func (c *ScheduleApiController) BatchPostSmartSch() {
- patient_id, _ := c.GetInt64("patient_id")
- adminInfo := c.GetAdminUserInfo()
-
- patientInfo, _ := service.FindPatientById(adminInfo.CurrentOrgId, patient_id)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- //drugOutConfig, _ := service.FindDrugOutConfigById(adminInfo.CurrentOrgId)
- //
- //recordDateStr := time.Now().Format("2006-01-02")
- //
- //recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- //退库
- //if drugOutConfig.IsOpen == 1 {
- // hisAdvice, _ := service.GetPatientDrugCountToday(patient_id, recordDate.Unix(), adminInfo.CurrentOrgId)
- //
- // if len(hisAdvice) > 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorAdivceCode)
- // return
- // }
- //}
-
- //list, _ := service.GetPatientGoodCountToday(patient_id, recordDate.Unix(), adminInfo.CurrentOrgId)
- //if len(list) > 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorAdivceCode)
- // return
- //}
-
- //数据校验
- if dataBody["smart_schs"] != nil && reflect.TypeOf(dataBody["smart_schs"]).String() == "[]interface {}" {
- schs, _ := dataBody["smart_schs"].([]interface{})
- if len(schs) > 0 {
- for _, item := range schs {
- items := item.(map[string]interface{})
- if items["sch_id"] == nil || reflect.TypeOf(items["sch_id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var schedule models.Schedule
- //var oldSchedule *models.Schedule
- sch_id := int64(items["sch_id"].(float64))
- if sch_id > 0 { //修改排班信息
- schedule, _ = service.GetScheduleTwo(adminInfo.CurrentOrgId, sch_id)
-
- if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
- utils.ErrorLog("mode_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- modeId := int64(items["mode_id"].(float64))
- if modeId < 1 {
- utils.ErrorLog("modeId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ModeId = modeId
-
- order, err := service.GetOneDialysisOrder(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if order != nil {
- week_type, _ := items["week_type"].(string)
- week_name, _ := items["week_name"].(string)
-
- switch week_type {
- case "1":
- json := make(map[string]interface{})
- json["msg"] = "本周" + week_name + "的床位已经有人上机,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "2":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "的床位已经有人上机,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "3":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "的床位已经有人上机,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
-
- }
-
- return
- }
-
- if order != nil {
- week_type, _ := items["week_type"].(string)
- week_name, _ := items["week_name"].(string)
-
- switch week_type {
- case "1":
- json := make(map[string]interface{})
- json["msg"] = "本周" + week_name + "的床位已经有人上机,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "2":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "的床位已经有人上机,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "3":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "的床位已经有人上机,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- }
- return
- }
-
- if items["schedule_type"] == nil || reflect.TypeOf(items["schedule_type"]).String() != "float64" {
- utils.ErrorLog("schedule_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleType := int64(items["schedule_type"].(float64))
- if scheduleType < 1 || scheduleType > 3 {
- utils.ErrorLog("scheduleType < 3")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleType = scheduleType
-
- if items["bed_id"] == nil || reflect.TypeOf(items["bed_id"]).String() != "float64" {
- utils.ErrorLog("bed_id")
- fmt.Println("~~~~~~333333333")
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- bedId := int64(items["bed_id"].(float64))
- if bedId < 1 {
- utils.ErrorLog("bedId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.BedId = bedId
-
- if items["zone_id"] == nil || reflect.TypeOf(items["zone_id"]).String() != "float64" {
- utils.ErrorLog("zone_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- partitionId := int64(items["zone_id"].(float64))
- if partitionId < 1 {
- utils.ErrorLog("partitionId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.PartitionId = partitionId
-
- bed, _ := service.GetDeviceNumberByID(adminInfo.CurrentOrgId, schedule.BedId)
- if bed == nil {
-
- week_type, _ := items["week_type"].(string)
- week_name, _ := items["week_name"].(string)
-
- switch week_type {
- case "1":
- json := make(map[string]interface{})
- json["msg"] = "本周" + week_name + "的机号不存在,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "2":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "的机号不存在,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "3":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "的机号不存在,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- }
-
- return
- }
- if bed.ZoneID != schedule.PartitionId {
-
- week_type, _ := items["week_type"].(string)
- week_name, _ := items["week_name"].(string)
-
- switch week_type {
- case "1":
- json := make(map[string]interface{})
- json["msg"] = "本周" + week_name + "所选机号不在选择分区中,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "2":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "所选机号不在选择分区中,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "3":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "所选机号不在选择分区中,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- }
-
- return
- }
-
- startTime := schedule.ScheduleDate
- endTime := startTime + 86399
-
- //一天只有排班一次
- daySchedule, err := service.GetDaySchedule(adminInfo.CurrentOrgId, startTime, endTime, schedule.PatientId)
-
- if daySchedule.ID > 0 && daySchedule.ID != schedule.ID {
- week_type, _ := items["week_type"].(string)
- week_name, _ := items["week_name"].(string)
-
- switch week_type {
- case "1":
- json := make(map[string]interface{})
- json["msg"] = "本周" + week_name + "已有排班,同一天不可有两次排班,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "2":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "已有排班,同一天不可有两次排班,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "3":
- json := make(map[string]interface{})
- json["msg"] = "下下周" + week_name + "已有排班,同一天不可有两次排班,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- }
-
- return
- }
-
- //同天同位置只能排一个
- pointSchedule, err := service.GetPointSchedule(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if pointSchedule.ID > 0 && pointSchedule.PatientId != patient_id {
- week_type, _ := items["week_type"].(string)
- week_name, _ := items["week_name"].(string)
-
- switch week_type {
- case "1":
- json := make(map[string]interface{})
- json["msg"] = "本周" + week_name + "所先位置排班已经存在,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "2":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "所先位置排班已经存在,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "3":
- json := make(map[string]interface{})
- json["msg"] = "下下周" + week_name + "所先位置排班已经存在,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- }
-
- return
- }
-
- } else { //新的排班信息
-
- if items["schedule_date"] == nil || reflect.TypeOf(items["schedule_date"]).String() != "string" {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleDate, _ := items["schedule_date"].(string)
- if len(scheduleDate) == 0 {
- utils.ErrorLog("len(schedule_date) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleDate = theTime.Unix()
- //existSch,_ := service.GetScheduleByDate(c.GetAdminUserInfo().CurrentOrgId,schedule.ScheduleDate,patient_id)
- //
- //if existSch.ID > 0{
- // fmt.Println("555555555")
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- //
- //}
-
- timeNow := time.Now().Format("2006-01-02")
- if timeNow > scheduleDate {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
- return
- }
- scheduleType := int64(items["schedule_type"].(float64))
- if scheduleType < 1 || scheduleType > 3 {
- utils.ErrorLog("scheduleType < 3")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleType = scheduleType
-
- if items["bed_id"] == nil || reflect.TypeOf(items["bed_id"]).String() != "float64" {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- bedId := int64(items["bed_id"].(float64))
- if bedId < 1 {
- utils.ErrorLog("bedId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.BedId = bedId
-
- if items["zone_id"] == nil || reflect.TypeOf(items["zone_id"]).String() != "float64" {
- utils.ErrorLog("zone_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- partitionId := int64(items["zone_id"].(float64))
- if partitionId < 1 {
- utils.ErrorLog("zone_id < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.PartitionId = partitionId
-
- if items["schedule_week"] == nil || reflect.TypeOf(items["schedule_week"]).String() != "float64" {
- utils.ErrorLog("schedule_week")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleWeek := int64(items["schedule_week"].(float64))
- if scheduleWeek < 1 || scheduleWeek > 7 {
- utils.ErrorLog("scheduleWeek < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleWeek = scheduleWeek
-
- if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
- utils.ErrorLog("mode_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- modeId := int64(items["mode_id"].(float64))
- if modeId < 1 && modeId > 14 {
- utils.ErrorLog("modeId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- //校验当天改床位是否有排班,如果有排班则不能替换排班
-
- sch, _ := service.GetScheduleByZoneAndBed(adminInfo.CurrentOrgId, partitionId, bedId, schedule.ScheduleDate, schedule.ScheduleType)
-
- fmt.Println(sch.PatientId)
- fmt.Println(schedule.PatientId)
-
- if sch.ID > 0 && sch.PatientId != patient_id {
- week_type, _ := items["week_type"].(string)
- week_name, _ := items["week_name"].(string)
-
- switch week_type {
- case "1":
- json := make(map[string]interface{})
- json["msg"] = "本周" + week_name + "该床位已经有人排班,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "2":
- json := make(map[string]interface{})
- json["msg"] = "下周" + week_name + "该床位已经有人排班,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- case "3":
- json := make(map[string]interface{})
- json["msg"] = "下下周" + week_name + "该床位已经有人排班,无法保存"
- json["state"] = 0
- c.Data["json"] = json
- c.ServeJSON()
- break
- }
-
- return
- }
-
- //daySchedule, err := service.GetDaySchedule(adminInfo.CurrentOrgId, theTime.Unix(), theTime.Unix(), patient_id)
- //if daySchedule.ID > 0 && daySchedule.ID != schedule.ID {
- // week_type, _ := items["week_type"].(string)
- // week_name, _ := items["week_name"].(string)
- //
- // switch week_type {
- // case "1":
- // json := make(map[string]interface{})
- // json["msg"] = "本周" + week_name + "该床位已经有人排班,无法保存"
- // json["state"] = 0
- // c.Data["json"] = json
- // c.ServeJSON()
- // break
- // case "2":
- // json := make(map[string]interface{})
- // json["msg"] = "下周" + week_name + "当天该患者已经排班,无法保存"
- // json["state"] = 0
- // c.Data["json"] = json
- // c.ServeJSON()
- // break
- // case "3":
- // json := make(map[string]interface{})
- // json["msg"] = "下下周" + week_name + "当天该患者已经排班,无法保存"
- // json["state"] = 0
- // c.Data["json"] = json
- // c.ServeJSON()
- // break
- // }
- //
- // return
- //
- //
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
- // return
- //}
- //
- }
-
- }
- }
- }
- ////删除数据
- if dataBody["del_schs"] != nil && reflect.TypeOf(dataBody["del_schs"]).String() == "[]interface {}" {
-
- schs, _ := dataBody["del_schs"].([]interface{})
- if len(schs) > 0 {
- for _, item := range schs {
- items := item.(map[string]interface{})
- if items["sch_id"] == nil || reflect.TypeOf(items["sch_id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var schedule models.Schedule
- sch_id := int64(items["sch_id"].(float64))
- if sch_id > 0 { //修改排班信息
- schedule, _ = service.GetScheduleTwo(adminInfo.CurrentOrgId, sch_id)
-
- order, _ := service.GetDialysisOrderByPatientAndBed(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.BedId, schedule.PatientId)
- if order.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDelScheduleFailByDialysis)
- return
- }
-
- schedule.Status = 0
- //针对凤凰医院
- if adminInfo.CurrentOrgId == 10579 || adminInfo.CurrentOrgId == 10344 || adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10679 {
- advice, _ := service.GetDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
- if len(advice) > 0 {
- service.UpdateAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
- }
- }
-
- //if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
- // hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
- // project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
- // if len(hisAdvice) > 0 {
- // service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
- // }
- // if len(project) > 0 {
- // service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminInfo.CurrentOrgId)
- // }
- //}
- service.SaveSch(&schedule)
- }
- HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
- //去除当天患者排班中重复数据,保留最后一条数据
- service.UpdateRepeatSchStatus(adminInfo.CurrentOrgId, schedule.ScheduleDate)
-
- }
-
- }
-
- }
- ////修改或保存数据
- if dataBody["smart_schs"] != nil && reflect.TypeOf(dataBody["smart_schs"]).String() == "[]interface {}" {
-
- schs, _ := dataBody["smart_schs"].([]interface{})
- if len(schs) > 0 {
- for _, item := range schs {
- items := item.(map[string]interface{})
- if items["sch_id"] == nil || reflect.TypeOf(items["sch_id"]).String() != "float64" {
- utils.ErrorLog("id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- var schedule models.Schedule
- //var oldSchedule *models.Schedule
- sch_id := int64(items["sch_id"].(float64))
- if sch_id > 0 { //修改排班信息
- fmt.Println("!!!!!!!")
- schedule, _ = service.GetScheduleTwo(adminInfo.CurrentOrgId, sch_id)
- if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
- fmt.Println(reflect.TypeOf(items["mode_id"]))
-
- utils.ErrorLog("mode_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- modeId := int64(items["mode_id"].(float64))
- if modeId < 1 {
- utils.ErrorLog("modeId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ModeId = modeId
-
- order, err := service.GetOneDialysisOrder(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if order != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeMode)
- return
- }
-
- if order != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeDeviceNumber)
- return
- }
-
- if items["schedule_type"] == nil || reflect.TypeOf(items["schedule_type"]).String() != "float64" {
- utils.ErrorLog("schedule_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleType := int64(items["schedule_type"].(float64))
- if scheduleType < 1 || scheduleType > 3 {
- utils.ErrorLog("scheduleType < 3")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleType = scheduleType
-
- if items["bed_id"] == nil || reflect.TypeOf(items["bed_id"]).String() != "float64" {
- utils.ErrorLog("bed_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- bedId := int64(items["bed_id"].(float64))
- if bedId < 1 {
- utils.ErrorLog("bedId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.BedId = bedId
-
- if items["zone_id"] == nil || reflect.TypeOf(items["zone_id"]).String() != "float64" {
- utils.ErrorLog("zone_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- partitionId := int64(items["zone_id"].(float64))
- if partitionId < 1 {
- utils.ErrorLog("partitionId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.PartitionId = partitionId
-
- bed, _ := service.GetDeviceNumberByID(adminInfo.CurrentOrgId, schedule.BedId)
- if bed == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
- return
- }
- if bed.ZoneID != schedule.PartitionId {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
- return
- }
-
- startTime := schedule.ScheduleDate
- endTime := startTime + 86399
-
- //一天只有排班一次
- daySchedule, err := service.GetDaySchedule(adminInfo.CurrentOrgId, startTime, endTime, schedule.PatientId)
- if daySchedule.ID > 0 && daySchedule.ID != schedule.ID {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
- return
- }
-
- //同天同位置只能排一个
- pointSchedule, err := service.GetPointSchedule(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if pointSchedule.ID > 0 && pointSchedule.PatientId != patient_id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
- return
- }
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(adminInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
- schedule.IsExport = 3000
- service.SaveSch(&schedule)
-
- //去除当天患者排班中重复数据,保留最后一条数据
- service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
-
- } else { //新的排班信息
-
- if items["schedule_date"] == nil || reflect.TypeOf(items["schedule_date"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleDate, _ := items["schedule_date"].(string)
- if len(scheduleDate) == 0 {
- utils.ErrorLog("len(schedule_date) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleDate = theTime.Unix()
-
- timeNow := time.Now().Format("2006-01-02")
- if timeNow > scheduleDate {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
- return
- }
- scheduleType := int64(items["schedule_type"].(float64))
- if scheduleType < 1 || scheduleType > 3 {
- utils.ErrorLog("scheduleType < 3")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleType = scheduleType
-
- if items["bed_id"] == nil || reflect.TypeOf(items["bed_id"]).String() != "float64" {
- utils.ErrorLog("bed_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- bedId := int64(items["bed_id"].(float64))
- if bedId < 1 {
- utils.ErrorLog("bedId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.BedId = bedId
-
- if items["zone_id"] == nil || reflect.TypeOf(items["zone_id"]).String() != "float64" {
- utils.ErrorLog("zone_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- partitionId := int64(items["zone_id"].(float64))
- if partitionId < 1 {
- utils.ErrorLog("zone_id < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.PartitionId = partitionId
-
- if items["schedule_week"] == nil || reflect.TypeOf(items["schedule_week"]).String() != "float64" {
- utils.ErrorLog("schedule_week")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleWeek := int64(items["schedule_week"].(float64))
- if scheduleWeek < 1 || scheduleWeek > 7 {
- utils.ErrorLog("scheduleWeek < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleWeek = scheduleWeek
-
- if items["mode_id"] == nil || reflect.TypeOf(items["mode_id"]).String() != "float64" {
- fmt.Println(reflect.TypeOf(items["mode_id"]))
-
- utils.ErrorLog("mode_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- modeId := int64(items["mode_id"].(float64))
- if modeId < 1 && modeId > 14 {
- utils.ErrorLog("modeId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- //校验当天改床位是否有排班,如果有排班则不能替换排班
-
- sch, _ := service.GetScheduleByZoneAndBed(adminInfo.CurrentOrgId, partitionId, bedId, schedule.ScheduleDate, schedule.ScheduleType)
-
- if sch.ID > 0 && sch.PatientId != patient_id {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorSchedualcRepeatBed)
- return
- }
- var DialysisMachineName string
-
- so, _ := service.GetDialysisSolutionTwo(adminInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(schedule.DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
-
- //判断当前保存的患者是否已经有排班
- existSchedule, _ := service.GetScheduleByDate(adminInfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
- if existSchedule.ID > 0 {
- existSchedule.ModeId = modeId
- existSchedule.BedId = schedule.BedId
- existSchedule.PartitionId = schedule.PartitionId
- existSchedule.ScheduleType = schedule.ScheduleType
- existSchedule.DialysisMachineName = schedule.DialysisMachineName
- existSchedule.IsExport = 3001
- service.SaveSmartSch(existSchedule)
-
- } else {
- schedule.ModeId = modeId
- schedule.PatientId = patient_id
- schedule.CreatedTime = time.Now().Unix()
- schedule.UpdatedTime = time.Now().Unix()
- schedule.Status = 1
- schedule.UserOrgId = adminInfo.CurrentOrgId
-
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(adminInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(adminInfo.CurrentOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
- //schedule.DialysisMachineName = schedule.DialysisMachineName
- daySchedule, _ := service.GetDaySchedule(adminInfo.CurrentOrgId, theTime.Unix(), theTime.Unix(), patient_id)
- if daySchedule.ID > 0 {
- daySchedule.ModeId = schedule.ModeId
- daySchedule.ScheduleType = schedule.ScheduleType
- daySchedule.PartitionId = schedule.PartitionId
- daySchedule.BedId = schedule.BedId
- daySchedule.DialysisMachineName = schedule.DialysisMachineName
- existSchedule.IsExport = 3002
- service.SaveSch(&daySchedule)
- } else {
- existSchedule.IsExport = 3003
- service.CreateScheduleTwo(&schedule)
- }
- }
- }
-
- //去除当天患者排班中重复数据,保留最后一条数据
- service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功",
- })
- HandleRedis(adminInfo.CurrentOrgId, schedule.ScheduleDate)
-
- }
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "保存成功",
- })
- }
- }
-
- }
- func HandleRedis(org_id int64, sch_date int64) {
- redis := service.RedisClient()
- //处方
- keyOne := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
- //医嘱
- keyTwo := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keySix := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":assessment_befores_list_all"
- redis.Set(keySix, "", time.Second)
- keyThree := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
- keyFour := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":monitor_record_list_all"
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":treatment_summarys_list_all"
- redis.Set(keyFive, "", time.Second)
- keySeven := strconv.FormatInt(org_id, 10) + ":" + strconv.FormatInt(sch_date, 10) + ":dialysis_orders_list_all"
- redis.Set(keySeven, "", time.Second)
- defer redis.Close()
-
- }
-
- func (c *ScheduleApiController) GetSmartSch() {
- patient_id, _ := c.GetInt64("patient_id")
- fmt.Println("~~~~~~")
- fmt.Println(patient_id)
- fmt.Println("~~~~~~")
-
- adminUserInfo := c.GetAdminUserInfo()
- sch, err := service.GetSmartSchPatientByPatientID(adminUserInfo.CurrentOrgId, patient_id)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "sch": sch,
- })
- }
-
- func (c *ScheduleApiController) GetPatient() {
- keyWord := c.GetString("keyword")
- adminUserInfo := c.GetAdminUserInfo()
- patient, err := service.GetSmartSchPatientByKeyWord(adminUserInfo.CurrentOrgId, keyWord)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (c *ScheduleApiController) GetPatientSchTemplate() {
- //patient_id, _ := c.GetInt64("patient_id",0)
- keyWord := c.GetString("keyword")
- adminUserInfo := c.GetAdminUserInfo()
- patient, err := service.GetSmartSchTemplatePatientByKeyWord(adminUserInfo.CurrentOrgId, keyWord)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "patient": patient,
- })
- }
-
- func (c *ScheduleApiController) GetPatientSmartSch() {
- patient_id, _ := c.GetInt64("patient_id", 0)
- adminUserInfo := c.GetAdminUserInfo()
- schs, err := service.GetSmartSchPatientByID(adminUserInfo.CurrentOrgId, patient_id)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "schedules": schs,
- })
- }
- func (c *ScheduleApiController) GetPatientSmartSchTemplate() {
- patient_id, _ := c.GetInt64("patient_id", 0)
- adminUserInfo := c.GetAdminUserInfo()
- mode, _ := service.GetOrgPatientScheduleTemplateModeTwo(adminUserInfo.CurrentOrgId)
- if mode.ID > 0 {
- if mode.Mode == 0 {
- //schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id)
- c.ServeSuccessJSON(map[string]interface{}{
- "status": 0,
- })
-
- } else if mode.Mode == 1 {
- schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id, 1)
- c.ServeSuccessJSON(map[string]interface{}{
- "status": 0,
- "schedules_template": schs,
- })
-
- } else if mode.Mode == 2 {
- schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id, 2)
- c.ServeSuccessJSON(map[string]interface{}{
- "status": 1,
- "schedules_template": schs,
- })
-
- } else if mode.Mode == 3 {
-
- schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id, 3)
- c.ServeSuccessJSON(map[string]interface{}{
- "status": 1,
- "schedules_template": schs,
- })
- } else if mode.Mode == 4 {
-
- schs, _ := service.GetSmartSchTemplatePatientByID(adminUserInfo.CurrentOrgId, patient_id, 4)
- c.ServeSuccessJSON(map[string]interface{}{
- "status": 1,
- "schedules_template": schs,
- })
- }
-
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": 0,
- })
-
- }
- }
-
- func (c *ScheduleApiController) GetDevicesNumbers() {
- sch_type, _ := c.GetInt("sch_type", 0)
- zone_id, _ := c.GetInt64("zone_id", 0)
- patient_id, _ := c.GetInt64("patient_id", 0)
-
- schedule_date := c.GetString("schedule_date")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime := theTime.Unix()
-
- deviceNumbers, getDeviceNumbersErr := service.GetAllAvaildDeviceNumbersByZone(c.GetAdminUserInfo().CurrentOrgId, recordDateTime, sch_type, zone_id, patient_id)
- if getDeviceNumbersErr != nil {
- c.ErrorLog("获取所有床位失败:%v", getDeviceNumbersErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "devices": deviceNumbers,
- })
-
- }
-
- func (c *ScheduleApiController) GetWeekPanels() {
-
- data, _ := c.GetInt64("data", 1)
- patitionIdStr := c.GetString("patitionid")
- var ids []string
- if len(patitionIdStr) > 0 {
- ids = strings.Split(patitionIdStr, ",")
- }
-
- adminInfo := c.GetAdminUserInfo()
- thisTime := time.Now()
- year, monthTime, day := thisTime.Date()
- month := int(monthTime)
- _, theWeek := thisTime.ISOWeek()
-
- lastWeek := thisTime.AddDate(0, 0, -7)
-
- nextWeek := thisTime.AddDate(0, 0, 7)
- nextSecWeek := thisTime.AddDate(0, 0, 14)
-
- _, theLastWeek := lastWeek.ISOWeek()
- _, theNextWeek := nextWeek.ISOWeek()
- _, theNextSecWeek := nextSecWeek.ISOWeek()
-
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekDays := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekDays = append(weekDays, indexWeek)
- }
-
- returnData := map[string]interface{}{
- "year": year,
- "month": month,
- "day": day,
- "theWeek": theWeek,
- "theNextWeek": theNextWeek,
- "theNextSecWeek": theNextSecWeek,
- "theLastWeek": theLastWeek,
- "weekDay": weekDay,
- "weekDays": weekDays,
- }
-
- if data == 1 {
-
- partitions, _ := service.GetSchedulePartitionPanelOne(adminInfo.CurrentOrgId, ids)
-
- returnData["partitions"] = partitions
- }
-
- c.ServeSuccessJSON(returnData)
- return
- }
-
- func (c *ScheduleApiController) GetSchedules() {
- week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
- partition_id, _ := c.GetInt64("partition_id")
- schedule_type, _ := c.GetInt64("schedule_type")
-
- is_before, _ := c.GetInt64("is_before")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
-
- adminInfo := c.GetAdminUserInfo()
- thisTime := time.Now()
- today := thisTime.Format("2006-01-02")
- if week < 1 || week > 4 {
- week = 2
- }
- if week == 1 {
- thisTime = thisTime.AddDate(0, 0, -7)
- } else if week == 3 {
- thisTime = thisTime.AddDate(0, 0, 7)
- } else if week == 4 {
- thisTime = thisTime.AddDate(0, 0, 14)
- }
-
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekTitle := make([]string, 0)
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekTitle = append(weekTitle, indexWeek)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekStartDay := thisTime.AddDate(0, 0, weekStart)
- weekEndDay := thisTime.AddDate(0, 0, weekEnd)
- weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
- weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
-
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
- weekStartPoint := theStarTime.Unix()
- weekEndPoint := theEndTime.Unix()
- if is_before > 0 {
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, start_time, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, end_time, loc)
- weekStartPoint = theStarTime.Unix()
- weekEndPoint = theEndTime.Unix()
- }
-
- schdules, _ := service.GetWeekScheduleOne(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, partition_id, schedule_type)
- c.ServeSuccessJSON(map[string]interface{}{
- "days": days,
- "weekTitle": weekTitle,
- "schdules": schdules,
- "today": today,
- })
- return
- }
-
- func (c *ScheduleApiController) GetPatients() {
- keywords := c.GetString("keywords", "")
- schedule, _ := c.GetInt64("schedule", 0) //1已2未
- contagion, _ := c.GetInt64("contagion", 0)
-
- adminInfo := c.GetAdminUserInfo()
-
- thisTime := time.Now()
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- thisWeekEnd := 7 - weekDay
- weekStartPoint := thisWeekEnd - 6
- weekStartDay := thisTime.AddDate(0, 0, weekStartPoint)
- weekEndPoint := thisWeekEnd + 7
- weekEndDay := thisTime.AddDate(0, 0, weekEndPoint)
- fmt.Println(weekStartPoint, weekStartDay, weekEndPoint, weekEndDay)
-
- weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
- weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
- fmt.Println(weekStartTime, weekEndTime)
-
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
- weekStart := theStarTime.Unix()
- weekEnd := theEndTime.Unix()
-
- patients, _ := service.GetPatientWithScheduleAndSolution(adminInfo.CurrentOrgId, keywords, weekStart, weekEnd, schedule, contagion)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "patients": patients,
- })
- return
- }
-
- func (c *ScheduleApiController) CreateSchedule() {
- patientID, _ := c.GetInt64("patient_id", 0)
- if patientID <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patientID)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- var schedule models.Schedule
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if dataBody["schedule_date"] == nil || reflect.TypeOf(dataBody["schedule_date"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleDate, _ := dataBody["schedule_date"].(string)
- if len(scheduleDate) == 0 {
- utils.ErrorLog("len(schedule_date) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleDate = theTime.Unix()
-
- timeNow := time.Now().Format("2006-01-02")
- if timeNow > scheduleDate {
- utils.ErrorLog(timeNow)
- utils.ErrorLog(scheduleDate)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
- return
- }
-
- if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
- utils.ErrorLog("schedule_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleType := int64(dataBody["schedule_type"].(float64))
- if scheduleType < 1 || scheduleType > 3 {
- utils.ErrorLog("scheduleType < 3")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleType = scheduleType
-
- if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
- utils.ErrorLog("bed_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- bedId := int64(dataBody["bed_id"].(float64))
- if bedId < 1 {
- utils.ErrorLog("bedId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.BedId = bedId
-
- if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
- utils.ErrorLog("partition_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- partitionId := int64(dataBody["partition_id"].(float64))
- if partitionId < 1 {
- utils.ErrorLog("partitionId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.PartitionId = partitionId
-
- if dataBody["schedule_week"] == nil || reflect.TypeOf(dataBody["schedule_week"]).String() != "float64" {
- utils.ErrorLog("schedule_week")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleWeek := int64(dataBody["schedule_week"].(float64))
- if scheduleWeek < 1 || scheduleWeek > 7 {
- utils.ErrorLog("scheduleWeek < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleWeek = scheduleWeek
-
- if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
- utils.ErrorLog("mode_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- modeId := int64(dataBody["mode_id"].(float64))
- if modeId < 1 && modeId > 14 {
- utils.ErrorLog("modeId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ModeId = modeId
-
- schedule.PatientId = patientID
- schedule.CreatedTime = time.Now().Unix()
- schedule.UpdatedTime = time.Now().Unix()
- schedule.Status = 1
- schedule.UserOrgId = adminUserInfo.CurrentOrgId
- schedule.IsExport = 5
-
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(adminUserInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
-
- bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
- if bed == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
- return
- }
- if bed.ZoneID != schedule.PartitionId {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
- return
- }
-
- scheduleDateStart := scheduleDate + " 00:00:00"
- scheduleDateEnd := scheduleDate + " 23:59:59"
- timeLayout = "2006-01-02 15:04:05"
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
- startTime := theStartTime.Unix()
- endTime := theEndTime.Unix()
-
- //一天只有排班一次
- daySchedule, err := service.GetDaySchedule(adminUserInfo.CurrentOrgId, startTime, endTime, patientID)
- if daySchedule.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
- return
- }
-
- //同天同位置只能排一个
- pointSchedule, err := service.GetPointSchedule(adminUserInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if pointSchedule.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
- return
- }
-
- redis := service.RedisClient()
- schedule.IsExport = 1000
- err = service.CreateScheduleTwo(&schedule)
-
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- scheduleLog := models.XtScheduleLog{
- UserOrgId: adminUserInfo.CurrentOrgId,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "电脑端新增排班",
- Module: 1,
- AdminUserId: adminUserInfo.AdminUser.Id,
- }
-
- service.CreateScheduleLog(scheduleLog)
-
- key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
-
- redis.Set(key, "", time.Second)
- //处方
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
-
- //医嘱
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
- redis.Set(keySix, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
-
- keyFour := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
- redis.Set(keyFour, "", time.Second)
-
- keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
- redis.Set(keyFive, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
- redis.Set(keySeven, "", time.Second)
- fmt.Println(err)
- defer redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
- return
- }
- schedule.Patient = patientInfo.Name
-
- service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "schedule": schedule,
- })
- return
- }
-
- func (c *ScheduleApiController) CreateScheduleTwo() {
- patientID, _ := c.GetInt64("patient_id", 0)
- id, _ := c.GetInt64("id_two", 0)
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminINfo := c.GetAdminUserInfo()
- schedule_two, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
- timeNow := time.Now().Format("2006-01-02")
- timeTemplate := "2006-01-02"
-
- tm := time.Unix(int64(schedule_two.ScheduleDate), 0)
- timeStr := tm.Format(timeTemplate)
- if timeNow > timeStr {
- utils.ErrorLog(timeNow)
- utils.ErrorLog(timeStr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
- return
- }
- //if schedule_two == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
- // return
- //}
-
- //order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule_two.ScheduleDate, schedule_two.PatientId)
- //if err != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- //}
- //
- //if order != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDelScheduleFailByDialysis)
- // return
- //}
-
- schedule_two.Status = 0
- schedule_two.UpdatedTime = time.Now().Unix()
-
- if patientID <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patientID)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- var schedule models.Schedule
- dataBody := make(map[string]interface{}, 0)
-
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if dataBody["schedule_date"] == nil || reflect.TypeOf(dataBody["schedule_date"]).String() != "string" {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleDate, _ := dataBody["schedule_date"].(string)
- if len(scheduleDate) == 0 {
- utils.ErrorLog("len(schedule_date) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", scheduleDate+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleDate = theTime.Unix()
-
- timeNow = time.Now().Format("2006-01-02")
- if timeNow > scheduleDate {
- utils.ErrorLog(timeNow)
- utils.ErrorLog(scheduleDate)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
- return
- }
-
- if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
- utils.ErrorLog("schedule_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleType := int64(dataBody["schedule_type"].(float64))
- if scheduleType < 1 || scheduleType > 3 {
- utils.ErrorLog("scheduleType < 3")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleType = scheduleType
-
- if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
- utils.ErrorLog("bed_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- bedId := int64(dataBody["bed_id"].(float64))
- if bedId < 1 {
- utils.ErrorLog("bedId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.BedId = bedId
-
- if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
- utils.ErrorLog("partition_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- partitionId := int64(dataBody["partition_id"].(float64))
- if partitionId < 1 {
- utils.ErrorLog("partitionId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.PartitionId = partitionId
-
- if dataBody["schedule_week"] == nil || reflect.TypeOf(dataBody["schedule_week"]).String() != "float64" {
- utils.ErrorLog("schedule_week")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleWeek := int64(dataBody["schedule_week"].(float64))
- if scheduleWeek < 1 || scheduleWeek > 7 {
- utils.ErrorLog("scheduleWeek < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleWeek = scheduleWeek
-
- if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
- utils.ErrorLog("mode_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- modeId := int64(dataBody["mode_id"].(float64))
- if modeId < 1 && modeId > 14 {
- utils.ErrorLog("modeId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ModeId = modeId
-
- schedule.PatientId = patientID
- schedule.CreatedTime = time.Now().Unix()
- schedule.UpdatedTime = time.Now().Unix()
- schedule.Status = 1
- schedule.UserOrgId = adminUserInfo.CurrentOrgId
- schedule.IsExport = 5
-
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(adminUserInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
-
- bed, _ := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, schedule.BedId)
- if bed == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
- return
- }
- if bed.ZoneID != schedule.PartitionId {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
- return
- }
-
- //scheduleDateStart := scheduleDate + " 00:00:00"
- //scheduleDateEnd := scheduleDate + " 23:59:59"
- timeLayout = "2006-01-02 15:04:05"
- //theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- //theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
- //startTime := theStartTime.Unix()
- //endTime := theEndTime.Unix()
-
- ////一天只有排班一次
- //daySchedule, err := service.GetDaySchedule(adminUserInfo.CurrentOrgId, startTime, endTime, patientID)
- //if daySchedule.ID > 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
- // return
- //}
- //同天同位置只能排一个
- pointSchedule, err := service.GetPointSchedule(adminUserInfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if pointSchedule.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
- return
- }
- schedule.IsExport = 1000
-
- err = service.CreateSchedule(&schedule, id)
-
- lastSchedule, _ := service.GetLastSchedule(patientID, adminUserInfo.CurrentOrgId)
-
- //查询上机床位号 更改床位号
- order, err := service.GetOneDialysisOrderOne(adminINfo.CurrentOrgId, schedule_two.ScheduleDate, schedule_two.PatientId)
-
- scheduleObj, _ := service.GetPatientScheduleByPatientId(patientID, adminUserInfo.CurrentOrgId, schedule_two.ScheduleDate)
- if order.ID > 0 {
- service.UpdateDialysiOrderByPatientId(order.ID, scheduleObj.ScheduleType, scheduleObj.PartitionId, scheduleObj.BedId)
-
- redis := service.RedisClient()
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_order"
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
- //清空key 值
- redis.Set(keyOne, "", time.Second)
- keySix := "scheduals_" + timeNow + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keySix, "", time.Second)
-
- }
-
- redis := service.RedisClient()
- key := "scheduals_" + scheduleDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(key, "", time.Second)
- //处方
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
- //医嘱
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
- redis.Set(keySix, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
- keyFour := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
- redis.Set(keyFive, "", time.Second)
- keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
- redis.Set(keySeven, "", time.Second)
- defer redis.Close()
- schedule.Patient = patientInfo.Name
-
- //去除当天患者排班中重复数据,保留最后一条数据
- service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "schedule": schedule,
- "schedule_two": schedule_two,
- "lastSchedule": lastSchedule,
- })
- return
-
- }
-
- func (c *ScheduleApiController) DeleteSchedule() {
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminINfo := c.GetAdminUserInfo()
-
- schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
- timeNow := time.Now().Format("2006-01-02")
- timeTemplate := "2006-01-02"
-
- tm := time.Unix(int64(schedule.ScheduleDate), 0)
- timeStr := tm.Format(timeTemplate)
- if timeNow > timeStr {
- utils.ErrorLog(timeNow)
- utils.ErrorLog(timeStr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
- return
- }
- if schedule == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
- return
- }
-
- order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if order != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDelScheduleFailByDialysis)
- return
- }
-
- schedule.Status = 0
- schedule.UpdatedTime = time.Now().Unix()
-
- //如果使用的是保存出库功能
- drugOutConfig, _ := service.FindDrugOutConfigById(adminINfo.CurrentOrgId)
- //退库
- if drugOutConfig.IsOpen == 1 {
- hisAdvice, _ := service.GetPatientDrugCountToday(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
-
- if len(hisAdvice) > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorAdivceCode)
- return
- }
- //for _, item := range hisAdvice {
- // creater := adminINfo.AdminUser.Id
- // err = service.DrugAutoAddCancelInfo(item, creater)
- // if err != nil {
- // err = fmt.Errorf("!:%v", err)
- // return
- // }
- //}
- ////查询是否有出库记录
- //service.GetPatientGoodStockCount(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
- }
-
- //查询该患者当天是否开耗材
- list, _ := service.GetPatientGoodCountToday(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
- if len(list) > 0 {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorAdivceCode)
- return
-
- //operation_time := time.Now().Unix()
- //creater := c.GetAdminUserInfo().AdminUser.Id
- ////创建退库单
- //timeStr := time.Now().Format("2006-01-02")
- //timeArr := strings.Split(timeStr, "-")
- //total, _ := service.FindAllCancelStockTotal(c.GetAdminUserInfo().CurrentOrgId)
- //total = total + 1
- //orderNumber := "CKTKD" + strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
- //houseConfig, _ := service.GetAllStoreHouseConfig(c.GetAdminUserInfo().CurrentOrgId)
- //cancelStock := models.CancelStock{
- // OrderNumber: orderNumber,
- // OperaTime: operation_time,
- // OrgId: c.GetAdminUserInfo().CurrentOrgId,
- // Creater: creater,
- // Ctime: time.Now().Unix(),
- // Status: 1,
- // ReturnTime: schedule.ScheduleDate,
- // Type: 1,
- // StorehouseId: houseConfig.StorehouseOutInfo,
- // IsCheck: 1,
- //}
- //_, msgerrkonde := service.GetCancelStockDetailByOrderNumberOne(schedule.ScheduleDate, c.GetAdminUserInfo().CurrentOrgId)
- //if msgerrkonde == gorm.ErrRecordNotFound {
- // service.AddSigleCancelStock(&cancelStock)
- //}
- //cancel, _ := service.GetLastCancelStockById(c.GetAdminUserInfo().CurrentOrgId)
- ////进行退库操作
- //for _, item := range list {
- // good, _ := service.FindGoodInfoByIdTwo(item.GoodId)
- // manufacturer, _ := service.GetManufactureById(item.Manufacturer)
- // deaerler, _ := service.GetDealerById(item.Dealer)
- // //回退库存
- // service.UpDateWarehouseInfoByStockDelete(item.WarehouseInfotId, item.Count, item.PatientId, item.SysRecordTime, item.GoodId)
- // goodList, _ := service.GetSumGoodList(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId)
- // var flush_count int64
- // for _, it := range goodList {
- // flush_count += it.StockCount
- // }
- // cancelStockInfo := models.CancelStockInfo{
- // GoodId: item.GoodId,
- // CancelStockId: cancel.ID,
- // GoodTypeId: good.GoodTypeId,
- // Count: item.Count,
- // Price: item.Price,
- // Total: 0,
- // ProductDate: item.ProductDate,
- // ExpiryDate: item.ExpiryDate,
- // Ctime: time.Now().Unix(),
- // Status: 1,
- // OrgId: c.GetAdminUserInfo().CurrentOrgId,
- // OrderNumber: cancel.OrderNumber,
- // Type: 0,
- // Dealer: deaerler.DealerName,
- // Manufacturer: manufacturer.ManufacturerName,
- // Number: item.Number,
- // RegisterAccount: "",
- // Remark: "",
- // WarehouseInfoId: item.WarehouseInfotId,
- // PatientId: item.PatientId,
- // RecordDate: item.SysRecordTime,
- // StorehouseId: houseConfig.StorehouseOutInfo,
- // IsCheck: 1,
- // }
- //
- // service.CreateCancelStockInfoOne(&cancelStockInfo)
- //
- // cancelInfo, _ := service.GetLastCancelStockInfoByGoodId(item.GoodId)
- //
- // flow := models.VmStockFlow{
- // WarehousingId: item.WarehouseInfotId,
- // GoodId: item.GoodId,
- // Number: item.Number,
- // LicenseNumber: item.LicenseNumber,
- // Count: item.Count,
- // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
- // PatientId: item.PatientId,
- // SystemTime: item.SysRecordTime,
- // ConsumableType: 7,
- // IsSys: 0,
- // WarehousingOrder: "",
- // WarehouseOutId: item.WarehouseOutId,
- // WarehouseOutOrderNumber: item.WarehouseOutOrderNumber,
- // IsEdit: 0,
- // CancelStockId: cancel.ID,
- // CancelOrderNumber: cancel.OrderNumber,
- // Manufacturer: manufacturer.ID,
- // Dealer: 0,
- // Creator: c.GetAdminUserInfo().CurrentOrgId,
- // UpdateCreator: 0,
- // Status: 1,
- // Ctime: time.Now().Unix(),
- // Mtime: 0,
- // Price: item.Price,
- // WarehousingDetailId: item.WarehouseInfotId,
- // WarehouseOutDetailId: item.ID,
- // CancelOutDetailId: cancelInfo.ID,
- // ProductDate: item.ProductDate,
- // ExpireDate: item.ExpiryDate,
- // StorehouseId: houseConfig.StorehouseOutInfo,
- // OverCount: flush_count,
- // }
- // service.CreateStockFlowOne(flow)
- //
- // //退库数量增加
- // service.UpdateSumAddCancelCount(c.GetAdminUserInfo().CurrentOrgId, item.GoodId, houseConfig.StorehouseOutInfo, item.Count)
- // //出库数量减少
- // service.UpdateSumCount(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId, item.Count)
- //
- // //更新库存
- // service.UpdateSumGood(c.GetAdminUserInfo().CurrentOrgId, houseConfig.StorehouseOutInfo, item.GoodId, flush_count)
- //
- // //更新基础库库存
- // service.UpdateGoodInfoSumCountSix(item.GoodId, flush_count, c.GetAdminUserInfo().CurrentOrgId)
- //}
- }
-
- err = service.UpdateSchedule(schedule)
-
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- scheduleLog := models.XtScheduleLog{
- UserOrgId: adminINfo.CurrentOrgId,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "电脑端删除排班",
- Module: 5,
- AdminUserId: adminINfo.AdminUser.Id,
- }
-
- service.CreateScheduleLog(scheduleLog)
-
- //针对凤凰医院
- if adminINfo.CurrentOrgId == 10579 || adminINfo.CurrentOrgId == 10344 || adminINfo.CurrentOrgId == 10206 || adminINfo.CurrentOrgId == 10679 {
- advice, _ := service.GetDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
- if len(advice) > 0 {
- service.UpdateAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
- }
- }
-
- if adminINfo.CurrentOrgId == 10206 || adminINfo.CurrentOrgId == 10344 {
- hisAdvice, _ := service.GetHisDoctorAdviceListTwenty(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
- project, _ := service.GetHisPrescriptionProjectList(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
- if len(hisAdvice) > 0 {
- service.UpdateHisAdviceObj(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
- }
- if len(project) > 0 {
- service.UpdateProjectObj(schedule.PatientId, schedule.ScheduleDate, adminINfo.CurrentOrgId)
- }
- }
-
- redis := service.RedisClient()
-
- //处方
- keyOne := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
-
- //医嘱
- keyTwo := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
- redis.Set(keySix, "", time.Second)
- keyThree := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
-
- keyFour := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
- redis.Set(keyFour, "", time.Second)
-
- keyFive := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
- redis.Set(keyFive, "", time.Second)
-
- keySeven := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
- redis.Set(keySeven, "", time.Second)
- fmt.Println(err)
- defer redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "schedule": &schedule,
- })
- }
-
- func (c *ScheduleApiController) ChangeSchedule() {
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminINfo := c.GetAdminUserInfo()
-
- schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
- if schedule == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
- return
- }
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- if dataBody["change_action"] == nil || reflect.TypeOf(dataBody["change_action"]).String() != "string" {
- utils.ErrorLog("change_action")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- changeAction := dataBody["change_action"].(string)
-
- if changeAction == "change_mode" {
- if dataBody["mode_id"] == nil || reflect.TypeOf(dataBody["mode_id"]).String() != "float64" {
- utils.ErrorLog("mode_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrongForSchMode)
- return
- }
- modeId := int64(dataBody["mode_id"].(float64))
- if modeId < 1 {
- utils.ErrorLog("modeId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrongForSchMode)
- return
- }
- schedule.ModeId = modeId
-
- so, _ := service.GetDialysisSolutionTwo(adminINfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(adminINfo.CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(adminINfo.CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(adminINfo.CurrentOrgId, "透析器/灌流器")
- var DialysisMachineName string
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- //fmt.Println("1111")
- fmt.Println(DialysisMachineName)
-
- }
- if filedRecordThree.IsShow == 1 {
- if len(schedule.DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
- //fmt.Println("22222")
- fmt.Println(DialysisMachineName)
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
- //fmt.Println("333333")
- fmt.Println(DialysisMachineName)
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
- //fmt.Println("55555555")
- fmt.Println(DialysisMachineName)
- } else {
- DialysisMachineName = so.DialysisIrrigation
- //fmt.Println("66666666")
- fmt.Println(DialysisMachineName)
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
-
- order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if order != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeMode)
- return
- }
-
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- scheduleLog := models.XtScheduleLog{
- UserOrgId: adminINfo.CurrentOrgId,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "电脑端改变模式排班",
- Module: 1,
- AdminUserId: adminINfo.AdminUser.Id,
- }
-
- service.CreateScheduleLog(scheduleLog)
-
- } else if changeAction == "change_device" {
- order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if order != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeDeviceNumber)
- return
- }
-
- if dataBody["schedule_type"] == nil || reflect.TypeOf(dataBody["schedule_type"]).String() != "float64" {
- utils.ErrorLog("schedule_type")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- scheduleType := int64(dataBody["schedule_type"].(float64))
- if scheduleType < 1 || scheduleType > 3 {
- utils.ErrorLog("scheduleType < 3")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.ScheduleType = scheduleType
-
- if dataBody["bed_id"] == nil || reflect.TypeOf(dataBody["bed_id"]).String() != "float64" {
- utils.ErrorLog("bed_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- bedId := int64(dataBody["bed_id"].(float64))
- if bedId < 1 {
- utils.ErrorLog("bedId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.BedId = bedId
-
- if dataBody["partition_id"] == nil || reflect.TypeOf(dataBody["partition_id"]).String() != "float64" {
- utils.ErrorLog("partition_id")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- partitionId := int64(dataBody["partition_id"].(float64))
- if partitionId < 1 {
- utils.ErrorLog("partitionId < 1")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedule.PartitionId = partitionId
-
- bed, _ := service.GetDeviceNumberByID(adminINfo.CurrentOrgId, schedule.BedId)
- if bed == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
- return
- }
- if bed.ZoneID != schedule.PartitionId {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotTheZone)
- return
- }
-
- startTime := schedule.ScheduleDate
- endTime := startTime + 86399
-
- //一天只有排班一次
- daySchedule, err := service.GetDaySchedule(adminINfo.CurrentOrgId, startTime, endTime, schedule.PatientId)
- if daySchedule.ID > 0 && daySchedule.ID != schedule.ID {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleAgainOneDay)
- return
- }
-
- //同天同位置只能排一个
- pointSchedule, err := service.GetPointSchedule(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.ScheduleWeek, schedule.ScheduleType, schedule.BedId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- if pointSchedule.ID > 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePointScheduleExist)
- return
- }
-
- //记录日志
- byterequest, _ := json.Marshal(schedule)
- scheduleLog := models.XtScheduleLog{
- UserOrgId: adminINfo.CurrentOrgId,
- RecordDate: schedule.ScheduleDate,
- Status: 1,
- PatientId: schedule.PatientId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- Source: "电脑端改变分区床位",
- Module: 4,
- AdminUserId: adminINfo.AdminUser.Id,
- }
-
- service.CreateScheduleLog(scheduleLog)
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- schedule.UpdatedTime = time.Now().Unix()
- err = service.UpdateSchedule(schedule)
-
- prescription := models.DialysisPrescription{
- ModeId: schedule.ModeId,
- }
- _, errcode := service.GetDialysisPrescribe(schedule.UserOrgId, schedule.PatientId, schedule.ScheduleDate)
- if errcode == gorm.ErrRecordNotFound {
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeScheduleFail)
- return
- }
- service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "schedule": &schedule,
- })
- } else if errcode == nil {
- err = service.UpdatedDialysisPrescription(&prescription, schedule.ScheduleDate, schedule.PatientId, schedule.UserOrgId)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeChangeScheduleFail)
- return
- }
- service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "schedule": &schedule,
- })
- }
- }
-
- // /api/schedule/print/initdata [get]
- // @param date:string yyyy-MM-dd 要打印的那一周中的任一天
- func (this *ScheduleApiController) PrintInitData() {
- dateStr := this.GetString("date")
- //week_type, _ := this.GetInt64("type", 0)
- var date *time.Time
- if len(dateStr) == 0 {
- now := time.Now()
- date = &now
- } else {
- var parseErr error
- date, parseErr = utils.ParseTimeStringToTime("2006-01-02", dateStr)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- // 获取本周的排班
- var monday time.Time
- var sunday time.Time
- //switch week_type {
- //case 1:
- monday, sunday = utils.GetMondayAndSundayOfWeekDate(date)
-
- // break
- //case 2:
- // monday, sunday = utils.GetMondayAndSundayOfNextWeekDate(date)
- //
- // break
- //case 3:
- // monday, sunday = utils.GetMondayAndSundayOfNextNextWeekDate(date)
- // break
- //}
- schedules, getScheduleErr := service.GetPrinitWeekSchedules(adminUserInfo.CurrentOrgId, monday.Unix(), sunday.Unix())
- total, getScheduleErr := service.GetPrinitWeekTotal(adminUserInfo.CurrentOrgId, monday.Unix(), sunday.Unix())
- if getScheduleErr != nil {
- this.ErrorLog("获取周排班失败:%v", getScheduleErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- thisTime := date
-
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "total": total,
- "schedules": schedules,
- "monday": monday.Unix(),
- "days": days,
- })
- }
-
- func (this *ScheduleApiController) UrgentScheduleData() {
- schedule_type, _ := this.GetInt("type", 0)
- schedule_date := this.GetString("date")
- var date *time.Time
- if len(schedule_date) == 0 {
- now := time.Now()
- date = &now
- } else {
- var parseErr error
- date, parseErr = utils.ParseTimeStringToTime("2006-01-02", schedule_date)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- deviceNumbers, getDeviceNumbersErr := service.MobileGetAllDeviceNumbersForUrgentSchedule(adminUserInfo.CurrentOrgId, date.Unix(), schedule_type)
- if getDeviceNumbersErr != nil {
- this.ErrorLog("获取所有床位失败:%v", getDeviceNumbersErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- // today := utils.ZeroHourTimeOfDay(time.Now())
- schedules, getSchedulesErr := service.MobileGetOtherSchedulesForUrgentSchedule(adminUserInfo.CurrentOrgId, date.Unix(), schedule_type)
- if getSchedulesErr != nil {
- this.ErrorLog("获取所有排班失败:%v", getSchedulesErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "device_numbers": deviceNumbers,
- "schedules": schedules,
- })
- }
-
- func (this *ScheduleApiController) SearchSchedulePatients() {
- keywords := this.GetString("keywords")
- week_type, _ := this.GetInt64("week_type", 0)
- start_sch := this.GetString("start_sch")
- end_sch := this.GetString("end_sch")
-
- thisTime1 := time.Now()
- thisTime2 := time.Now()
-
- thisTime1 = thisTime1.AddDate(0, 0, 7)
- thisTime2 = thisTime2.AddDate(0, 0, 14)
-
- var start_time string
- var end_time string
-
- switch week_type {
- case 1:
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var startSchTime int64
- if len(start_sch) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_sch+" 00:00:00", loc)
- startSchTime = theTime.Unix()
- }
- var endSchTime int64
- if len(end_sch) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_sch+" 00:00:00", loc)
- endSchTime = theTime.Unix()
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- list, _ := service.GetSchedualPatientsByKeywords(keywords, adminUserInfo.CurrentOrgId, startSchTime, endSchTime)
- this.ServeSuccessJSON(map[string]interface{}{
- "schdules": list,
- })
-
- break
- case 2:
- days := make([]string, 0)
-
- weekDay1 := int(thisTime1.Weekday())
- if weekDay1 == 0 {
- weekDay1 = 7
- }
- weekEnd1 := 7 - weekDay1
- weekStart1 := weekEnd1 - 6
- for index := weekStart1; index <= weekEnd1; index++ {
- fmt.Println(index)
- theDay := thisTime1.AddDate(0, 0, index)
- days = append(days, theDay.Format("2006-01-02"))
-
- }
-
- fmt.Println(days)
-
- start_time = days[0]
- end_time = days[len(days)-1]
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTime int64
- if len(start_time) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- theStartTime = theTime.Unix()
- }
- var theEndtTime int64
- if len(end_time) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- theEndtTime = theTime.Unix()
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- list, _ := service.GetSchedualPatientsByKeywordsAndWeek(keywords, adminUserInfo.CurrentOrgId, theStartTime, theEndtTime)
- this.ServeSuccessJSON(map[string]interface{}{
- "schdules": list,
- })
-
- break
- case 3:
- days := make([]string, 0)
-
- weekDay2 := int(thisTime2.Weekday())
- if weekDay2 == 0 {
- weekDay2 = 7
- }
- weekEnd2 := 7 - weekDay2
- weekStart2 := weekEnd2 - 6
- for index := weekStart2; index <= weekEnd2; index++ {
- theDay := thisTime2.AddDate(0, 0, index)
- days = append(days, theDay.Format("2006-01-02"))
-
- }
-
- start_time = days[0]
- end_time = days[len(days)-1]
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTime int64
- if len(start_time) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- theStartTime = theTime.Unix()
- }
- var theEndtTime int64
- if len(end_time) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- theEndtTime = theTime.Unix()
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- list, _ := service.GetSchedualPatientsByKeywordsAndWeek(keywords, adminUserInfo.CurrentOrgId, theStartTime, theEndtTime)
- this.ServeSuccessJSON(map[string]interface{}{
- "schdules": list,
- })
-
- break
- }
-
- }
-
- func (this *ScheduleApiController) GetWeekDaySchedule() {
- week_type, _ := this.GetInt64("week_type", -1)
- week_time, _ := this.GetInt64("week_time")
-
- thisTime := time.Now()
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekTitle := make([]string, 0)
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekTitle = append(weekTitle, indexWeek)
- days = append(days, theDay.Format("2006-01-02"))
- }
- fmt.Println(days)
-
- var targetDayStr string
- var startTime string
- var endTime string
- switch week_type {
- case 0:
- {
- startTime = days[0]
- endTime = days[6]
- }
- case 1:
- targetDayStr = days[0]
- break
- case 2:
- targetDayStr = days[1]
-
- break
- case 3:
- targetDayStr = days[2]
-
- break
- case 4:
- targetDayStr = days[3]
-
- break
- case 5:
- targetDayStr = days[4]
-
- break
- case 6:
- targetDayStr = days[5]
-
- break
- case 7:
- targetDayStr = days[6]
-
- break
- }
- targetDay, parseErr := utils.ParseTimeStringToTime("2006-01-02", targetDayStr)
- startDay, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
- endDay, _ := utils.ParseTimeStringToTime("2006-01-02", endTime)
- fmt.Println(startDay, endDay)
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- list, _ := service.GetWeekDayScheduleTwo(orgId, targetDay.Unix(), targetDay, week_time)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "schdules": list,
- "day": targetDayStr,
- })
-
- }
-
- func Struct2Map(obj interface{}) map[string]interface{} {
- t := reflect.TypeOf(obj)
- v := reflect.ValueOf(obj)
-
- var data = make(map[string]interface{})
- for i := 0; i < t.NumField(); i++ {
- data[t.Field(i).Name] = v.Field(i).Interface()
- }
- return data
- }
-
- func (this *ScheduleApiController) ExportSchedule() {
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- return
- }
- utils.ErrorLog("%v", dataBody)
- export_time := time.Now().Unix()
- var schedules []*models.Schedule
- var failed_total int
- var total_schedule []interface{}
- var patients []*models.Patients
-
- patients, _, _ = service.GetAllPatientList(this.GetAdminUserInfo().CurrentOrgId)
-
- start_time := dataBody["start_time"].(string)
-
- end_time := dataBody["end_time"].(string)
-
- delete_type := int64(dataBody["delete_type"].(float64))
- fmt.Println("delete_type", delete_type)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
-
- fmt.Println("theTimeStart", theTimeStart.Unix())
- fmt.Println("theTimeEnd", theTimeEnd.Unix())
-
- if dataBody["failed_schedule"] != nil || reflect.TypeOf(dataBody["failed_schedule"]).String() == "[]interface {}" {
- tempSchedule := dataBody["failed_schedule"].([]interface{})
- failed_total = len(tempSchedule)
-
- }
-
- if dataBody["schedule"] != nil || reflect.TypeOf(dataBody["schedule"]).String() == "[]interface {}" {
- tempSchedule := dataBody["schedule"].([]interface{})
- total_schedule = tempSchedule
- for _, schMap := range tempSchedule {
- schMapM := schMap.(map[string]interface{})
- var sch models.Schedule
-
- if schMapM["name"] == nil || reflect.TypeOf(schMapM["name"]).String() != "string" {
- utils.ErrorLog("name")
- return
- }
-
- name, _ := schMapM["name"].(string)
- fmt.Println(name)
- if len(name) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列的姓名不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- continue
-
- } else {
- var patient []*models.Patients
- for _, item := range patients {
- if strings.Replace(item.Name, " ", "", -1) == name {
- patient = append(patient, item)
- }
- }
- if len(patient) == 0 { //错误日志
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列,患者姓名为\"" + name + "\"在系统中不存在,请在系统中添加该患者",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- continue
-
- } else if len(patient) == 1 { //
- sch.PatientId = patient[0].ID
-
- } else if len(patient) > 1 { //出现同名的情况
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列" + "患者姓名为" + name + "在当前机构中存在重名,无法确定到具体患者",
-
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列,患者姓名为\"" + name + "\"在在当前机构中存在重名,无法确定到具体患者",
-
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- continue
-
- }
- }
-
- if schMapM["schedule_type"] == nil && reflect.TypeOf(schMapM["schedule_type"]).String() != "float64" {
- utils.ErrorLog("schedule_type")
- return
- }
- schedule_type := int64(schMapM["schedule_type"].(float64))
- if schedule_type <= 0 { //班次格式有误,插入日志
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第2行第" + schMapM["row"].(string) + "列的班次格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else {
- sch.ScheduleType = schedule_type
- }
-
- if schMapM["partition_name"] == nil || reflect.TypeOf(schMapM["partition_name"]).String() != "string" {
- utils.ErrorLog("partition_name")
- return
- }
-
- partition_name, _ := schMapM["partition_name"].(string)
- if len(partition_name) == 0 { //分区为空
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)) ,10)+ "行" + "的姓名不能为空",
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行第1列所属的分区格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else {
- zone, err := service.FindDeviceZoneByName(partition_name, this.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- sch.PartitionId = zone.ID
- } else if err == gorm.ErrRecordNotFound { //查不到数据,插入错误日志
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)) ,10)+ "行" + "的姓名不能为空",
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行第1列所属的分区格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- }
-
- }
-
- if schMapM["device_number_name"] == nil || reflect.TypeOf(schMapM["device_number_name"]).String() != "string" {
- utils.ErrorLog("device_number_name")
- return
- }
-
- device_number_name, _ := schMapM["device_number_name"].(string)
- if len(device_number_name) == 0 { //分区为空
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)) ,10)+ "行" + "的姓名不能为空",
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行第2列机号格式有误",
-
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else {
- device, err := service.FindDeviceByName(device_number_name, this.GetAdminUserInfo().CurrentOrgId, sch.PartitionId)
- if err == nil {
- if len(device) == 0 { //没查到数据,插入错误日志
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行第2列机号格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else if len(device) == 1 {
- sch.BedId = device[0].ID
-
- } else if len(device) > 1 { //出现重名,插入错误日志
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "出现两个床位号相同的床位",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- }
- }
- }
-
- if schMapM["schedule_week"] == nil || reflect.TypeOf(schMapM["schedule_week"]).String() != "string" {
- utils.ErrorLog("schedule_week")
- return
- }
- schedule_week, _ := schMapM["schedule_week"].(string)
- if len(schedule_week) == 0 { //周几为空则生成一条导入错误日志
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)) ,10)+ "行" + "的姓名不能为空",
- ErrMsg: "第1行第" + schMapM["row"].(string) + "列的星期名格式有误",
-
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else if schedule_week == "0" { //周几不符合格式则生成一条导入错误日志
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第1行第" + schMapM["row"].(string) + "列的星期名格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else {
- schedule_week, _ := strconv.ParseInt(schedule_week, 10, 64)
- sch.ScheduleWeek = schedule_week
-
- }
-
- if schMapM["schedule_date"] == nil || reflect.TypeOf(schMapM["schedule_date"]).String() != "string" {
- utils.ErrorLog("schedule_date")
- return
- }
- schedule_date, _ := schMapM["schedule_date"].(string)
-
- if len(schedule_date) == 0 { //周几为空则生成一条导入错误日志
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第1行第" + schMapM["row"].(string) + "列的星期名格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else if schedule_date == "0" { //周几不符合格式则生成一条导入错误日志
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: 1 + int64(failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第1行第" + schMapM["row"].(string) + "列的星期名格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else {
- date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
- sch.ScheduleDate = date.Unix()
- }
-
- sch.CreatedTime = time.Now().Unix()
- sch.UpdatedTime = time.Now().Unix()
- sch.ModeId = 1
- sch.Status = 1
- sch.UserOrgId = this.GetAdminUserInfo().CurrentOrgId
- sch.IsExport = 1
-
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(sch.UserOrgId, sch.PatientId, sch.ModeId)
- filedRecordOne, _ := service.FindFiledBy(sch.UserOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(sch.UserOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(sch.UserOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- sch.DialysisMachineName = DialysisMachineName
-
- schedules = append(schedules, &sch)
- }
-
- errLogs, _ := service.FindSchedualExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
-
- if len(schedules) > 0 {
- schedule_date := time.Now().Format("2006-01-02")
- date, _ := utils.ParseTimeStringToTime("2006-01-02", schedule_date)
- clear_schedule_date := date.Unix() //根据日期去清除,该日期未来的排班数据
-
- service.UpdateScheduleByExport(this.GetAdminUserInfo().CurrentOrgId, clear_schedule_date)
-
- if err == nil {
- for _, item := range schedules {
- if item.ScheduleDate > clear_schedule_date {
- //查询该患者是否转出获取死亡
- //查找当天日期是否存在
- _, errcode := service.GetTodayScheduleIsExistOne(item.PatientId, item.ScheduleDate, item.UserOrgId)
- if errcode == gorm.ErrRecordNotFound {
- //查询该床位是否有患者
- sch, errcodes := service.GetPatientByBed(item.ScheduleDate, item.BedId, item.ScheduleType, item.UserOrgId)
-
- if errcodes == gorm.ErrRecordNotFound {
- service.CreateScheduleTwo(item)
- } else if errcodes == nil {
- //清除当天该床位已有的患者
- service.ModeFyScheduleById(sch.ScheduleDate, sch.BedId, sch.ScheduleType, sch.UserOrgId)
- service.CreateScheduleTwo(item)
- }
-
- } else if errcode == nil {
- schedule := models.XtSchedule{
- PartitionId: item.PartitionId,
- BedId: item.BedId,
- PatientId: item.PatientId,
- ScheduleDate: item.ScheduleDate,
- ScheduleType: item.ScheduleType,
- ScheduleWeek: item.ScheduleWeek,
- ModeId: 1,
- Status: 1,
- DialysisMachineName: item.DialysisMachineName,
- }
- service.UpdateScheduleByOrgIdOne(item.PatientId, item.ScheduleDate, item.UserOrgId, &schedule)
- }
- }
- }
-
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: int64(len(errLogs) + failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- if failed_total > 0 {
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "当前日期(" + time.Now().Format("2006-01-02") + " " + GetWeekString(time.Now().Weekday().String()) +
- ")及以前的排班数据" + strconv.FormatInt(int64(failed_total), 10) + "条,不执行导入",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_schedule) + failed_total,
- "success_num": len(schedules),
- "fail_num": int64(len(errLogs)),
- })
- } else {
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: int64(len(errLogs) + failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- if failed_total > 0 {
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "当前日期(" + time.Now().Format("2006-01-02") + " " + GetWeekString(time.Now().Weekday().String()) +
- ")及以前的排班数据" + strconv.FormatInt(int64(failed_total), 10) + "条,不执行导入",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_schedule),
- "success_num": len(schedules),
- "fail_num": int64(len(errLogs)),
- })
- }
- } else {
- log := models.ExportLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule) + failed_total),
- FailNum: int64(len(errLogs) + failed_total),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- if failed_total > 0 {
- err_log := models.ExportErrLog{
- LogType: 2,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "当前日期(" + time.Now().Format("2006-01-02") + " " + GetWeekString(time.Now().Weekday().String()) +
- ")及以前的排班数据" + strconv.FormatInt(int64(failed_total), 10) + "条,不执行导入",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_schedule),
- "success_num": len(schedules),
- "fail_num": int64(len(errLogs)),
- })
- }
- }
-
- }
-
- func (this *ScheduleApiController) ExportScheduleTemplate() {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- return
- }
- utils.ErrorLog("%v", dataBody)
- export_time := time.Now().Unix()
- var schedules []*models.PatientScheduleTemplateItem
- var total_schedule []interface{}
-
- patients, _, _ := service.GetAllPatientList(this.GetAdminUserInfo().CurrentOrgId)
-
- if dataBody["schedule"] != nil || reflect.TypeOf(dataBody["schedule"]).String() == "[]interface {}" {
- tempSchedule := dataBody["schedule"].([]interface{})
- total_schedule = tempSchedule
- for _, schMap := range tempSchedule {
- schMapM := schMap.(map[string]interface{})
- var sch models.PatientScheduleTemplateItem
-
- if schMapM["name"] == nil || reflect.TypeOf(schMapM["name"]).String() != "string" {
- utils.ErrorLog("name")
- return
- }
-
- name, _ := schMapM["name"].(string)
- fmt.Println(name)
- if len(name) == 0 { //名字为空则生成一条导入错误日志
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列的姓名不能为空",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- continue
-
- } else {
- var patient []*models.Patients
- for _, item := range patients {
- if strings.Replace(item.Name, " ", "", -1) == name {
- patient = append(patient, item)
- }
- }
- if len(patient) == 0 { //错误日志
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列的姓名在系统中不存在,请在系统中添加该病人",
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列患者姓名为\"" + name + "\"在系统中不存在,请在系统中添加该患者",
-
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- continue
-
- } else if len(patient) == 1 { //
- sch.PatientID = patient[0].ID
-
- } else if len(patient) > 1 { //出现同名的情况
-
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列" + "患者姓名为" + name + "在当前机构中存在重名,无法确定到具体患者",
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行,第" + schMapM["row"].(string) + "列患者姓名为\"" + name + "\"在当前机构中存在重名,无法确定到具体患者",
-
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- continue
-
- }
- }
-
- if schMapM["schedule_type"] == nil && reflect.TypeOf(schMapM["schedule_type"]).String() != "float64" {
- utils.ErrorLog("schedule_type")
- return
- }
- schedule_type := int64(schMapM["schedule_type"].(float64))
- if schedule_type <= 0 { //班次格式有误,插入日志
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: 1,
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第2行第" + schMapM["row"].(string) + "列的班次格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else {
- sch.TimeType = int8(schedule_type)
- }
-
- if schMapM["template_id"] == nil && reflect.TypeOf(schMapM["template_id"]).String() != "float64" {
- utils.ErrorLog("template_id")
- return
- }
-
- template_id := int64(schMapM["template_id"].(float64))
- sch.TemplateID = template_id
-
- if schMapM["device_number_name"] == nil || reflect.TypeOf(schMapM["device_number_name"]).String() != "string" {
- utils.ErrorLog("device_number_name")
- return
- }
-
- partition_name, _ := schMapM["partition_name"].(string)
- zone, _ := service.FindDeviceZoneByName(partition_name, this.GetAdminUserInfo().CurrentOrgId)
-
- device_number_name, _ := schMapM["device_number_name"].(string)
- if len(device_number_name) == 0 { //分区为空
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: 1,
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)) ,10)+ "行" + "的姓名不能为空",
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行第2列机号格式有误",
-
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else {
- device, err := service.FindDeviceByNameTwo(device_number_name, this.GetAdminUserInfo().CurrentOrgId, zone.ID)
- if err == nil {
- if len(device) == 0 { //没查到数据,插入错误日志
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: 1,
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)), 10) + "行第2列机号格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else if len(device) == 1 {
- sch.DeviceNumberID = device[0].ID
-
- } else if len(device) > 1 { //出现重名,插入错误日志
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: 1,
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "出现两个床位号相同的床位",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- }
- }
- }
-
- if schMapM["schedule_week"] == nil || reflect.TypeOf(schMapM["schedule_week"]).String() != "string" {
- utils.ErrorLog("schedule_week")
- return
- }
- schedule_week, _ := schMapM["schedule_week"].(string)
- if len(schedule_week) == 0 { //周几为空则生成一条导入错误日志
-
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: 1,
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- //ErrMsg: "第" + strconv.FormatInt(int64(schMapM["index"].(float64)) ,10)+ "行" + "的姓名不能为空",
- ErrMsg: "第1行第" + schMapM["row"].(string) + "列的星期名格式有误",
-
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else if schedule_week == "0" { //周几不符合格式则生成一条导入错误日志
-
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: 1,
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- err_log := models.ExportErrLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- ErrMsg: "第1行第" + schMapM["row"].(string) + "列的星期名格式有误",
- Status: 1,
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- }
- service.CreateExportErrLog(&err_log)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
-
- } else {
- schedule_week, _ := strconv.ParseInt(schedule_week, 10, 64)
- sch.Weekday = int8(schedule_week)
-
- }
- treat_mode, _ := schMapM["treat_mode"].(string)
- treat_mode_int, _ := strconv.ParseInt(treat_mode, 10, 64)
- sch.CreateTime = time.Now().Unix()
- sch.ModifyTime = time.Now().Unix()
- sch.TreatMode = treat_mode_int
- sch.Status = 1
- sch.OrgID = this.GetAdminUserInfo().CurrentOrgId
- sch.IsExport = 1
- schedules = append(schedules, &sch)
- }
-
- errLogs, _ := service.FindSchedualTemplateExportLog(this.GetAdminUserInfo().CurrentOrgId, export_time)
-
- //for _, item := range schedules {
- //
- //}
-
- if len(schedules) > 0 {
- err := service.UpdateScheduleTemplateStatus(this.GetAdminUserInfo().CurrentOrgId)
- if err == nil {
- for _, item := range schedules {
- //判斷某個模板下,當天是否有排版,沒有的話就新增
- total := service.ExportScheduleTemplate(item)
- if total == 0 {
- service.CreateScheduleTemplate(item)
- }
- }
- ////查询已经转出或者死亡的患者
- //patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
- //for _, it := range patientList {
- // timeStr := time.Now().Format("2006-01-02")
- // timeLayout := "2006-01-02 15:04:05"
- // timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
- // timenow := timeStringToTime.Unix()
- // service.UpdateScheduleByDeathTime(it.ID, timenow)
- // service.UpdateScheduleItemByPatientId(it.ID)
- //}
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_schedule),
- "success_num": len(schedules),
- "fail_num": int64(len(errLogs)),
- })
- } else {
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_schedule),
- "success_num": len(schedules),
- "fail_num": int64(len(errLogs)),
- })
- }
- } else {
- log := models.ExportLog{
- LogType: 3,
- UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
- TotalNum: int64(len(total_schedule)),
- FailNum: int64(len(errLogs)),
- SuccessNum: int64(len(schedules)),
- CreateTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- ExportTime: export_time,
- Status: 1,
- }
- service.CreateExportLog(&log)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "导入成功",
- "total_num": len(total_schedule),
- "success_num": len(schedules),
- "fail_num": int64(len(errLogs)),
- })
- }
- }
-
- }
-
- func (c *ScheduleApiController) GetInitExcelInitDate() {
-
- thisTime := time.Now()
- thisTime1 := time.Now()
- thisTime2 := time.Now()
- thisTime3 := time.Now()
- thisTime4 := time.Now()
-
- thisTime1 = thisTime1.AddDate(0, 0, 7)
- thisTime2 = thisTime2.AddDate(0, 0, 14)
- thisTime3 = thisTime3.AddDate(0, 0, 21)
- thisTime4 = thisTime4.AddDate(0, 0, 28)
-
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekDay1 := int(thisTime1.Weekday())
- if weekDay1 == 0 {
- weekDay1 = 7
- }
- weekEnd1 := 7 - weekDay1
- weekStart1 := weekEnd1 - 6
- for index := weekStart1; index <= weekEnd1; index++ {
- theDay := thisTime1.AddDate(0, 0, index)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekDay2 := int(thisTime2.Weekday())
- if weekDay2 == 0 {
- weekDay2 = 7
- }
- weekEnd2 := 7 - weekDay2
- weekStart2 := weekEnd2 - 6
- for index := weekStart2; index <= weekEnd2; index++ {
- theDay := thisTime2.AddDate(0, 0, index)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekDay3 := int(thisTime3.Weekday())
- if weekDay3 == 0 {
- weekDay3 = 7
- }
- weekEnd3 := 7 - weekDay3
- weekStart3 := weekEnd3 - 6
- for index := weekStart3; index <= weekEnd3; index++ {
- theDay := thisTime3.AddDate(0, 0, index)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekDay4 := int(thisTime4.Weekday())
- if weekDay4 == 0 {
- weekDay4 = 7
- }
- weekEnd4 := 7 - weekDay4
- weekStart4 := weekEnd4 - 6
- for index := weekStart4; index <= weekEnd4; index++ {
- theDay := thisTime4.AddDate(0, 0, index)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "days": days,
- })
- return
- }
-
- func GetWeekString(week string) string {
- var weekStr string
- switch week {
- case "Sunday":
- weekStr = "周日"
- break
- case "Monday":
- weekStr = "周一"
- break
- case "Tuesday":
- weekStr = "周二"
- break
- case "Wednesday":
- weekStr = "周三"
- break
- case "Thursday":
- weekStr = "周四"
-
- break
- case "Friday":
- weekStr = "周五"
-
- break
- case "Saturday":
- weekStr = "周六"
- break
- default:
- weekStr = ""
- break
-
- }
- return weekStr
- }
-
- func (c *ScheduleApiController) SearchTemplateSchedulePatients() {
- template_id, _ := c.GetInt64("template_id", 0)
- keywords := c.GetString("keywords")
- adminInfo := c.GetAdminUserInfo()
- scheduleItems, _ := service.GetTemplateSchedualPatientsByKeywords(keywords, adminInfo.CurrentOrgId, template_id)
- c.ServeSuccessJSON(map[string]interface{}{
- "schdules": scheduleItems,
- })
- }
-
- func (c *ScheduleApiController) CancelScheduleTemplate() {
- item_id, _ := c.GetInt64("id")
- adminInfo := c.GetAdminUserInfo()
- err := service.UpdateNewScheduleTemplateStatus(item_id, adminInfo.CurrentOrgId)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "取消成功",
- })
- return
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeExportError)
- return
- }
- }
- func (this *ScheduleApiController) GetNextWeekDayScheduleOne() {
- week_type, _ := this.GetInt64("week_type", -1)
- week_time, _ := this.GetInt64("week_time")
- record_date := this.GetString("record_date")
-
- zons := this.GetString("zone")
- zone := strings.Split(zons, ",")
-
- start_time, _ := this.GetInt64("start_time")
- end_time, _ := this.GetInt64("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- //theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- //theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- ids := this.GetString("ids")
- var idStr []string
- if len(ids) > 0 {
- idStr = strings.Split(ids, ",")
- }
- adminUserInfo := this.GetAdminUserInfo()
- var theStartTIme int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theStartTIme = theTime.Unix()
- }
-
- schedule, err := service.GetNextWeekDayScheduleSix(week_type, week_time, start_time, end_time, adminUserInfo.CurrentOrgId, zone, theStartTIme, idStr)
-
- for _, item := range schedule {
- order, _ := service.GetLastDialysisOrder(adminUserInfo.CurrentOrgId, item.PatientId, theStartTIme)
- item.XtDialysisOrderSix = order
- solutionLastWeek, _ := service.GetDialysisSolutionLastWeek(adminUserInfo.CurrentOrgId, item.PatientId, item.ModeId)
- item.DialysisSolution = solutionLastWeek
- prescription, _ := service.GetLastDialysisPrescriptionTwo(adminUserInfo.CurrentOrgId, item.PatientId, item.ModeId, item.ScheduleDate)
- item.DialysisPrescription = prescription
-
- }
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- })
- }
-
- func (this *ScheduleApiController) GetNextWeekDaySchedule() {
-
- week_type, _ := this.GetInt64("week_type", -1)
- week_time, _ := this.GetInt64("week_time")
- record_date := this.GetString("record_date")
-
- zons := this.GetString("zone")
- zone := strings.Split(zons, ",")
-
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTimeStart, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- theTimeEnd, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- ids := this.GetString("ids")
- var idStr []string
- if len(ids) > 0 {
- idStr = strings.Split(ids, ",")
- }
- adminUserInfo := this.GetAdminUserInfo()
- var theStartTIme int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theStartTIme = theTime.Unix()
- }
-
- schedule, err := service.GetNextWeekDaySchedule(week_type, week_time, theTimeStart.Unix(), theTimeEnd.Unix(), adminUserInfo.CurrentOrgId, zone, theStartTIme, idStr)
-
- for _, item := range schedule {
- AssessmentBefor, _ := service.GetAssessmentBeforListLastWeek(item.ScheduleDate, item.PatientId, item.UserOrgId)
- item.XtAssessmentBeforeDislysis = AssessmentBefor
- doctorAdvices, _ := service.GetDoctorAdviceLastWeek(item.UserOrgId, item.PatientId, item.ScheduleDate)
- item.DoctorAdvice = doctorAdvices
-
- hisDoctorAdvice, _ := service.GetHisDoctorAdviceListLastWeek(item.UserOrgId, item.PatientId, item.ScheduleDate)
-
- item.HisDoctorAdviceInfo = hisDoctorAdvice
-
- solutionLastWeek, _ := service.GetDialysisSolutionLastWeek(item.UserOrgId, item.PatientId, item.ModeId)
- item.DialysisSolution = solutionLastWeek
-
- templateList, _ := service.GetHisPrescriptionTemplateList(item.UserOrgId, item.PatientId, item.ModeId)
-
- item.HisPrescriptionTemplate = templateList
-
- }
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- })
- }
-
- func (this *ScheduleApiController) GetThreeWeekList() {
- start_time := this.GetString("start_time")
- end_time := this.GetString("end_time")
- partition_id, _ := this.GetInt64("partition_id")
- schedule_type, _ := this.GetInt64("schedule_type")
- fmt.Println(partition_id, schedule_type)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- var theStartTIme int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theStartTIme = theTime.Unix()
- }
- var theEndtTIme int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theEndtTIme = theTime.Unix()
- }
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- partitions, _ := service.GetSchedulePartitionPanel(orgId)
- list, err := service.GetThreeWeekList(theStartTIme, theEndtTIme, orgId, schedule_type, partition_id)
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "partitions": partitions,
- })
- }
-
- func (this *ScheduleApiController) GetAllZones() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- zones, err := service.GetAllZoneOne(orgId)
- devicenumber, err := service.GetAllBedNumberList(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "zones": zones,
- "devicenumber": devicenumber,
- })
- }
-
- func (this *ScheduleApiController) GetCopyPatientSchedules() {
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- start_time, _ := this.GetInt64("start_time")
-
- end_time, _ := this.GetInt64("end_time")
-
- copy_startime, _ := this.GetInt64("copy_startime")
-
- copy_endtime, _ := this.GetInt64("copy_endtime")
-
- //获取本周患者排班
- schedules, _ := service.GetWeekSchedules(orgId, start_time, end_time)
-
- //先清除复制周的排班
- errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
- fmt.Println(errcode)
- var err error
- for _, item := range schedules {
- //fmt.Println(item.StartTime+604800)
- //礼拜1
- if item.ScheduleWeek == 1 {
- item.ScheduleDate = copy_startime
- }
- if item.ScheduleWeek == 2 {
- item.ScheduleDate = copy_startime + 86400
- }
- if item.ScheduleWeek == 3 {
- item.ScheduleDate = copy_startime + 172800
- }
- if item.ScheduleWeek == 4 {
- item.ScheduleDate = copy_startime + 259200
- }
- if item.ScheduleWeek == 5 {
- item.ScheduleDate = copy_startime + 345600
- }
-
- if item.ScheduleWeek == 6 {
- item.ScheduleDate = copy_startime + 432000
- }
- //礼拜天
- if item.ScheduleWeek == 7 {
- item.ScheduleDate = copy_endtime
- }
- schedule := models.XtSchedule{
- UserOrgId: item.UserOrgId,
- PartitionId: item.PartitionId,
- BedId: item.BedId,
- PatientId: item.PatientId,
- ScheduleDate: item.ScheduleDate,
- ScheduleType: item.ScheduleType,
- ScheduleWeek: item.ScheduleWeek,
- ModeId: item.ModeId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- }
-
- var DialysisMachineName string
-
- so, _ := service.GetDialysisSolutionTwo(adminUserInfo.CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(adminUserInfo.CurrentOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
- schedule.IsExport = 4000
- err = service.AddPatientSchedule(&schedule)
-
- }
- patientList, _ := service.GetDeathPatient(this.GetAdminUserInfo().CurrentOrgId)
- timeStr := time.Now().Format("2006-01-02")
- timeLayout := "2006-01-02 15:04:05"
- timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
- timenow := timeStringToTime.Unix()
- for _, it := range patientList {
-
- service.UpdateScheduleByDeathTime(it.ID, timenow)
-
- service.UpdateScheduleItemByPatientId(it.ID)
- }
-
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "msg",
- })
- return
- //查询复制中的排班日期是否存在
- //_, errcode := service.GetLastWeekSchedule(orgId, copy_startime, copy_endtime)
- //
- //if errcode == gorm.ErrRecordNotFound {
- // //如果没有直接新增
- //
- // for _, item := range schedules {
- // //fmt.Println(item.StartTime+604800)
- // //礼拜1
- // if item.ScheduleWeek == 1 {
- // item.ScheduleDate = copy_startime
- // }
- // if item.ScheduleWeek == 2 {
- // item.ScheduleDate = copy_startime + 86400
- // }
- // if item.ScheduleWeek == 3 {
- // item.ScheduleDate = copy_startime + 172800
- // }
- // if item.ScheduleWeek == 4 {
- // item.ScheduleDate = copy_startime + 259200
- // }
- // if item.ScheduleWeek == 5 {
- // item.ScheduleDate = copy_startime + 345600
- // }
- //
- // if item.ScheduleWeek == 6 {
- // item.ScheduleDate = copy_startime + 432000
- // }
- // //礼拜天
- // if item.ScheduleWeek == 0 {
- // item.ScheduleDate = copy_endtime
- // }
- // schedule := models.XtSchedule{
- // UserOrgId: item.UserOrgId,
- // PartitionId: item.PartitionId,
- // BedId: item.BedId,
- // PatientId: item.PatientId,
- // ScheduleDate: item.ScheduleDate,
- // ScheduleType: item.ScheduleType,
- // ScheduleWeek: item.ScheduleWeek,
- // ModeId: item.ModeId,
- // Status: 1,
- // CreatedTime: time.Now().Unix(),
- // }
- //
- // err := service.AddPatientSchedule(&schedule)
- // if err != nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // this.ServeSuccessJSON(map[string]interface{}{
- // "schedule": schedule,
- // })
- // }
- //} else if errcode == nil {
- //
- // //先清除复制周的排班
- // errcode := service.UpdatePatientSchedule(orgId, copy_startime, copy_endtime)
- // fmt.Println(errcode)
- // for _, item := range schedules {
- // //fmt.Println(item.StartTime+604800)
- // //礼拜1
- // if item.ScheduleWeek == 1 {
- // item.ScheduleDate = copy_startime
- // }
- // if item.ScheduleWeek == 2 {
- // item.ScheduleDate = copy_startime + 86400
- // }
- // if item.ScheduleWeek == 3 {
- // item.ScheduleDate = copy_startime + 172800
- // }
- // if item.ScheduleWeek == 4 {
- // item.ScheduleDate = copy_startime + 259200
- // }
- // if item.ScheduleWeek == 5 {
- // item.ScheduleDate = copy_startime + 345600
- // }
- //
- // if item.ScheduleWeek == 6 {
- // item.ScheduleDate = copy_startime + 432000
- // }
- // //礼拜天
- // if item.ScheduleWeek == 0 {
- // item.ScheduleDate = copy_endtime
- // }
- // schedule := models.XtSchedule{
- // UserOrgId: item.UserOrgId,
- // PartitionId: item.PartitionId,
- // BedId: item.BedId,
- // PatientId: item.PatientId,
- // ScheduleDate: item.ScheduleDate,
- // ScheduleType: item.ScheduleType,
- // ScheduleWeek: item.ScheduleWeek,
- // ModeId: item.ModeId,
- // Status: 1,
- // CreatedTime: time.Now().Unix(),
- // }
- //
- // err := service.AddPatientSchedule(&schedule)
- // if err != nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // }
- // this.ServeSuccessJSON(map[string]interface{}{
- // "schedule": schedule,
- // })
- // }
- //}
- }
-
- func (this *ScheduleApiController) SaveRemindPrint() {
-
- id, _ := this.GetInt64("id")
- anticoagulants, _ := this.GetInt64("anticoagulant")
- anticoagulant_zongliang, _ := this.GetInt64("anticoagulant_zongliang")
- classes, _ := this.GetInt64("classes")
- dialyzers, _ := this.GetInt64("dialyzers")
- doctor_advice, _ := this.GetInt64("doctor_advice")
- mode, _ := this.GetInt64("mode")
- name, _ := this.GetInt64("name")
- number, _ := this.GetInt64("number")
- perfusion_apparatus, _ := this.GetInt64("perfusion_apparatus")
- prescription_status, _ := this.GetInt64("prescription_status")
- week, _ := this.GetInt64("week")
- zone, _ := this.GetInt64("zone")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- setting := models.XtRemindPrintSetting{
- Anticoagulant: anticoagulants,
- Classes: classes,
- AnticoagulantZongliang: anticoagulant_zongliang,
- Dialyzers: dialyzers,
- DoctorAdvice: doctor_advice,
- Mode: mode,
- Name: name,
- Number: number,
- PerfusionApparatus: perfusion_apparatus,
- PrescriptionStatus: prescription_status,
- Week: week,
- Zone: zone,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
- _, errcode := service.GetSettingById(id)
- if errcode == gorm.ErrRecordNotFound {
- err := service.CreateSetting(&setting)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "setting": setting,
- })
- } else if errcode == nil {
- err := service.UpdatedRemindPrint(&setting, id)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "setting": setting,
- })
- }
-
- }
- func (this *ScheduleApiController) GetRemindPrintList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- list, err := service.GetRemindPrintList(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *ScheduleApiController) GetBloodScheduleList() {
-
- week_type, _ := this.GetInt64("week_type", -1)
- week_time, _ := this.GetInt64("week_time")
- zones := this.GetString("zone")
- zone := strings.Split(zones, ",")
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- ids := this.GetString("ids")
- var idStr []string
- if len(ids) > 0 {
- idStr = strings.Split(ids, ",")
- }
- thisTime := time.Now()
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekTitle := make([]string, 0)
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekTitle = append(weekTitle, indexWeek)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- var targetDayStr string
- var startTime string
- switch week_type {
- case 0:
- startTime = days[0]
- targetDayStr = days[6]
- break
- case 1:
- targetDayStr = days[0]
- break
- case 2:
- targetDayStr = days[1]
-
- break
- case 3:
- targetDayStr = days[2]
-
- break
- case 4:
- targetDayStr = days[3]
-
- break
- case 5:
- targetDayStr = days[4]
-
- break
- case 6:
- targetDayStr = days[5]
-
- break
- case 7:
- targetDayStr = days[6]
-
- break
- }
- targetDay, parseErr := utils.ParseTimeStringToTime("2006-01-02", targetDayStr)
-
- if parseErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- if week_type > 0 {
-
- list, total, err := service.GetWeekDayScheduleByIdThee(orgId, targetDay.Unix(), week_time, zone, limit, page, idStr)
-
- for _, item := range list {
- order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
- item.XtDialysisOrderSix = order
- advicehisList, _ := service.GetHisDoctorAdviceList(orgId, item.PatientId, targetDay.Unix())
- item.HisDoctorAdviceInfo = advicehisList
- advices, _ := service.GetDoctorAdviceListSchedule(orgId, item.PatientId)
- item.DoctorAdvice = advices
- prescription, _ := service.GetLastDialysisPrescriptionTwo(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
- item.DialysisPrescription = prescription
- dialysisSolution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId)
- item.DialysisSolution = dialysisSolution
- lastDialysisAfter, _ := service.GetLastDialysisAfter(orgId, item.PatientId, item.ScheduleDate)
- item.LastAfterWeight = lastDialysisAfter
- assessmentBeforFourty, _ := service.GetAssessmentBeforFourty(orgId, item.PatientId, item.ScheduleDate)
- item.XtAssessmentBeforeDislysis = assessmentBeforFourty
-
- templateList, _ := service.GetHisPrescriptionTemplateList(orgId, item.PatientId, item.ModeId)
-
- item.HisPrescriptionTemplate = templateList
-
- }
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "day": targetDayStr,
- "total": total,
- })
- }
-
- if week_type == 0 {
- startDate, _ := utils.ParseTimeStringToTime("2006-01-02", startTime)
- list, total, err := service.GetWeekDayScheduleByIdTwo(orgId, targetDay.Unix(), week_time, startDate.Unix(), zone, limit, page, idStr)
- for _, item := range list {
-
- order, _ := service.GetLastDialysisOrder(orgId, item.PatientId, targetDay.Unix())
- item.XtDialysisOrderSix = order
- advicehisList, _ := service.GetHisDoctorAdviceList(orgId, item.PatientId, targetDay.Unix())
- item.HisDoctorAdviceInfo = advicehisList
- advices, _ := service.GetDoctorAdviceListSchedule(orgId, item.PatientId)
- item.DoctorAdvice = advices
- prescription, _ := service.GetLastDialysisPrescriptionTwo(orgId, item.PatientId, item.ModeId, item.ScheduleDate)
- item.DialysisPrescription = prescription
- dialysisSolution, _ := service.GetLastDialysisSolution(orgId, item.PatientId, item.ModeId)
- item.DialysisSolution = dialysisSolution
-
- lastDialysisAfter, _ := service.GetLastDialysisAfter(orgId, item.PatientId, item.ScheduleDate)
- item.LastAfterWeight = lastDialysisAfter
-
- assessmentBeforFourty, _ := service.GetAssessmentBeforFourty(orgId, item.PatientId, item.ScheduleDate)
- item.XtAssessmentBeforeDislysis = assessmentBeforFourty
-
- templateList, _ := service.GetHisPrescriptionTemplateList(orgId, item.PatientId, item.ModeId)
-
- item.HisPrescriptionTemplate = templateList
-
- }
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "day": targetDayStr,
- "total": total,
- })
- }
-
- }
-
- func (this *ScheduleApiController) GetPrintList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- list, err := service.GetRemindPrintList(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- func (this *ScheduleApiController) GetAllZoneList() {
-
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- zoneList, err := service.GetAllZoneOne(orgId)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "zoneList": zoneList,
- })
- }
-
- func (this *ScheduleApiController) GetPatientScheduleCount() {
- patitionIdStr := this.GetString("partition_id")
- week, _ := this.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
- ids := strings.Split(patitionIdStr, ",")
- adminUserInfo := this.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- thisTime := time.Now()
- weekDay := int(thisTime.Weekday())
- if week < 1 || week > 4 {
- week = 2
- }
- if week == 1 {
- thisTime = thisTime.AddDate(0, 0, -7)
- } else if week == 3 {
- thisTime = thisTime.AddDate(0, 0, 7)
- } else if week == 4 {
- thisTime = thisTime.AddDate(0, 0, 14)
- }
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekTitle := make([]string, 0)
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekTitle = append(weekTitle, indexWeek)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekStartDay := thisTime.AddDate(0, 0, weekStart)
- weekEndDay := thisTime.AddDate(0, 0, weekEnd)
- weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
- weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
-
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
- weekStartPoint := theStarTime.Unix()
- weekEndPoint := theEndTime.Unix()
-
- list, err := service.GetPatientScheduleCount(orgId, weekStartPoint, weekEndPoint, ids)
- _, total, _ := service.GetTotalBedNumber(orgId, ids)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- })
- }
-
- func (c *ScheduleApiController) GetWeekPanelsOne() {
-
- data, _ := c.GetInt64("data", 1)
- patitionIdStr := c.GetString("patitionid")
-
- ids := strings.Split(patitionIdStr, ",")
-
- adminInfo := c.GetAdminUserInfo()
- thisTime := time.Now()
- year, monthTime, day := thisTime.Date()
- month := int(monthTime)
- _, theWeek := thisTime.ISOWeek()
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekDays := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekDays = append(weekDays, indexWeek)
- }
-
- returnData := map[string]interface{}{
- "year": year,
- "month": month,
- "day": day,
- "theWeek": theWeek,
- "weekDay": weekDay,
- "weekDays": weekDays,
- }
-
- if data == 1 {
- partitions, _ := service.GetSchedulePartitionPanelTwo(adminInfo.CurrentOrgId, ids)
- returnData["partitions"] = partitions
- }
-
- c.ServeSuccessJSON(returnData)
- return
- }
-
- func (c *ScheduleApiController) GetScheduleOne() {
-
- week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
- patitionIdStr := c.GetString("patitionid")
- ids := strings.Split(patitionIdStr, ",")
- //fmt.Println("patitonStr", ids)
- schedule_type, _ := c.GetInt64("schedule_type")
- is_before, _ := c.GetInt64("is_before")
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
-
- adminInfo := c.GetAdminUserInfo()
-
- thisTime := time.Now()
-
- today := thisTime.Format("2006-01-02")
- if week < 1 || week > 4 {
- week = 2
- }
- if week == 1 {
- thisTime = thisTime.AddDate(0, 0, -7)
- } else if week == 3 {
- thisTime = thisTime.AddDate(0, 0, 7)
- } else if week == 4 {
- thisTime = thisTime.AddDate(0, 0, 14)
- }
-
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekTitle := make([]string, 0)
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekTitle = append(weekTitle, indexWeek)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekStartDay := thisTime.AddDate(0, 0, weekStart)
- weekEndDay := thisTime.AddDate(0, 0, weekEnd)
- weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
- weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
-
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
-
- weekStartPoint := theStarTime.Unix()
- weekEndPoint := theEndTime.Unix()
- if is_before > 0 {
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, start_time, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, end_time, loc)
- weekStartPoint = theStarTime.Unix()
- weekEndPoint = theEndTime.Unix()
- }
- schdules, _ := service.GetWeekScheduleTwo(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
- timenow := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timenow)
- if adminInfo.CurrentOrgId == 10346 || adminInfo.CurrentOrgId == 10585 || adminInfo.CurrentOrgId == 10495 {
-
- if len(schdules) > 0 {
- //获取长期医嘱里面的透析器灌流器
- for _, item := range schdules {
- if item.ScheduleDate >= timeNewDate.Unix() {
- solution, _ := service.GetLongSolutionByModeId(item.PatientId, item.ModeId, item.UserOrgId)
- service.UpdateScheduleByDialysis(item.PatientId, item.ModeId, item.ScheduleDate, item.UserOrgId, solution.DialyzerPerfusionApparatus, item.ScheduleType)
- }
-
- }
-
- }
- }
-
- //查询排班里面的空透析器
- if adminInfo.CurrentOrgId == 10375 || adminInfo.CurrentOrgId == 10510 || adminInfo.CurrentOrgId == 9538 {
-
- schedulesFive, _ := service.GetWeekScheduleFive(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
-
- for _, item := range schedulesFive {
- if item.ScheduleDate >= timeNewDate.Unix() {
- solution, _ := service.GetLongSolutionByModeId(item.PatientId, item.ModeId, item.UserOrgId)
- var DialysisMachineName string
- if len(solution.DialysisDialyszers) > 0 {
- DialysisMachineName = solution.DialysisDialyszers
- }
- if len(solution.DialyzerPerfusionApparatus) > 0 {
- DialysisMachineName = DialysisMachineName + "," + solution.DialyzerPerfusionApparatus
- }
-
- if len(solution.DialysisIrrigation) > 0 {
- DialysisMachineName = DialysisMachineName + "," + solution.DialysisIrrigation
- }
- item.DialysisMachineName = DialysisMachineName
- service.UpdateSchOne(item.ID, item.DialysisMachineName)
- }
- if item.ScheduleDate < timeNewDate.Unix() {
- prescriptionList, _ := service.GetDialysisPrescriptionList(item.PatientId, item.UserOrgId, item.ScheduleDate)
- var DialysisMachineName string
- if len(prescriptionList.DialysisDialyszers) > 0 {
- DialysisMachineName = prescriptionList.DialysisDialyszers
- }
- if len(prescriptionList.DialyzerPerfusionApparatus) > 0 {
- DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialyzerPerfusionApparatus
- }
-
- if len(prescriptionList.DialysisIrrigation) > 0 {
- DialysisMachineName = DialysisMachineName + "," + prescriptionList.DialysisIrrigation
- }
- item.DialysisMachineName = DialysisMachineName
- service.UpdateSchOne(item.ID, item.DialysisMachineName)
- }
-
- }
-
- }
- schedulesGroup, _ := service.GetScheduleTotalCount(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type)
- c.ServeSuccessJSON(map[string]interface{}{
- "days": days,
- "weekTitle": weekTitle,
- "schdules": schdules,
- "today": today,
- "schedulesGroup": schedulesGroup,
- })
- return
- }
-
- func (c *ScheduleApiController) GetScheduleTwo() {
-
- week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
-
- patitionIdStr := c.GetString("patitionid")
-
- ids := strings.Split(patitionIdStr, ",")
-
- schedule_type, _ := c.GetInt64("schedule_type")
-
- adminInfo := c.GetAdminUserInfo()
- weekDateStr := c.GetString("week_date")
-
- WeekDayIds := strings.Split(weekDateStr, ",")
-
- thisTime := time.Now()
- today := thisTime.Format("2006-01-02")
- if week < 1 || week > 4 {
- week = 2
- }
- if week == 1 {
- thisTime = thisTime.AddDate(0, 0, -7)
- } else if week == 3 {
- thisTime = thisTime.AddDate(0, 0, 7)
- } else if week == 4 {
- thisTime = thisTime.AddDate(0, 0, 14)
- }
-
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekTitle := make([]string, 0)
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekTitle = append(weekTitle, indexWeek)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekStartDay := thisTime.AddDate(0, 0, weekStart)
- weekEndDay := thisTime.AddDate(0, 0, weekEnd)
- weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
- weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
-
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
- weekStartPoint := theStarTime.Unix()
- weekEndPoint := theEndTime.Unix()
- schdules, _ := service.GetWeekScheduleThree(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type, WeekDayIds)
- c.ServeSuccessJSON(map[string]interface{}{
- "days": days,
- "weekTitle": weekTitle,
- "schdules": schdules,
- "today": today,
- })
- return
- }
-
- func (c *ScheduleApiController) GetScheduleThreeList() {
-
- week, _ := c.GetInt64("weekTime", 0) //1:last, 2:this 3:next 4 nextTwo
-
- patitionIdStr := c.GetString("patitionid")
-
- ids := strings.Split(patitionIdStr, ",")
-
- schedule_type, _ := c.GetInt64("schedule_type")
-
- adminInfo := c.GetAdminUserInfo()
- weekDateStr := c.GetString("week_date")
-
- WeekDayIds := strings.Split(weekDateStr, ",")
-
- thisTime := time.Now()
- today := thisTime.Format("2006-01-02")
- if week < 1 || week > 4 {
- week = 2
- }
- if week == 1 {
- thisTime = thisTime.AddDate(0, 0, -7)
- } else if week == 3 {
- thisTime = thisTime.AddDate(0, 0, 7)
- } else if week == 4 {
- thisTime = thisTime.AddDate(0, 0, 14)
- }
-
- weekDay := int(thisTime.Weekday())
- if weekDay == 0 {
- weekDay = 7
- }
- weekEnd := 7 - weekDay
- weekStart := weekEnd - 6
- weekTitle := make([]string, 0)
- days := make([]string, 0)
- for index := weekStart; index <= weekEnd; index++ {
- theDay := thisTime.AddDate(0, 0, index)
- indexYear, indexMonthTime, indexDay := theDay.Date()
- indexMonth := int(indexMonthTime)
- indexWeek := strconv.Itoa(indexYear) + "." + strconv.Itoa(indexMonth) + "." + strconv.Itoa(indexDay)
- weekTitle = append(weekTitle, indexWeek)
- days = append(days, theDay.Format("2006-01-02"))
- }
-
- weekStartDay := thisTime.AddDate(0, 0, weekStart)
- weekEndDay := thisTime.AddDate(0, 0, weekEnd)
- weekStartTime := weekStartDay.Format("2006-01-02") + " 00:00:00"
- weekEndTime := weekEndDay.Format("2006-01-02") + " 23:59:59"
-
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStarTime, _ := time.ParseInLocation(timeLayout, weekStartTime, loc)
- theEndTime, _ := time.ParseInLocation(timeLayout, weekEndTime, loc)
- weekStartPoint := theStarTime.Unix()
- weekEndPoint := theEndTime.Unix()
- schdules, _ := service.GetWeekScheduleFour(adminInfo.CurrentOrgId, weekStartPoint, weekEndPoint, ids, schedule_type, WeekDayIds)
-
- if len(schdules) > 0 {
- for _, item := range schdules {
- listObj, _ := service.GetNextScheduleByList(item.PatientId, item.ScheduleDate, item.UserOrgId)
- item.SchedulePatientsOne = listObj
- }
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "days": days,
- "weekTitle": weekTitle,
- "schdules": schdules,
- "today": today,
- })
- return
- }
-
- func (c *ScheduleApiController) SaveScheduleTemplate() {
-
- template_id, _ := c.GetInt64("template_id")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- template := models.ScheduleTemplate{
- TemplateId: template_id,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
-
- _, errcodes := service.GetScheudleTemplateById(orgId)
- if errcodes == gorm.ErrRecordNotFound {
- service.CreateXtscheduleTemplate(&template)
- } else if errcodes == nil {
- service.UpdateXtScheduleTemplate(&template, orgId)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- return
-
- }
-
- func (c *ScheduleApiController) GetScheduleTemplate() {
-
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- template, _ := service.GetScheduleTemplate(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "template": template,
- })
- return
- }
-
- func (c *ScheduleApiController) ChangeFuncPrint() {
-
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
- is_open, _ := c.GetInt64("is_open")
- dataPrint := models.XtDataPrint{
- UserOrgId: orgId,
- IsOpen: is_open,
- Status: 1,
- Ctime: time.Now().Unix(),
- }
-
- _, errcode := service.GetDataPrintByOrgId(orgId)
- if errcode == gorm.ErrRecordNotFound {
- service.CreateDataPrint(&dataPrint)
- c.ServeSuccessJSON(map[string]interface{}{
- "dataPrint": dataPrint,
- })
- return
- } else if errcode == nil {
- service.UpdteDataPrint(orgId, &dataPrint)
- c.ServeSuccessJSON(map[string]interface{}{
- "dataPrint": dataPrint,
- })
- return
- }
-
- }
-
- func (c *ScheduleApiController) GetDataPrint() {
-
- adminUserInfo := c.GetAdminUserInfo()
- orgId := adminUserInfo.CurrentOrgId
-
- dataPrint, _ := service.GetDataPrint(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "dataPrint": dataPrint,
- })
- return
- }
-
- func (c *ScheduleApiController) GetNextWeekPanels() {
- start_time, _ := c.GetInt64("start_time")
- fmt.Println("start_time", start_time)
- end_time, _ := c.GetInt64("end_time")
- fmt.Println("end_time", end_time)
- orgId := c.GetAdminUserInfo().CurrentOrgId
- schedule, _ := service.GetNextWeekPanels(start_time, end_time, orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- })
- }
-
- func (c *ScheduleApiController) SynchroSchedule() {
-
- template_id, _ := c.GetInt64("template_id")
- copy_startime, _ := c.GetInt64("copy_startime")
- copy_endtime, _ := c.GetInt64("copy_endtime")
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- //根据模板ID获取模板数据
- list, _ := service.GetTemplateListByTemplateId(template_id, orgId)
- fmt.Println(len(list))
-
- //数据去重操作
- list = RemoveRepeatedScheduleTemplate(list)
-
- recordDateStr := time.Now().Format("2006-01-02")
- recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- nowtime := recordDate.Unix()
- fmt.Println("今日时间", nowtime)
- fmt.Println("后期日期", copy_startime)
- var tuesday int64
- var wednesday int64
- var thursday int64
- var friday int64
- var saturday int64
- //
- //如果选择的开始日期大于当前日期
- if copy_startime > nowtime {
- //清空该时间段的所有排班数据
- service.DeletePatientSchedule(copy_startime, copy_endtime, orgId)
- tuesday = copy_startime + 86400
- wednesday = copy_startime + 172800
- thursday = copy_startime + 259200
- friday = copy_startime + 345600
- saturday = copy_startime + 432000
- for _, item := range list {
- if item.Weekday == 1 {
- item.ScheduleDate = copy_startime
- }
- if item.Weekday == 2 {
- item.ScheduleDate = tuesday
- }
- if item.Weekday == 3 {
- item.ScheduleDate = wednesday
- }
- if item.Weekday == 4 {
- item.ScheduleDate = thursday
- }
- if item.Weekday == 5 {
- item.ScheduleDate = friday
- }
- if item.Weekday == 6 {
- item.ScheduleDate = saturday
- }
- if item.Weekday == 7 {
- item.ScheduleDate = copy_endtime
- }
-
- //根据床位号获取区号
- number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
- item.ZoneId = number.ZoneID
- }
- for _, item := range list {
- schedule := models.XtSchedule{
- UserOrgId: orgId,
- PartitionId: item.ZoneId,
- BedId: item.DeviceNumberID,
- PatientId: item.PatientID,
- ScheduleDate: item.ScheduleDate,
- ScheduleType: item.TimeType,
- ScheduleWeek: item.Weekday,
- ModeId: item.TreatMode,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: 0,
- IsExport: 200000,
- }
-
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(c.GetAdminUserInfo().CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
- service.CreatePatientSchedule(&schedule)
-
- service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
-
- }
- }
- //如果选择的日期小于当前日期,只同步今日以后的数据
- if copy_startime <= nowtime {
- //清空今日以后的数据
- service.DeletePatientScheduleToday(nowtime, copy_endtime, orgId)
- var tuesday int64
- var wednesday int64
- var thursday int64
- var friday int64
- var saturday int64
-
- tuesday = copy_startime + 86400
- wednesday = copy_startime + 172800
- thursday = copy_startime + 259200
- friday = copy_startime + 345600
- saturday = copy_startime + 432000
-
- for _, item := range list {
- if item.Weekday == 1 {
- item.ScheduleDate = copy_startime
- }
- if item.Weekday == 2 {
- item.ScheduleDate = tuesday
- }
- if item.Weekday == 3 {
- item.ScheduleDate = wednesday
- }
- if item.Weekday == 4 {
- item.ScheduleDate = thursday
- }
- if item.Weekday == 5 {
- item.ScheduleDate = friday
- }
- if item.Weekday == 6 {
- item.ScheduleDate = saturday
- }
- if item.Weekday == 7 {
- item.ScheduleDate = copy_endtime
- }
-
- //根据床位号获取区号
- number, _ := service.GetBedNumberById(item.DeviceNumberID, orgId)
- item.ZoneId = number.ZoneID
- }
- for _, item := range list {
- // 同步今日以后的数据
- if item.ScheduleDate > nowtime {
- schedule := models.XtSchedule{
- UserOrgId: orgId,
- PartitionId: item.ZoneId,
- BedId: item.DeviceNumberID,
- PatientId: item.PatientID,
- ScheduleDate: item.ScheduleDate,
- ScheduleType: item.TimeType,
- ScheduleWeek: item.Weekday,
- ModeId: item.TreatMode,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: 0,
- }
-
- var DialysisMachineName string
- so, _ := service.GetDialysisSolutionTwo(c.GetAdminUserInfo().CurrentOrgId, schedule.PatientId, schedule.ModeId)
- filedRecordOne, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "透析器")
- filedRecordTwo, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "灌流器")
- filedRecordThree, _ := service.FindFiledBy(c.GetAdminUserInfo().CurrentOrgId, "透析器/灌流器")
-
- if filedRecordOne.IsShow == 1 {
- DialysisMachineName = so.DialysisDialyszers
- }
- if filedRecordThree.IsShow == 1 {
- if len(DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialyzerPerfusionApparatus
-
- } else {
- DialysisMachineName = so.DialyzerPerfusionApparatus
-
- }
- }
- if filedRecordTwo.IsShow == 1 {
- if len(schedule.DialysisMachineName) > 0 {
- DialysisMachineName = DialysisMachineName + "," + so.DialysisIrrigation
-
- } else {
- DialysisMachineName = so.DialysisIrrigation
-
- }
- }
- schedule.DialysisMachineName = DialysisMachineName
- service.CreatePatientSchedule(&schedule)
- }
- }
- }
-
- returnData := make(map[string]interface{}, 0)
- returnData["list"] = list
- c.ServeSuccessJSON(returnData)
- return
- }
-
- func (c *ScheduleApiController) GetPatientScheduleTempalate() {
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- tempalate, _ := service.GetPatientScheduleTempalate(orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "schedule": tempalate,
- })
- }
-
- func (c *ScheduleApiController) GetSolutionSchedule() {
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- solution, _ := service.GetSolutionSchedule(orgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "solution": solution,
- })
- return
- }
-
- func RemoveRepeatedScheduleTemplate(arr []*models.VmPatientScheduleTemplateItem) (newArr []*models.VmPatientScheduleTemplateItem) {
- newArr = make([]*models.VmPatientScheduleTemplateItem, 0)
- for i := 0; i < len(arr); i++ {
- repeat := false
- for j := i + 1; j < len(arr); j++ {
- if arr[i].TemplateID == arr[j].TemplateID && arr[i].PatientID == arr[j].PatientID && arr[i].Weekday == arr[j].Weekday {
- repeat = true
- break
- }
- }
- if !repeat {
- newArr = append(newArr, arr[i])
- }
- }
- return
- }
-
- func (c *ScheduleApiController) DeleteScheduleTwo() {
- id, _ := c.GetInt64("id", 0)
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminINfo := c.GetAdminUserInfo()
-
- schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
- timeNow := time.Now().Format("2006-01-02")
- timeTemplate := "2006-01-02"
-
- tm := time.Unix(int64(schedule.ScheduleDate), 0)
- timeStr := tm.Format(timeTemplate)
- if timeNow > timeStr {
- utils.ErrorLog(timeNow)
- utils.ErrorLog(timeStr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCantSetScheduleBeforeNow)
- return
- }
- if schedule == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
- return
- }
-
- order, err := service.GetOneDialysisOrder(adminINfo.CurrentOrgId, schedule.ScheduleDate, schedule.PatientId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
-
- if order != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDelScheduleFailByDialysisTwo)
- return
- }
-
- schedule.Status = 0
- schedule.UpdatedTime = time.Now().Unix()
- err = service.UpdateSchedule(schedule)
-
- if err == nil {
- redis := service.RedisClient()
- //处方
- keyOne := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
-
- //医嘱
- keyTwo := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_befores_list_all"
- redis.Set(keySix, "", time.Second)
- keyThree := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
-
- keyFour := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":monitor_record_list_all"
- redis.Set(keyFour, "", time.Second)
-
- keyFive := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":treatment_summarys_list_all"
- redis.Set(keyFive, "", time.Second)
-
- keySeven := strconv.FormatInt(adminINfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(schedule.ScheduleDate, 10) + ":dialysis_orders_list_all"
- redis.Set(keySeven, "", time.Second)
- defer redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteScheduleFail)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "schedule": &schedule,
- })
-
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
-
- func (c *ScheduleApiController) ChangeScheduleTen() {
-
- id, _ := c.GetInt64("id", 0)
- bed_id, _ := c.GetInt64("bed_id")
- mode_id, _ := c.GetInt64("mode_id")
- schedule_type, _ := c.GetInt64("schedule_type")
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminINfo := c.GetAdminUserInfo()
-
- schedule, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
-
- //获取分区号
- number, _ := service.GetZoneId(bed_id, adminINfo.CurrentOrgId)
- if schedule == nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
- return
- }
- //如果透析模式相等 床位号相等,班次相等
- if mode_id == schedule.ModeId && bed_id == schedule.BedId && schedule_type == schedule.ScheduleType && number.ZoneID == schedule.PartitionId {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorScheduleCode)
- return
- } else {
-
- //如果床位未发生改变
- if bed_id == schedule.BedId {
-
- //查询该床位今天是否存在排班
- sch, _ := service.GetScheduleByBedId(bed_id, schedule_type, adminINfo.CurrentOrgId, schedule.ScheduleDate)
- fmt.Println("schwowowoowowowowowo", sch.ID, sch.PatientId)
-
- if sch.ID == 0 {
- ////删除排班
- //service.UpdateScheduleByScheduleId(id)
-
- //五四的床位
- xtSchedule := models.XtSchedule{
- UserOrgId: adminINfo.CurrentOrgId,
- PartitionId: number.ZoneID,
- BedId: bed_id,
- PatientId: schedule.PatientId,
- ScheduleDate: schedule.ScheduleDate,
- ScheduleType: schedule_type,
- ScheduleWeek: schedule.ScheduleWeek,
- ModeId: mode_id,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: 0,
- IsExport: 999999,
- DialysisMachineName: "",
- }
- //service.CreateNewSchedule(xtSchedule)
-
- service.UpdateScheduleSixTy(id, xtSchedule)
- }
-
- if schedule_type != schedule.ScheduleType && sch.ID > 0 {
- //存在排班
- if sch.ID > 0 {
-
- xtSchedule := models.XtSchedule{
- UserOrgId: adminINfo.CurrentOrgId,
- PartitionId: number.ZoneID,
- BedId: sch.BedId,
- PatientId: schedule.PatientId,
- ScheduleDate: sch.ScheduleDate,
- ScheduleType: sch.ScheduleType,
- ScheduleWeek: sch.ScheduleWeek,
- ModeId: sch.ModeId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- IsExport: 8888,
- DialysisMachineName: "",
- }
- fmt.Println("汪涵我我我哦", id)
-
- //赵云的ID
- // 该床位存在的患者
- service.UpdateScheduleSixTy(id, xtSchedule)
-
- //赵云的排班
- msch := models.XtSchedule{
- UserOrgId: adminINfo.CurrentOrgId,
- PartitionId: schedule.PartitionId,
- BedId: schedule.BedId,
- PatientId: sch.PatientId,
- ScheduleDate: schedule.ScheduleDate,
- ScheduleType: schedule.ScheduleType,
- ScheduleWeek: schedule.ScheduleWeek,
- ModeId: schedule.ModeId,
- IsExport: 88888,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- }
-
- // 历史床位的患者
- service.UpdateScheduleSixTy(sch.ID, msch)
- }
- }
-
- }
-
- //如果床位发生改变
- if bed_id != schedule.BedId {
- //查询该床位今天是否存在排班
- sch, _ := service.GetScheduleByBedId(bed_id, schedule_type, adminINfo.CurrentOrgId, schedule.ScheduleDate)
- fmt.Println("schwowowoowowowowowo", sch.ID, sch.PatientId)
-
- if sch.ID == 0 {
- ////删除排班
- //service.UpdateScheduleByScheduleId(id)
-
- //五四的床位
- xtSchedule := models.XtSchedule{
- UserOrgId: adminINfo.CurrentOrgId,
- PartitionId: number.ZoneID,
- BedId: bed_id,
- PatientId: schedule.PatientId,
- ScheduleDate: schedule.ScheduleDate,
- ScheduleType: schedule_type,
- ScheduleWeek: schedule.ScheduleWeek,
- ModeId: mode_id,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: 0,
- IsExport: 999999,
- DialysisMachineName: "",
- }
- //service.CreateNewSchedule(xtSchedule)
-
- service.UpdateScheduleSixTy(id, xtSchedule)
- }
-
- //存在排班
- if sch.ID > 0 {
-
- xtSchedule := models.XtSchedule{
- UserOrgId: adminINfo.CurrentOrgId,
- PartitionId: number.ZoneID,
- BedId: sch.BedId,
- PatientId: schedule.PatientId,
- ScheduleDate: sch.ScheduleDate,
- ScheduleType: sch.ScheduleType,
- ScheduleWeek: sch.ScheduleWeek,
- ModeId: sch.ModeId,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- IsExport: 8888,
- DialysisMachineName: "",
- }
- fmt.Println("idwoowowowowowowoowowowowo", id)
-
- //赵云的ID
- // 该床位存在的患者
- service.UpdateScheduleSixTy(id, xtSchedule)
-
- //赵云的排班
- msch := models.XtSchedule{
- UserOrgId: adminINfo.CurrentOrgId,
- PartitionId: schedule.PartitionId,
- BedId: schedule.BedId,
- PatientId: sch.PatientId,
- ScheduleDate: schedule.ScheduleDate,
- ScheduleType: schedule.ScheduleType,
- ScheduleWeek: schedule.ScheduleWeek,
- ModeId: schedule.ModeId,
- IsExport: 88888,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- }
-
- // 历史床位的患者
- service.UpdateScheduleSixTy(sch.ID, msch)
- }
-
- }
- }
- //去除当天患者排班中重复数据,保留最后一条数据
- service.UpdateRepeatSchStatus(schedule.UserOrgId, schedule.ScheduleDate)
-
- scheduletwo, _ := service.GetSchedule(adminINfo.CurrentOrgId, id)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "schedule": scheduletwo,
- })
-
- }
-
- func (c *ScheduleApiController) GetNumberListById() {
-
- id, _ := c.GetInt64("id")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- number, _ := service.GetNumberListById(id, orgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "number": number,
- })
-
- }
|