dialysis_api_controller.go 207KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520
  1. package controllers
  2. import (
  3. "XT_New/models"
  4. "XT_New/service"
  5. "XT_New/utils"
  6. "encoding/json"
  7. "fmt"
  8. "github.com/jinzhu/gorm"
  9. "math"
  10. "reflect"
  11. "strconv"
  12. "strings"
  13. //"strings"
  14. "time"
  15. "XT_New/enums"
  16. "github.com/astaxie/beego"
  17. )
  18. type DialysisApiController struct {
  19. BaseAuthAPIController
  20. }
  21. func DialysisApiRegistRouters() {
  22. beego.Router("/api/dialysis/device", &DialysisApiController{}, "get:GetDeviceList")
  23. beego.Router("/api/dialysis/patients", &DialysisApiController{}, "get:GetDialysisWatch")
  24. beego.Router("/api/dialysis/zone", &DialysisApiController{}, "get:GetAllDeviceZone")
  25. beego.Router("/api/dialysis/info", &DialysisApiController{}, "get:GetSchedualPatientsInfo")
  26. beego.Router("/api/dialysis/advice/create", &DialysisApiController{}, "Post:CreateDoctorAdvice")
  27. beego.Router("/api/dialysis/advice/get", &DialysisApiController{}, "Get:GetDoctorAdvice")
  28. beego.Router("/api/dialysis/advice/edit", &DialysisApiController{}, "put:EditDoctorAdvice")
  29. beego.Router("/api/dialysis/monitor/create", &DialysisApiController{}, "Post:CreateMonitor")
  30. beego.Router("/api/dialysis/monitor/del", &DialysisApiController{}, "Post:DelMonitor")
  31. beego.Router("/api/dialysis/dialysisorder", &DialysisApiController{}, "Get:GetDialysisOrder")
  32. beego.Router("/api/dialysis/prescription", &DialysisApiController{}, "Post:PostPrescription")
  33. beego.Router("/api/dialysis/soulution", &DialysisApiController{}, "Post:PostSoulution")
  34. beego.Router("/api/dialysis/dobule", &DialysisApiController{}, "Post:PostDouleCheck")
  35. beego.Router("/api/dialysis/accepts", &DialysisApiController{}, "Post:PostReceiveTreatmentAsses")
  36. beego.Router("/api/dialysis/assessmentbeforedislysis", &DialysisApiController{}, "Post:PostAssessmentBeforeDislysis")
  37. beego.Router("/api/dialysis/assessmentafterdislysis", &DialysisApiController{}, "Post:PostAssessmentAfterDislysis")
  38. beego.Router("/api/dialysis/treatmentsummary", &DialysisApiController{}, "Post:PostTreatmentSummary")
  39. beego.Router("/api/dialysis/advice_remind", &DialysisApiController{}, "Get:GetLongAdvice")
  40. beego.Router("/api/dialysis/advice_remind/one", &DialysisApiController{}, "Get:GetLongAdviceOne")
  41. beego.Router("/api/dialysis/advice_remind/two", &DialysisApiController{}, "Get:GetLongAdviceTwo")
  42. beego.Router("/api/advice_remind/create", &DialysisApiController{}, "Post:CreateRemindDoctorAdvice")
  43. beego.Router("/api/solution/get", &DialysisApiController{}, "Get:GetSolution")
  44. beego.Router("/api/schedule/get", &DialysisApiController{}, "Get:GetSchedule")
  45. beego.Router("/api/today_monitor/get", &DialysisApiController{}, "Get:GetTodayMonitor")
  46. beego.Router("/api/dryweight/commit", &DialysisApiController{}, "Post:UploadDryWeight")
  47. beego.Router("/api/func_per/get", &DialysisApiController{}, "Get:GetFuncPurview")
  48. beego.Router("/api/doctoradvice/get", &DialysisApiController{}, "Get:GetLastOrNextDoctorAdvice")
  49. beego.Router("/api/dialysisgoods/get", &DialysisApiController{}, "Get:GetDialysisGoods")
  50. beego.Router("/api/goodstatistics/get", &DialysisApiController{}, "Get:GetDialysisGoodsStatistics")
  51. beego.Router("/api/queue/get", &DialysisApiController{}, "Get:GetQueueCall")
  52. beego.Router("/api/queue/update", &DialysisApiController{}, "Get:UpdateQueueCall")
  53. beego.Router("/api/get/getrolelist", &DialysisApiController{}, "Get:GetRoleList")
  54. beego.Router("/api/getinitprintdata", &DialysisApiController{}, "Get:GetInitPrintData")
  55. beego.Router("/api/schedule/getorderdoctoradvice", &DialysisApiController{}, "Get:GetOrderDoctorAdvice")
  56. beego.Router("/api/getinitprintdateone", &DialysisApiController{}, "Get:GetInitPrintDataOne")
  57. //新接口
  58. beego.Router("/api/patient/getpatientdialysissolutiongrouplist", &DialysisApiController{}, "Get:GetPatientDialysisSolutionGroupList")
  59. beego.Router("/api/patient/getdialysisadvicetemplatelist", &DialysisApiController{}, "Get:GetDialysisAdviceTemplateList")
  60. beego.Router("/api/patient/savedialysissetting", &DialysisApiController{}, "Get:SaveDialysisSetting")
  61. beego.Router("/api/patient/getdialysissetting", &DialysisApiController{}, "Get:GetDialysisSetting")
  62. beego.Router("/api/patient/getdialysisparameter", &DialysisApiController{}, "Get:GetDialysisParameterList")
  63. beego.Router("/api/patient/getdialysisgoodtotalcount", &DialysisApiController{}, "Get:GetDialysisGoodTotalCount")
  64. beego.Router("/api/patient/getdialysisadvicescheduelist", &DialysisApiController{}, "Get:GetDialysisAdviceSchedulist")
  65. beego.Router("/api/patient/getdialysisparametergoodlist", &DialysisApiController{}, "Get:GetDialysisParameterGoodList")
  66. beego.Router("/api/patient/savehisdialysis", &DialysisApiController{}, "Get:SaveHisDialysis")
  67. beego.Router("/api/patient/gethisdialysisgoodcount", &DialysisApiController{}, "Get:GetHisDialysisGoodCount")
  68. beego.Router("/api/schedule/getpatientshedule", &DialysisApiController{}, "Get:GetPatientSchedule")
  69. beego.Router("/api/patient/getscheduleprintlist", &DialysisApiController{}, "Get:GetSchedulePrintList")
  70. beego.Router("/api/patient/getsolutionlistbyorgid", &DialysisApiController{}, "Get:GetSolutionListByOrgId")
  71. beego.Router("/api/schedule/excutiondoctoradvice", &DialysisApiController{}, "Get:ExcutionDoctorAdvice")
  72. beego.Router("/api/schedule/checknewdoctoradvice", &DialysisApiController{}, "Get:CheckNewDoctorAdvice")
  73. beego.Router("/api/schedule/settlenewdoctoradvice", &DialysisApiController{}, "Get:SettleNewDoctorAdvice")
  74. beego.Router("/api/schedule/excutiondoctoradvicebyid", &DialysisApiController{}, "Get:ExcutionDoctorAdviceById")
  75. beego.Router("/api/patient/getdialysisadvicetoday", &DialysisApiController{}, "Get:GetDialysisAdviceToday")
  76. }
  77. func (c *DialysisApiController) GetQueueCall() {
  78. adminUserInfo := c.GetAdminUserInfo()
  79. queueConfig, _ := service.FindQueueCallInfo(adminUserInfo.CurrentOrgId)
  80. if queueConfig.ID <= 0 {
  81. queueConfig.OrgId = adminUserInfo.CurrentOrgId
  82. queueConfig.Qhsj = 10
  83. queueConfig.Jzdcbbcs = 3
  84. queueConfig.Jzbbsy = 1
  85. queueConfig.Jzjhyc = 0
  86. queueConfig.Sjdcbbcs = 3
  87. queueConfig.Sjbbsy = 0
  88. queueConfig.Sjjhyc = 0
  89. queueConfig.Txxqyxs = 0
  90. queueConfig.Txglsyxs = 0
  91. }
  92. c.ServeSuccessJSON(map[string]interface{}{
  93. "queue_config": queueConfig,
  94. })
  95. }
  96. func (c *DialysisApiController) UpdateQueueCall() {
  97. adminUserInfo := c.GetAdminUserInfo()
  98. queueConfig, _ := service.FindQueueCallInfo(adminUserInfo.CurrentOrgId)
  99. if queueConfig.ID <= 0 {
  100. queueConfig.OrgId = adminUserInfo.CurrentOrgId
  101. queueConfig.Qhsj = 10
  102. queueConfig.Jzdcbbcs = 3
  103. queueConfig.Jzbbsy = 1
  104. queueConfig.Jzjhyc = 0
  105. queueConfig.Sjdcbbcs = 3
  106. queueConfig.Sjbbsy = 0
  107. queueConfig.Sjjhyc = 0
  108. queueConfig.Txxqyxs = 0
  109. queueConfig.Txglsyxs = 0
  110. queueConfig.CreateTime = time.Now().Unix()
  111. queueConfig.UpdateTime = time.Now().Unix()
  112. }
  113. qhsj, _ := c.GetInt64("qhsj", 0)
  114. if qhsj > 0 {
  115. queueConfig.Qhsj = qhsj
  116. }
  117. jzdcbbcs, _ := c.GetInt64("jzdcbbcs", 0)
  118. if jzdcbbcs > 0 {
  119. queueConfig.Jzdcbbcs = jzdcbbcs
  120. }
  121. jzbbsy, _ := c.GetInt64("jzbbsy", 0)
  122. if jzbbsy > 0 {
  123. queueConfig.Jzbbsy = jzbbsy
  124. }
  125. jzjhyc, _ := c.GetInt64("jzjhyc", 0)
  126. queueConfig.Jzjhyc = jzjhyc
  127. sjdcbbcs, _ := c.GetInt64("sjdcbbcs", 0)
  128. if sjdcbbcs > 0 {
  129. queueConfig.Sjdcbbcs = sjdcbbcs
  130. }
  131. sjbbsy, _ := c.GetInt64("sjbbsy", 0)
  132. if sjbbsy > 0 {
  133. queueConfig.Sjbbsy = sjbbsy
  134. }
  135. sjjhyc, _ := c.GetInt64("sjjhyc", 0)
  136. queueConfig.Sjjhyc = sjjhyc
  137. txxqyxs, _ := c.GetInt64("txxqyxs", 0)
  138. queueConfig.Txxqyxs = txxqyxs
  139. txglsyxs, _ := c.GetInt64("txglsyxs", 0)
  140. queueConfig.Txglsyxs = txglsyxs
  141. queueConfig.UpdateTime = time.Now().Unix()
  142. service.UpDateQueueCallInfo(queueConfig)
  143. c.ServeSuccessJSON(map[string]interface{}{
  144. "queue_config": queueConfig,
  145. })
  146. }
  147. func (c *DialysisApiController) PostPrescription() {
  148. patient, _ := c.GetInt64("patient_id", 0)
  149. recordDateStr := c.GetString("record_date")
  150. if patient <= 0 {
  151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  152. return
  153. }
  154. adminUserInfo := c.GetAdminUserInfo()
  155. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  156. if patientInfo.ID == 0 {
  157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  158. return
  159. }
  160. if len(recordDateStr) == 0 {
  161. recordDateStr = time.Now().Format("2006-01-02")
  162. }
  163. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  164. if parseDateErr != nil {
  165. c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  167. return
  168. }
  169. mode_id, _ := c.GetInt64("mode_id", 0)
  170. dialysis_duration, _ := c.GetFloat("dialysis_duration", 0)
  171. dialyzer, _ := c.GetInt64("dialyzer", 0)
  172. dialyzerPerfusionApparatus := c.GetString("dialyzer_perfusion_apparatus")
  173. perfusion_apparatus, _ := c.GetInt64("perfusion_apparatus", 0)
  174. blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
  175. dewater_amount, _ := c.GetFloat("dewater_amount", 0)
  176. displace_liqui, _ := c.GetFloat("displace_liqui", 0)
  177. replacement_way, _ := c.GetInt64("replacement_way", 0)
  178. anticoagulant, _ := c.GetInt64("anticoagulant", 0)
  179. anticoagulant_shouji, _ := c.GetFloat("anticoagulant_shouji", 0)
  180. anticoagulant_weichi, _ := c.GetFloat("anticoagulant_weichi", 0)
  181. anticoagulant_zongliang, _ := c.GetFloat("anticoagulant_zongliang", 0)
  182. anticoagulant_gaimingcheng := c.GetString("anticoagulant_gaimingcheng")
  183. anticoagulant_gaijiliang := c.GetString("anticoagulant_gaijiliang")
  184. kalium, _ := c.GetFloat("kalium", 0)
  185. sodium, _ := c.GetFloat("sodium", 0)
  186. replacement_total, _ := c.GetFloat("replacement_total", 0)
  187. calcium, _ := c.GetFloat("calcium", 0)
  188. bicarbonate, _ := c.GetFloat("bicarbonate", 0)
  189. glucose, _ := c.GetFloat("glucose", 0)
  190. // dry_weight, _ := c.GetFloat("dry_weight", 0)
  191. dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
  192. dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
  193. conductivity, _ := c.GetFloat("conductivity", 0)
  194. remark := c.GetString("remark")
  195. dialysisDurationHour, _ := c.GetInt64("dialysis_duration_hour", 0)
  196. dialysisDurationMinute, _ := c.GetInt64("dialysis_duration_minute", 0)
  197. targetUltrafiltration, _ := c.GetFloat("target_ultrafiltration", 0)
  198. dialysateFormulation, _ := c.GetInt64("dialysate_formulation", 0)
  199. body_fluid, _ := c.GetInt64("body_fluid", 0)
  200. special_medicine, _ := c.GetInt64("special_medicine", 0)
  201. special_medicine_other := c.GetString("special_medicine_other")
  202. displace_liqui_part, _ := c.GetInt64("displace_liqui_part", 0)
  203. displace_liqui_value, _ := c.GetFloat("displace_liqui_value", 0)
  204. blood_access, _ := c.GetInt64("blood_access", 0)
  205. ultrafiltration, _ := c.GetFloat("ultrafiltration", 0)
  206. body_fluid_other := c.GetString("body_fluid_other")
  207. target_ktv, _ := c.GetFloat("target_ktv", 0)
  208. niprocart, _ := c.GetInt64("niprocart", 0)
  209. jms, _ := c.GetInt64("jms", 0)
  210. fistula_needle_set, _ := c.GetInt64("fistula_needle_set", 0)
  211. fistula_needle_set_16, _ := c.GetInt64("fistula_needle_set_16", 0)
  212. hemoperfusion, _ := c.GetInt64("hemoperfusion", 0)
  213. dialyser_sterilised, _ := c.GetInt64("dialyser_sterilised", 0)
  214. filtryzer, _ := c.GetInt64("filtryzer", 0)
  215. dialyzers, _ := c.GetInt64("dialyzers", 0)
  216. injector, _ := c.GetInt64("injector", 0)
  217. bloodlines, _ := c.GetInt64("bloodlines", 0)
  218. tubing_hemodialysis, _ := c.GetInt64("tubing_hemodialysis", 0)
  219. safe_package, _ := c.GetInt64("package", 0)
  220. a_liquid, _ := c.GetInt64("a_liquid", 0)
  221. preImpules, _ := c.GetFloat("pre_impulse", 0)
  222. fmt.Println("", preImpules)
  223. anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
  224. anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
  225. //heparin_sodium := c.GetString("heparin_sodium")
  226. //fmt.Println("肝素钠",heparin_sodium)
  227. //nucleoprotamine := c.GetString("nucleoprotamine")
  228. //fmt.Println("鱼精蛋白",nucleoprotamine)
  229. //push_the_protamine := c.GetString("push_the_protamine")
  230. //fmt.Println("下机前推注鱼精蛋白",push_the_protamine)
  231. // var prescription_doctor int64
  232. blood := c.GetString("blood")
  233. dialysis_dialyszers := c.GetString("dialysis_dialyszers")
  234. dialysis_irrigation := c.GetString("dialysis_irrigation")
  235. antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
  236. displace_speed := c.GetString("displace_speed")
  237. illness, _ := c.GetInt64("illness")
  238. amylaceum := c.GetString("amylaceum")
  239. single_time := c.GetString("single_time")
  240. single_water := c.GetString("single_water")
  241. replacement_flow := c.GetString("replacement_flow")
  242. plasma_separator := c.GetString("plasma_separator")
  243. bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
  244. oxygen_uptake, _ := c.GetInt64("oxygen_uptake")
  245. oxygen_flow := c.GetString("oxygen_flow")
  246. oxygen_time := c.GetString("oxygen_time")
  247. hemodialysis_pipelines := c.GetString("hemodialysis_pipelines")
  248. hemodialysis_pipelines_count, _ := c.GetFloat("hemodialysis_pipelines_count", 0)
  249. puncture_needle := c.GetString("puncture_needle")
  250. puncture_needle_count, _ := c.GetFloat("puncture_needle_count", 0)
  251. epo := c.GetString("epo")
  252. epo_count, _ := c.GetFloat("epo_count", 0)
  253. max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
  254. admin_user_id, _ := c.GetInt64("admin_user_id")
  255. is_water, _ := c.GetInt64("is_water")
  256. drhy_water := c.GetString("drhy_water")
  257. dry_water_hour := c.GetString("dry_water_hour")
  258. water_machine := c.GetString("water_machine")
  259. add_amount, _ := c.GetFloat("add_amount")
  260. reduce_amount, _ := c.GetFloat("reduce_amount")
  261. dialysis_remark := c.GetString("dialysis_remark")
  262. appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
  263. //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  264. //if template.TemplateId == 2 || template.TemplateId == 6 {
  265. // if appRole.UserType == 3 {
  266. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  267. // if getPermissionErr != nil {
  268. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  269. // return
  270. // } else if headNursePermission == nil {
  271. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  272. // return
  273. // }
  274. // }
  275. //}
  276. prescription := models.DialysisPrescription{
  277. UserOrgId: adminUserInfo.CurrentOrgId,
  278. PatientId: patient,
  279. RecordDate: recordDate.Unix(),
  280. ModeId: mode_id,
  281. DialysisDuration: dialysis_duration,
  282. Dialyzer: dialyzer,
  283. ReplacementTotal: replacement_total,
  284. PerfusionApparatus: perfusion_apparatus,
  285. BloodFlowVolume: blood_flow_volume,
  286. DewaterAmount: dewater_amount,
  287. DisplaceLiqui: displace_liqui,
  288. ReplacementWay: replacement_way,
  289. Anticoagulant: anticoagulant,
  290. AnticoagulantShouji: anticoagulant_shouji,
  291. AnticoagulantWeichi: anticoagulant_weichi,
  292. AnticoagulantZongliang: anticoagulant_zongliang,
  293. AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
  294. AnticoagulantGaijiliang: anticoagulant_gaijiliang,
  295. Kalium: kalium,
  296. Sodium: sodium,
  297. Calcium: calcium,
  298. Bicarbonate: bicarbonate,
  299. Glucose: glucose,
  300. // DryWeight: dry_weight,
  301. DialysateFlow: dialysate_flow,
  302. DialysateTemperature: dialysate_temperature,
  303. Conductivity: conductivity,
  304. Remark: remark,
  305. Status: 1,
  306. CreatedTime: time.Now().Unix(),
  307. UpdatedTime: time.Now().Unix(),
  308. DialysisDurationMinute: dialysisDurationMinute,
  309. DialysisDurationHour: dialysisDurationHour,
  310. TargetUltrafiltration: targetUltrafiltration,
  311. DialysateFormulation: dialysateFormulation,
  312. DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
  313. BodyFluid: body_fluid,
  314. SpecialMedicine: special_medicine,
  315. SpecialMedicineOther: special_medicine_other,
  316. DisplaceLiquiPart: displace_liqui_part,
  317. DisplaceLiquiValue: displace_liqui_value,
  318. BloodAccess: blood_access,
  319. Ultrafiltration: ultrafiltration,
  320. BodyFluidOther: body_fluid_other,
  321. TargetKtv: target_ktv,
  322. Niprocart: niprocart,
  323. Jms: jms,
  324. FistulaNeedleSet: fistula_needle_set,
  325. FistulaNeedleSet16: fistula_needle_set_16,
  326. Hemoperfusion: hemoperfusion,
  327. DialyserSterilised: dialyser_sterilised,
  328. Filtryzer: filtryzer,
  329. Dialyzers: dialyzers,
  330. Injector: injector,
  331. Bloodlines: bloodlines,
  332. TubingHemodialysis: tubing_hemodialysis,
  333. Package: safe_package,
  334. ALiquid: a_liquid,
  335. PreImpulse: preImpules,
  336. AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
  337. AnticoagulantStopTimeMin: anticoagulant_stop_time_min,
  338. Blood: blood,
  339. DialysisDialyszers: dialysis_dialyszers,
  340. DialysisIrrigation: dialysis_irrigation,
  341. AntioxidantCommodityName: antioxidant_commodity_name,
  342. DisplaceSpeed: displace_speed,
  343. Illness: illness,
  344. Amylaceum: amylaceum,
  345. SingleTime: single_time,
  346. SingleWater: single_water,
  347. ReplacementFlow: replacement_flow,
  348. PlasmaSeparator: plasma_separator,
  349. BilirubinAdsorptionColumn: bilirubin_adsorption_column,
  350. OxygenFlow: oxygen_flow,
  351. OxygenUptake: oxygen_uptake,
  352. OxygenTime: oxygen_time,
  353. HemodialysisPipelines: hemodialysis_pipelines,
  354. HemodialysisPipelinesCount: hemodialysis_pipelines_count,
  355. PunctureNeedle: puncture_needle,
  356. PunctureNeedleCount: puncture_needle_count,
  357. Epo: epo,
  358. EpoCount: epo_count,
  359. MaxUltrafiltrationRate: max_ultrafiltration_rate,
  360. AdminUserId: admin_user_id,
  361. IsWater: is_water,
  362. DrhyWater: drhy_water,
  363. DryWaterHour: dry_water_hour,
  364. WaterMachine: water_machine,
  365. AddAmount: add_amount,
  366. ReduceAmount: reduce_amount,
  367. DialysisRemark: dialysis_remark,
  368. }
  369. if appRole.UserType == 2 || appRole.UserType == 1 {
  370. prescription.PrescriptionDoctor = appRole.AdminUserId
  371. }
  372. _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
  373. if dialysisPrescription.ID == 0 { //新增
  374. if mode_id > 0 {
  375. var str string
  376. //查找该机构用的是什么透析器
  377. filedConfig, _ := service.GetFiledConfig(adminUserInfo.CurrentOrgId)
  378. if filedConfig.ID > 0 {
  379. str = dialyzerPerfusionApparatus
  380. } else {
  381. str = dialysis_dialyszers + "/" + dialysis_irrigation
  382. }
  383. service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
  384. }
  385. prescription.Creater = adminUserInfo.AdminUser.Id
  386. //针对河间咸得
  387. if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
  388. if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
  389. prescription.DisplaceLiquiPart = 0
  390. prescription.DisplaceLiquiValue = 0
  391. }
  392. }
  393. err := service.AddSigleRecord(&prescription)
  394. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
  395. redis := service.RedisClient()
  396. //清空key 值
  397. redis.Set(key, "", time.Second)
  398. keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
  399. redis.Set(keyTwo, "", time.Second)
  400. keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  401. redis.Set(keyThree, "", time.Second)
  402. defer redis.Close()
  403. if err == nil {
  404. updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
  405. if updateErr != nil {
  406. utils.ErrorLog("%v", updateErr)
  407. }
  408. c.ServeSuccessJSON(map[string]interface{}{
  409. "prescription": &prescription,
  410. })
  411. } else {
  412. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  413. }
  414. } else { //修改
  415. if mode_id > 0 {
  416. var str string
  417. //查找该机构用的是什么透析器
  418. filedConfig, _ := service.GetFiledConfig(adminUserInfo.CurrentOrgId)
  419. if filedConfig.ID > 0 {
  420. str = dialyzerPerfusionApparatus
  421. } else {
  422. str = dialysis_dialyszers + "/" + dialysis_irrigation
  423. }
  424. service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
  425. }
  426. //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  427. //if template.TemplateId == 1 {
  428. // if dialysisPrescription.Creater > 0 && dialysisPrescription.Creater != adminUserInfo.AdminUser.Id {
  429. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  430. // if getPermissionErr != nil {
  431. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  432. // return
  433. // } else if headNursePermission == nil {
  434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  435. // return
  436. // }
  437. // }
  438. //}
  439. if appRole.UserType == 2 || appRole.UserType == 1 {
  440. prescription_doctor := adminUserInfo.AdminUser.Id
  441. prescription.PrescriptionDoctor = prescription_doctor
  442. }
  443. if dialysisPrescription.Creater == 0 { //体重称
  444. prescription.Creater = adminUserInfo.AdminUser.Id
  445. } else {
  446. prescription.Creater = dialysisPrescription.Creater
  447. }
  448. prescription.CreatedTime = dialysisPrescription.CreatedTime
  449. prescription.UpdatedTime = time.Now().Unix()
  450. prescription.Modifier = adminUserInfo.AdminUser.Id
  451. prescription.ID = dialysisPrescription.ID
  452. updateErr := service.UpDateDialysisPrescription(&prescription)
  453. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
  454. redis := service.RedisClient()
  455. defer redis.Close()
  456. //清空key 值
  457. redis.Set(key, "", time.Second)
  458. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
  459. redis.Set(keyOne, "", time.Second)
  460. keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  461. redis.Set(keyThree, "", time.Second)
  462. if updateErr == nil {
  463. updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
  464. if updateErr != nil {
  465. utils.ErrorLog("%v", updateErr)
  466. }
  467. c.ServeSuccessJSON(map[string]interface{}{
  468. "prescription": &prescription,
  469. })
  470. } else {
  471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  472. }
  473. }
  474. }
  475. func (c *DialysisApiController) PostSoulution() {
  476. patient, _ := c.GetInt64("patient", 0)
  477. recordDateStr := c.GetString("record_date")
  478. if patient <= 0 {
  479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  480. return
  481. }
  482. adminUserInfo := c.GetAdminUserInfo()
  483. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  484. if patientInfo.ID == 0 {
  485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  486. return
  487. }
  488. if len(recordDateStr) == 0 {
  489. recordDateStr = time.Now().Format("2006-01-02")
  490. }
  491. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  492. if parseDateErr != nil {
  493. c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  495. return
  496. }
  497. mode_id, _ := c.GetInt64("mode_id", 0)
  498. dialysis_duration, _ := c.GetFloat("dialysis_duration", 0)
  499. dialyzer, _ := c.GetInt64("dialyzer", 0)
  500. perfusion_apparatus, _ := c.GetInt64("perfusion_apparatus", 0)
  501. blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
  502. replacement_total, _ := c.GetFloat("replacement_total", 0)
  503. dialyzerPerfusionApparatus := c.GetString("dialyzer_perfusion_apparatus")
  504. dewater_amount, _ := c.GetFloat("dewater_amount", 0)
  505. displace_liqui, _ := c.GetFloat("displace_liqui", 0)
  506. replacement_way, _ := c.GetInt64("replacement_way", 0)
  507. anticoagulant, _ := c.GetInt64("anticoagulant", 0)
  508. anticoagulant_shouji, _ := c.GetFloat("anticoagulant_shouji", 0)
  509. anticoagulant_weichi, _ := c.GetFloat("anticoagulant_weichi", 0)
  510. anticoagulant_zongliang, _ := c.GetFloat("anticoagulant_zongliang", 0)
  511. anticoagulant_gaimingcheng := c.GetString("anticoagulant_gaimingcheng")
  512. anticoagulant_gaijiliang := c.GetString("anticoagulant_gaijiliang")
  513. kalium, _ := c.GetFloat("kalium", 0)
  514. sodium, _ := c.GetFloat("sodium", 0)
  515. calcium, _ := c.GetFloat("calcium", 0)
  516. bicarbonate, _ := c.GetFloat("bicarbonate", 0)
  517. glucose, _ := c.GetFloat("glucose", 0)
  518. // dry_weight, _ := c.GetFloat("dry_weight", 0)
  519. dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
  520. dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
  521. conductivity, _ := c.GetFloat("conductivity", 0)
  522. remark := c.GetString("remark")
  523. dialysisDurationHour, _ := c.GetInt64("dialysis_duration_hour", 0)
  524. dialysisDurationMinute, _ := c.GetInt64("dialysis_duration_minute", 0)
  525. targetUltrafiltration, _ := c.GetFloat("target_ultrafiltration", 0)
  526. dialysateFormulation, _ := c.GetInt64("dialysate_formulation", 0)
  527. body_fluid, _ := c.GetInt64("body_fluid", 0)
  528. special_medicine, _ := c.GetInt64("special_medicine", 0)
  529. special_medicine_other := c.GetString("special_medicine_other")
  530. displace_liqui_part, _ := c.GetInt64("displace_liqui_part", 0)
  531. displace_liqui_value, _ := c.GetFloat("displace_liqui_value", 0)
  532. blood_access, _ := c.GetInt64("blood_access", 0)
  533. ultrafiltration, _ := c.GetFloat("ultrafiltration", 0)
  534. body_fluid_other := c.GetString("body_fluid_other")
  535. target_ktv, _ := c.GetFloat("target_ktv", 0)
  536. niprocart, _ := c.GetInt64("niprocart", 0)
  537. jms, _ := c.GetInt64("jms", 0)
  538. fistula_needle_set, _ := c.GetInt64("fistula_needle_set", 0)
  539. fistula_needle_set_16, _ := c.GetInt64("fistula_needle_set_16", 0)
  540. hemoperfusion, _ := c.GetInt64("hemoperfusion", 0)
  541. dialyser_sterilised, _ := c.GetInt64("dialyser_sterilised", 0)
  542. filtryzer, _ := c.GetInt64("filtryzer", 0)
  543. dialyzers, _ := c.GetInt64("dialyzers", 0)
  544. injector, _ := c.GetInt64("injector", 0)
  545. bloodlines, _ := c.GetInt64("bloodlines", 0)
  546. tubing_hemodialysis, _ := c.GetInt64("tubing_hemodialysis", 0)
  547. safe_package, _ := c.GetInt64("package", 0)
  548. a_liquid, _ := c.GetInt64("a_liquid", 0)
  549. anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
  550. anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
  551. blood := c.GetString("blood")
  552. dialysis_dialyszers := c.GetString("dialysis_dialyszers")
  553. dialysis_irrigation := c.GetString("dialysis_irrigation")
  554. antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
  555. displace_speed := c.GetString("displace_speed")
  556. illness, _ := c.GetInt64("illness")
  557. amylaceum := c.GetString("amylaceum")
  558. single_time := c.GetString("single_time")
  559. single_water := c.GetString("single_water")
  560. replacement_flow := c.GetString("replacement_flow")
  561. plasma_separator := c.GetString("plasma_separator")
  562. bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
  563. oxygen_uptake, _ := c.GetInt64("oxygen_uptake")
  564. oxygen_flow := c.GetString("oxygen_flow")
  565. oxygen_time := c.GetString("oxygen_time")
  566. hemodialysis_pipelines := c.GetString("hemodialysis_pipelines")
  567. hemodialysis_pipelines_count, _ := c.GetFloat("hemodialysis_pipelines_count", 0)
  568. puncture_needle := c.GetString("puncture_needle")
  569. puncture_needle_count, _ := c.GetFloat("puncture_needle_count", 0)
  570. epo := c.GetString("epo")
  571. epo_count, _ := c.GetFloat("epo_count", 0)
  572. max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
  573. impulse := c.GetString("impulse")
  574. preImpules, parseDateErr := strconv.ParseFloat(impulse, 64)
  575. admin_user_id, _ := c.GetInt64("admin_user_id")
  576. fmt.Println("", preImpules)
  577. is_water, _ := c.GetInt64("is_water")
  578. dry_water_hour := c.GetString("dry_water_hour")
  579. drhy_water := c.GetString("drhy_water")
  580. water_machine := c.GetString("water_machine")
  581. add_amount, _ := c.GetFloat("add_amount")
  582. reduce_amount, _ := c.GetFloat("reduce_amount")
  583. dialysis_remark := c.GetString("dialysis_remark")
  584. var prescription_doctor int64
  585. appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
  586. if appRole.UserType == 2 || appRole.UserType == 1 {
  587. prescription_doctor = appRole.AdminUserId
  588. }
  589. if mode_id > 0 {
  590. var str string
  591. //查找该机构用的是什么透析器
  592. filedConfig, _ := service.GetFiledConfig(adminUserInfo.CurrentOrgId)
  593. if filedConfig.ID > 0 {
  594. str = dialyzerPerfusionApparatus
  595. } else {
  596. str = dialysis_dialyszers + "/" + dialysis_irrigation
  597. }
  598. service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
  599. }
  600. //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  601. //
  602. //if template.TemplateId == 2 || template.TemplateId == 6 {
  603. // if appRole.UserType == 3 {
  604. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  605. // if getPermissionErr != nil {
  606. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  607. // return
  608. // } else if headNursePermission == nil {
  609. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  610. // return
  611. // }
  612. // }
  613. //}
  614. prescription := models.DialysisPrescription{
  615. UserOrgId: adminUserInfo.CurrentOrgId,
  616. PatientId: patient,
  617. RecordDate: recordDate.Unix(),
  618. ModeId: mode_id,
  619. DialysisDuration: dialysis_duration,
  620. Dialyzer: dialyzer,
  621. PerfusionApparatus: perfusion_apparatus,
  622. BloodFlowVolume: blood_flow_volume,
  623. DewaterAmount: dewater_amount,
  624. DisplaceLiqui: displace_liqui,
  625. ReplacementWay: replacement_way,
  626. Anticoagulant: anticoagulant,
  627. AnticoagulantShouji: anticoagulant_shouji,
  628. AnticoagulantWeichi: anticoagulant_weichi,
  629. AnticoagulantZongliang: anticoagulant_zongliang,
  630. AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
  631. AnticoagulantGaijiliang: anticoagulant_gaijiliang,
  632. Kalium: kalium,
  633. Sodium: sodium,
  634. Calcium: calcium,
  635. Bicarbonate: bicarbonate,
  636. Glucose: glucose,
  637. // DryWeight: dry_weight,
  638. DialysateFlow: dialysate_flow,
  639. DialysateTemperature: dialysate_temperature,
  640. Conductivity: conductivity,
  641. Remark: remark,
  642. PrescriptionDoctor: prescription_doctor,
  643. Status: 1,
  644. CreatedTime: time.Now().Unix(),
  645. UpdatedTime: time.Now().Unix(),
  646. DialysisDurationMinute: dialysisDurationMinute,
  647. DialysisDurationHour: dialysisDurationHour,
  648. TargetUltrafiltration: targetUltrafiltration,
  649. DialysateFormulation: dialysateFormulation,
  650. ReplacementTotal: replacement_total,
  651. DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
  652. BodyFluid: body_fluid,
  653. SpecialMedicine: special_medicine,
  654. SpecialMedicineOther: special_medicine_other,
  655. DisplaceLiquiPart: displace_liqui_part,
  656. DisplaceLiquiValue: displace_liqui_value,
  657. BloodAccess: blood_access,
  658. Ultrafiltration: ultrafiltration,
  659. BodyFluidOther: body_fluid_other,
  660. TargetKtv: target_ktv,
  661. Niprocart: niprocart,
  662. Jms: jms,
  663. FistulaNeedleSet: fistula_needle_set,
  664. FistulaNeedleSet16: fistula_needle_set_16,
  665. Hemoperfusion: hemoperfusion,
  666. DialyserSterilised: dialyser_sterilised,
  667. Filtryzer: filtryzer,
  668. Dialyzers: dialyzers,
  669. Injector: injector,
  670. Bloodlines: bloodlines,
  671. TubingHemodialysis: tubing_hemodialysis,
  672. Package: safe_package,
  673. ALiquid: a_liquid,
  674. AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
  675. AnticoagulantStopTimeMin: anticoagulant_stop_time_min,
  676. Blood: blood,
  677. DialysisIrrigation: dialysis_irrigation,
  678. DialysisDialyszers: dialysis_dialyszers,
  679. AntioxidantCommodityName: antioxidant_commodity_name,
  680. DisplaceSpeed: displace_speed,
  681. Illness: illness,
  682. Amylaceum: amylaceum,
  683. SingleTime: single_time,
  684. SingleWater: single_water,
  685. ReplacementFlow: replacement_flow,
  686. PlasmaSeparator: plasma_separator,
  687. BilirubinAdsorptionColumn: bilirubin_adsorption_column,
  688. OxygenTime: oxygen_time,
  689. OxygenUptake: oxygen_uptake,
  690. OxygenFlow: oxygen_flow,
  691. HemodialysisPipelines: hemodialysis_pipelines,
  692. HemodialysisPipelinesCount: hemodialysis_pipelines_count,
  693. PunctureNeedle: puncture_needle,
  694. PunctureNeedleCount: puncture_needle_count,
  695. Epo: epo,
  696. EpoCount: epo_count,
  697. MaxUltrafiltrationRate: max_ultrafiltration_rate,
  698. PreImpulse: preImpules,
  699. AdminUserId: admin_user_id,
  700. IsWater: is_water,
  701. DryWaterHour: dry_water_hour,
  702. DrhyWater: drhy_water,
  703. WaterMachine: water_machine,
  704. AddAmount: add_amount,
  705. ReduceAmount: reduce_amount,
  706. DialysisRemark: dialysis_remark,
  707. }
  708. //查询最近透析准备表里是否存在 透析器 灌流器
  709. //splitStr := strings.Split(dialysis_dialyszers, ",")
  710. //
  711. //splitIrrigation := strings.Split(dialysis_irrigation, ",")
  712. //
  713. //mation, _ := service.GetGoodInfoMation(adminUserInfo.CurrentOrgId)
  714. //if len(mation)>0{
  715. // for _, item := range splitStr {
  716. // for _,it := range mation{
  717. // if(item == it.SpecificationName){
  718. //
  719. // //查询最近一次的透析器
  720. // _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
  721. //
  722. // if errcode == gorm.ErrRecordNotFound{
  723. // //插入数据
  724. // prepare := models.DialysisBeforePrepare{
  725. // UserOrgId: adminUserInfo.CurrentOrgId,
  726. // PatientId: patient,
  727. // RecordDate: recordDate.Unix(),
  728. // GoodTypeId: it.GoodTypeId,
  729. // GoodId: it.ID,
  730. // Count: 1,
  731. // Ctime: time.Now().Unix(),
  732. // Creater: adminUserInfo.AdminUser.Id,
  733. // Status:1,
  734. //
  735. // }
  736. // errcode := service.CreateDialysisBeforePrepareOne(&prepare)
  737. // fmt.Println("",errcode)
  738. // }
  739. // }
  740. // }
  741. //
  742. // }
  743. //
  744. // for _, item := range splitIrrigation {
  745. // for _,it := range mation{
  746. // if(item == it.SpecificationName){
  747. // //查询最近一次的透析器
  748. // _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
  749. // if errcode == gorm.ErrRecordNotFound{
  750. // //插入数据
  751. // prepare := models.DialysisBeforePrepare{
  752. // UserOrgId: adminUserInfo.CurrentOrgId,
  753. // PatientId: patient,
  754. // RecordDate: recordDate.Unix(),
  755. // GoodTypeId: it.GoodTypeId,
  756. // GoodId: it.ID,
  757. // Count: 1,
  758. // Ctime: time.Now().Unix(),
  759. // Creater: adminUserInfo.AdminUser.Id,
  760. // Status:1,
  761. //
  762. // }
  763. // errcode := service.CreateDialysisBeforePrepareOne(&prepare)
  764. // fmt.Println(errcode)
  765. // }
  766. // }
  767. // }
  768. // }
  769. //}
  770. _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
  771. if dialysisPrescription.ID == 0 { //新增
  772. if appRole.UserType == 2 || appRole.UserType == 1 {
  773. prescription.PrescriptionDoctor = adminUserInfo.AdminUser.Id
  774. }
  775. prescription.Creater = adminUserInfo.AdminUser.Id
  776. } else { //修改
  777. //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  778. //if template.TemplateId == 1 {
  779. // if dialysisPrescription.Creater != adminUserInfo.AdminUser.Id && dialysisPrescription.Creater != 0 {
  780. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  781. // if getPermissionErr != nil {
  782. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  783. // return
  784. // } else if headNursePermission == nil {
  785. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  786. // return
  787. // }
  788. // }
  789. //}
  790. if appRole.UserType == 2 || appRole.UserType == 1 {
  791. prescription_doctor := adminUserInfo.AdminUser.Id
  792. prescription.PrescriptionDoctor = prescription_doctor
  793. } else {
  794. prescription.PrescriptionDoctor = dialysisPrescription.PrescriptionDoctor
  795. }
  796. if dialysisPrescription.Creater == 0 {
  797. prescription.Creater = adminUserInfo.AdminUser.Id
  798. } else {
  799. prescription.Creater = dialysisPrescription.Creater
  800. }
  801. prescription.CreatedTime = dialysisPrescription.CreatedTime
  802. prescription.UpdatedTime = time.Now().Unix()
  803. prescription.Modifier = adminUserInfo.AdminUser.Id
  804. prescription.ID = dialysisPrescription.ID
  805. }
  806. solution := models.DialysisSolution{
  807. RegistrarsId: adminUserInfo.AdminUser.Id,
  808. UserOrgId: adminUserInfo.CurrentOrgId,
  809. Doctor: prescription_doctor,
  810. PatientId: patient,
  811. ModeId: mode_id,
  812. DialysisDuration: dialysis_duration,
  813. PerfusionApparatus: perfusion_apparatus,
  814. BloodFlowVolume: blood_flow_volume,
  815. Dewater: dewater_amount,
  816. DisplaceLiqui: displace_liqui,
  817. ReplacementWay: replacement_way,
  818. Anticoagulant: anticoagulant,
  819. AnticoagulantShouji: anticoagulant_shouji,
  820. AnticoagulantWeichi: anticoagulant_weichi,
  821. AnticoagulantZongliang: anticoagulant_zongliang,
  822. AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
  823. AnticoagulantGaijiliang: anticoagulant_gaijiliang,
  824. Kalium: kalium,
  825. Sodium: sodium,
  826. Calcium: calcium,
  827. Bicarbonate: bicarbonate,
  828. Glucose: glucose,
  829. // DryWeight: dry_weight,
  830. DialysateFlow: dialysate_flow,
  831. DialysateTemperature: dialysate_temperature,
  832. Conductivity: conductivity,
  833. Remark: remark,
  834. Status: 1,
  835. CreatedTime: time.Now().Unix(),
  836. UpdatedTime: time.Now().Unix(),
  837. DialysisDurationMinute: dialysisDurationMinute,
  838. DialysisDurationHour: dialysisDurationHour,
  839. TargetUltrafiltration: targetUltrafiltration,
  840. DialysateFormulation: dialysateFormulation,
  841. DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
  842. BodyFluid: body_fluid,
  843. SpecialMedicine: special_medicine,
  844. SpecialMedicineOther: special_medicine_other,
  845. DisplaceLiquiPart: displace_liqui_part,
  846. DisplaceLiquiValue: displace_liqui_value,
  847. BloodAccess: blood_access,
  848. Ultrafiltration: ultrafiltration,
  849. BodyFluidOther: body_fluid_other,
  850. ReplacementTotal: replacement_total,
  851. TargetKtv: target_ktv,
  852. DialysisIrrigation: dialysis_irrigation,
  853. DialysisDialyszers: dialysis_dialyszers,
  854. HemodialysisPipelines: hemodialysis_pipelines,
  855. HemodialysisPipelinesCount: hemodialysis_pipelines_count,
  856. PunctureNeedle: puncture_needle,
  857. PunctureNeedleCount: puncture_needle_count,
  858. Epo: epo,
  859. EpoCount: epo_count,
  860. MaxUltrafiltrationRate: max_ultrafiltration_rate,
  861. OxygenUptake: oxygen_uptake,
  862. OxygenFlow: oxygen_flow,
  863. OxygenTime: oxygen_time,
  864. PreImpulse: preImpules,
  865. SolutionStatus: 1,
  866. DialysisRemark: dialysis_remark,
  867. }
  868. //针对河间咸得
  869. if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
  870. if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
  871. prescription.DisplaceLiquiPart = 0
  872. prescription.DisplaceLiquiValue = 0
  873. }
  874. }
  875. if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
  876. if solution.ModeId != 2 && solution.ModeId != 5 && solution.ModeId != 12 {
  877. solution.DisplaceLiquiPart = 0
  878. solution.DisplaceLiquiValue = 0
  879. }
  880. }
  881. err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
  882. //获取最新1条
  883. dialysisSolution, _ := service.GetLastPatientDialysisSolution(patient, adminUserInfo.CurrentOrgId)
  884. //更新状态
  885. service.UpdateDialysisSolutionStatusTwo(dialysisSolution.ID, dialysisSolution.ModeId, dialysisSolution.UserOrgId, dialysisSolution.PatientId)
  886. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
  887. redis := service.RedisClient()
  888. //清空key 值
  889. redis.Set(key, "", time.Second)
  890. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
  891. //清空key 值
  892. redis.Set(keyOne, "", time.Second)
  893. keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
  894. redis.Set(keyTwo, "", time.Second)
  895. keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  896. redis.Set(keyThree, "", time.Second)
  897. defer redis.Close()
  898. if err == nil {
  899. c.ServeSuccessJSON(map[string]interface{}{
  900. "solution": &solution,
  901. "prescription": &prescription,
  902. })
  903. } else {
  904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  905. }
  906. }
  907. func (c *DialysisApiController) PostDouleCheck() {
  908. id, _ := c.GetInt64("patient", 0)
  909. recordDateStr := c.GetString("record_date")
  910. checkTimeStr := c.GetString("check_time")
  911. firstCheckTimeStr := c.GetString("first_check_time")
  912. creater, _ := c.GetInt64("creater", 0)
  913. modifier, _ := c.GetInt64("modifier", 0)
  914. dialysis_item_check, _ := c.GetInt64("dialysis_item_check", 0)
  915. dialysis_parameter_check, _ := c.GetInt64("dialysis_parameter_check", 0)
  916. vascular_access_verification, _ := c.GetInt64("vascular_access_verification", 0)
  917. pipeline_connection_check, _ := c.GetInt64("pipeline_connection_check", 0)
  918. dialysis_item_desc := c.GetString("dialysis_item_desc")
  919. dialysis_parameter_desc := c.GetString("dialysis_parameter_desc")
  920. vascular_access_desc := c.GetString("vascular_access_desc")
  921. pipeline_connection_desc := c.GetString("pipeline_connection_desc")
  922. collator, _ := c.GetInt64("collator", 0)
  923. employee_number := c.GetString("employee_number")
  924. if id <= 0 {
  925. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  926. return
  927. }
  928. adminUserInfo := c.GetAdminUserInfo()
  929. patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
  930. if patient.ID == 0 {
  931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  932. return
  933. }
  934. if len(recordDateStr) == 0 {
  935. recordDateStr = time.Now().Format("2006-01-02")
  936. }
  937. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  938. if parseDateErr != nil {
  939. c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  941. return
  942. }
  943. var checkDate int64
  944. if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
  945. list, _ := service.GetRoleList(adminUserInfo.CurrentOrgId, modifier)
  946. if employee_number != list.JobNumber {
  947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorEmployeeNumber)
  948. return
  949. }
  950. }
  951. if len(checkTimeStr) == 0 {
  952. //checkTimeStr = time.Now().Format("2006-01-02 15:04")
  953. checkDate = 0
  954. } else {
  955. checkDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", checkTimeStr)
  956. checkDate = checkDateUnix.Unix()
  957. }
  958. var firstCheckTimeDate int64
  959. if len(firstCheckTimeStr) == 0 {
  960. //firstCheckTimeStr = time.Now().Format("2006-01-02 15:04")
  961. firstCheckTimeDate = 0
  962. } else {
  963. firstCheckTimeDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", firstCheckTimeStr)
  964. firstCheckTimeDate = firstCheckTimeDateUnix.Unix()
  965. }
  966. doubleCheck := models.DoubleCheck{
  967. UserOrgId: adminUserInfo.CurrentOrgId,
  968. PatientId: id,
  969. DialysisItemCheck: dialysis_item_check,
  970. DialysisParameterCheck: dialysis_parameter_check,
  971. VascularAccessVerification: vascular_access_verification,
  972. PipelineConnectionCheck: pipeline_connection_check,
  973. DialysisItemDesc: dialysis_item_desc,
  974. DialysisParameterDesc: dialysis_parameter_desc,
  975. VascularAccessDesc: vascular_access_desc,
  976. PipelineConnectionDesc: pipeline_connection_desc,
  977. Collator: collator,
  978. Status: 1,
  979. CreatedTime: time.Now().Unix(),
  980. UpdatedTime: time.Now().Unix(),
  981. CheckDate: recordDate.Unix(),
  982. EmployeeNumber: employee_number,
  983. }
  984. _, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
  985. if check.ID == 0 { //新增
  986. doubleCheck.FirstCheckTime = firstCheckTimeDate
  987. doubleCheck.CheckTime = checkDate
  988. doubleCheck.Creater = creater
  989. doubleCheck.Modifier = modifier
  990. err := service.AddSigleDoubleCheck(&doubleCheck)
  991. redis := service.RedisClient()
  992. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
  993. //清空key 值
  994. redis.Set(key, "", time.Second)
  995. keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  996. redis.Set(keyTwo, "", time.Second)
  997. keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
  998. redis.Set(keyThree, "", time.Second)
  999. defer redis.Close()
  1000. if err == nil {
  1001. c.ServeSuccessJSON(map[string]interface{}{
  1002. "doubleCheck": doubleCheck,
  1003. })
  1004. } else {
  1005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1006. }
  1007. } else { //修改
  1008. doubleCheck.FirstCheckTime = firstCheckTimeDate
  1009. doubleCheck.CheckTime = checkDate
  1010. doubleCheck.Creater = creater
  1011. doubleCheck.Modifier = modifier
  1012. doubleCheck.CreatedTime = check.CreatedTime
  1013. doubleCheck.UpdatedTime = time.Now().Unix()
  1014. doubleCheck.ID = check.ID
  1015. redis := service.RedisClient()
  1016. err := service.UpdateDoubleCheck(&doubleCheck)
  1017. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
  1018. keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  1019. redis.Set(keyTwo, "", time.Second)
  1020. //清空key 值
  1021. redis.Set(key, "", time.Second)
  1022. keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
  1023. redis.Set(keyThree, "", time.Second)
  1024. defer redis.Close()
  1025. if err == nil {
  1026. c.ServeSuccessJSON(map[string]interface{}{
  1027. "doubleCheck": doubleCheck,
  1028. })
  1029. } else {
  1030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1031. }
  1032. }
  1033. }
  1034. func (c *DialysisApiController) PostReceiveTreatmentAsses() {
  1035. id, _ := c.GetInt64("patient", 0)
  1036. recordDateStr := c.GetString("record_date")
  1037. way, _ := c.GetInt64("way", 0)
  1038. consciousness, _ := c.GetInt64("consciousness", 0)
  1039. appetite, _ := c.GetInt64("appetite", 0)
  1040. condition, _ := c.GetInt64("condition", 0)
  1041. posture, _ := c.GetInt64("posture")
  1042. score := c.GetString("score")
  1043. sick_condition, _ := c.GetInt64("sick_condition", 0)
  1044. danger_level, _ := c.GetInt64("danger_level", 0)
  1045. intake, _ := c.GetInt64("intake", 0)
  1046. nutrition, _ := c.GetInt64("nutrition", 0)
  1047. psychological_assessment, _ := c.GetInt64("psychological_assessment", 0)
  1048. psychological_assessment_other := c.GetString("psychological_assessment_other")
  1049. sick_condition_other := c.GetString("sick_condition_other")
  1050. //precaution, _ := c.GetInt64("precaution", 0)
  1051. precaution := c.GetString("precaution")
  1052. precaution_other := c.GetString("precaution_other")
  1053. psychological_other := c.GetString("psychological_other")
  1054. admission_number := c.GetString("admission_number")
  1055. tumble, _ := c.GetInt64("tumble")
  1056. his_department := c.GetString("his_department")
  1057. his_bed := c.GetString("his_bed")
  1058. diacrisis := c.GetString("diacrisis")
  1059. if id <= 0 {
  1060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1061. return
  1062. }
  1063. adminUserInfo := c.GetAdminUserInfo()
  1064. patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
  1065. if patient.ID == 0 {
  1066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1067. return
  1068. }
  1069. if len(recordDateStr) == 0 {
  1070. recordDateStr = time.Now().Format("2006-01-02")
  1071. }
  1072. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1073. if parseDateErr != nil {
  1074. c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1076. return
  1077. }
  1078. _, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
  1079. receiveTreatmentAsses := models.ReceiveTreatmentAsses{
  1080. UserOrgId: adminUserInfo.CurrentOrgId,
  1081. PatientId: id,
  1082. RecordDate: recordDate.Unix(),
  1083. Way: way,
  1084. Consciousness: consciousness,
  1085. Appetite: appetite,
  1086. Condition: condition,
  1087. SickCondition: sick_condition,
  1088. DangerLevel: danger_level,
  1089. Intake: intake,
  1090. Nutrition: nutrition,
  1091. PsychologicalAssessment: psychological_assessment,
  1092. PsychologicalAssessmentOther: psychological_assessment_other,
  1093. SickConditionOther: sick_condition_other,
  1094. Posture: posture,
  1095. CreatedTime: time.Now().Unix(),
  1096. UpdateTime: time.Now().Unix(),
  1097. Status: 1,
  1098. Score: score,
  1099. Precaution: precaution,
  1100. PrecautionOther: precaution_other,
  1101. PsychologicalOther: psychological_other,
  1102. AdmissionNumber: admission_number,
  1103. Tumble: tumble,
  1104. HisDepartment: his_department,
  1105. HisBed: his_bed,
  1106. Diacrisis: diacrisis,
  1107. }
  1108. if receiveTreatment.ID == 0 { //新增
  1109. receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
  1110. err := service.AddSigleReceiveTreatmentAssesRecord(&receiveTreatmentAsses)
  1111. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
  1112. redis := service.RedisClient()
  1113. //清空key 值
  1114. redis.Set(key, "", time.Second)
  1115. defer redis.Close()
  1116. if err == nil {
  1117. c.ServeSuccessJSON(map[string]interface{}{
  1118. "receiveTreatmentAsses": receiveTreatmentAsses,
  1119. })
  1120. } else {
  1121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1122. }
  1123. } else { //修改
  1124. //if receiveTreatment.Creater != adminUserInfo.AdminUser.Id {
  1125. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  1126. // if getPermissionErr != nil {
  1127. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1128. // return
  1129. // } else if headNursePermission == nil {
  1130. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  1131. // return
  1132. // }
  1133. //}
  1134. receiveTreatmentAsses.Creater = receiveTreatment.Creater
  1135. receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
  1136. receiveTreatmentAsses.UpdateTime = time.Now().Unix()
  1137. receiveTreatmentAsses.Modifier = adminUserInfo.AdminUser.Id
  1138. receiveTreatmentAsses.ID = receiveTreatment.ID
  1139. err := service.UpadateReceiveTreatmentAsses(&receiveTreatmentAsses)
  1140. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
  1141. redis := service.RedisClient()
  1142. defer redis.Close()
  1143. redis.Set(keyOne, "", time.Second*60*60*18)
  1144. if err == nil {
  1145. c.ServeSuccessJSON(map[string]interface{}{
  1146. "receiveTreatmentAsses": receiveTreatmentAsses,
  1147. })
  1148. } else {
  1149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1150. }
  1151. }
  1152. }
  1153. func (c *DialysisApiController) PostAssessmentAfterDislysis() {
  1154. patient, _ := c.GetInt64("patient", 0)
  1155. recordDateStr := c.GetString("record_date")
  1156. fmt.Println(recordDateStr)
  1157. if patient <= 0 {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1159. return
  1160. }
  1161. adminUserInfo := c.GetAdminUserInfo()
  1162. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  1163. if patientInfo.ID == 0 {
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1165. return
  1166. }
  1167. if len(recordDateStr) == 0 {
  1168. recordDateStr = time.Now().Format("2006-01-02")
  1169. }
  1170. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1171. if parseDateErr != nil {
  1172. c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  1173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1174. return
  1175. }
  1176. // data := make(map[string]interface{}, 0)
  1177. var data models.AssessmentAfterDislysis
  1178. var err error
  1179. err = json.Unmarshal(c.Ctx.Input.RequestBody, &data)
  1180. fmt.Println(err)
  1181. if err != nil {
  1182. c.ErrorLog("数据解析错误:%v", err)
  1183. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1184. return
  1185. }
  1186. assessment, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
  1187. assessment.DialysisOrderId = data.DialysisOrderId
  1188. assessment.Evaluator = adminUserInfo.AdminUser.Id
  1189. assessment.Status = 1
  1190. assessment.WeightAfter = data.WeightAfter
  1191. assessment.WeightLoss = data.WeightLoss
  1192. assessment.Temperature = data.Temperature
  1193. assessment.SystolicBloodPressure = data.SystolicBloodPressure
  1194. assessment.DiastolicBloodPressure = data.DiastolicBloodPressure
  1195. assessment.PulseFrequency = data.PulseFrequency
  1196. assessment.ActualUltrafiltration = data.ActualUltrafiltration
  1197. assessment.ActualDisplacement = data.ActualDisplacement
  1198. assessment.ActualTreatmentHour = data.ActualTreatmentHour
  1199. assessment.ActualTreatmentMinute = data.ActualTreatmentMinute
  1200. assessment.Cruor = data.Cruor
  1201. assessment.SymptomAfterDialysis = data.SymptomAfterDialysis
  1202. assessment.DialysisIntakes = data.DialysisIntakes
  1203. assessment.InternalFistula = data.InternalFistula
  1204. assessment.BloodAccessPartId = data.BloodAccessPartId
  1205. assessment.BloodAccessPartOperaId = data.BloodAccessPartOperaId
  1206. assessment.Catheter = data.Catheter
  1207. assessment.Complication = data.Complication
  1208. assessment.PuncturePointOozingBlood = data.PuncturePointOozingBlood
  1209. assessment.PuncturePointHaematoma = data.PuncturePointHaematoma
  1210. assessment.InternalFistulaTremorAc = data.InternalFistulaTremorAc
  1211. assessment.PatientGose = data.PatientGose
  1212. assessment.InpatientDepartment = data.InpatientDepartment
  1213. assessment.ObservationContent = data.ObservationContent
  1214. assessment.ObservationContentOther = data.ObservationContentOther
  1215. assessment.Remark = data.Remark
  1216. assessment.BreathingRate = data.BreathingRate
  1217. assessment.DialysisProcess = data.DialysisProcess
  1218. assessment.InAdvanceMinute = data.InAdvanceMinute
  1219. assessment.InAdvanceReasonOther = data.InAdvanceReasonOther
  1220. assessment.InAdvanceReason = data.InAdvanceReason
  1221. assessment.HemostasisOpera = data.HemostasisOpera
  1222. assessment.HemostasisMinute = data.HemostasisMinute
  1223. assessment.TremorNoise = data.TremorNoise
  1224. assessment.DisequilibriumSyndrome = data.DisequilibriumSyndrome
  1225. assessment.DisequilibriumSyndromeOption = data.DisequilibriumSyndromeOption
  1226. assessment.ArterialTube = data.ArterialTube
  1227. assessment.IntravenousTube = data.IntravenousTube
  1228. assessment.DialysisIntakesUnit = data.DialysisIntakesUnit
  1229. assessment.Dialyzer = data.Dialyzer
  1230. assessment.IsEat = data.IsEat
  1231. assessment.CvcA = data.CvcA
  1232. assessment.CvcV = data.CvcV
  1233. assessment.Channel = data.Channel
  1234. assessment.ReturnBlood = data.ReturnBlood
  1235. assessment.RehydrationVolume = data.RehydrationVolume
  1236. assessment.DialysisDuring = data.DialysisDuring
  1237. assessment.StrokeVolume = data.StrokeVolume
  1238. assessment.BloodFlow = data.BloodFlow
  1239. assessment.SealingFluidDispose = data.SealingFluidDispose
  1240. assessment.SealingFluidSpecial = data.SealingFluidSpecial
  1241. assessment.DosageOfAnticoagulants = data.DosageOfAnticoagulants
  1242. assessment.SupineSystolicBloodPressure = data.SupineSystolicBloodPressure
  1243. assessment.SettingPressure = data.SettingPressure
  1244. assessment.SupineDiastolicBloodPressure = data.SupineDiastolicBloodPressure
  1245. assessment.DiastolicPressure = data.DiastolicPressure
  1246. assessment.AdditionalWeight = data.AdditionalWeight
  1247. assessment.OtherComplication = data.OtherComplication
  1248. assessment.Ktv = data.Ktv
  1249. assessment.Urr = data.Urr
  1250. assessment.Hypertenison = data.Hypertenison
  1251. assessment.Hypopiesia = data.Hypopiesia
  1252. assessment.LeaveOfficeMethod = data.LeaveOfficeMethod
  1253. assessment.Lapse = data.Lapse
  1254. assessment.Consciousness = data.Consciousness
  1255. assessment.Fallrisk = data.Fallrisk
  1256. assessment.MachineRun = data.MachineRun
  1257. assessment.AfterUrea = data.AfterUrea
  1258. assessment.PipCoagulation = data.PipCoagulation
  1259. assessment.AccumulatedBloodVolume = data.AccumulatedBloodVolume
  1260. appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
  1261. if assessment.ID > 0 {
  1262. if appRole.UserType == 2 || appRole.UserType == 1 {
  1263. assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
  1264. assessment.AssessmentTime = time.Now().Unix()
  1265. } else {
  1266. if assessment.Creater == 0 {
  1267. assessment.Modifier = adminUserInfo.AdminUser.Id
  1268. assessment.Creater = adminUserInfo.AdminUser.Id
  1269. } else {
  1270. assessment.Modifier = adminUserInfo.AdminUser.Id
  1271. }
  1272. }
  1273. assessment.UpdatedTime = time.Now().Unix()
  1274. err = service.UpdateAssessmentAfterDislysisRecord(&assessment)
  1275. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
  1276. redis := service.RedisClient()
  1277. //清空key 值
  1278. redis.Set(key, "", time.Second)
  1279. keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
  1280. redis.Set(keyThree, "", time.Second)
  1281. keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  1282. redis.Set(keyTwo, "", time.Second)
  1283. defer redis.Close()
  1284. } else {
  1285. if appRole.UserType == 2 || appRole.UserType == 1 {
  1286. assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
  1287. assessment.AssessmentTime = time.Now().Unix()
  1288. } else {
  1289. assessment.Creater = adminUserInfo.AdminUser.Id
  1290. }
  1291. assessment.CreatedTime = time.Now().Unix()
  1292. assessment.UpdatedTime = time.Now().Unix()
  1293. assessment.UserOrgId = adminUserInfo.CurrentOrgId
  1294. assessment.PatientId = patient
  1295. assessment.AssessmentDate = recordDate.Unix()
  1296. err = service.AddSigleAssessmentAfterDislysisRecord(&assessment)
  1297. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
  1298. redis := service.RedisClient()
  1299. //清空key 值
  1300. redis.Set(key, "", time.Second)
  1301. keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
  1302. redis.Set(keyThree, "", time.Second)
  1303. keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  1304. redis.Set(keyTwo, "", time.Second)
  1305. defer redis.Close()
  1306. }
  1307. if err != nil {
  1308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1309. return
  1310. }
  1311. c.ServeSuccessJSON(map[string]interface{}{
  1312. "AssessmentAfterDislysis": &assessment,
  1313. })
  1314. }
  1315. func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
  1316. patient, _ := c.GetInt64("patient", 0)
  1317. recordDateStr := c.GetString("record_date")
  1318. if patient <= 0 {
  1319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1320. return
  1321. }
  1322. adminUserInfo := c.GetAdminUserInfo()
  1323. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  1324. if patientInfo.ID == 0 {
  1325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1326. return
  1327. }
  1328. if len(recordDateStr) == 0 {
  1329. recordDateStr = time.Now().Format("2006-01-02")
  1330. }
  1331. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1332. if parseDateErr != nil {
  1333. c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  1334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1335. return
  1336. }
  1337. weight_before, _ := c.GetFloat("weight_before", 0)
  1338. dry_weight, _ := c.GetFloat("dry_weight", 0)
  1339. additional_weight, _ := c.GetFloat("additional_weight", 0)
  1340. temperature, _ := c.GetFloat("temperature", 0)
  1341. pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
  1342. systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
  1343. diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
  1344. last_post_dialysis := c.GetString("last_post_dialysis")
  1345. dialysis_interphase := c.GetString("dialysis_interphase")
  1346. symptom_before_dialysis := c.GetString("symptom_before_dialysis")
  1347. bloodAccessPartOperaId, _ := c.GetInt64("blood_access_part_opera_id", 0)
  1348. //bloodAccessPartId, _ := c.GetInt64("blood_access_part_id", 0)
  1349. bloodAccessPartId := c.GetString("blood_access_part_id")
  1350. internalFistula := c.GetString("internal_fistula")
  1351. internal_fistula_skin := c.GetString("internal_fistula_skin")
  1352. catheter := c.GetString("catheter")
  1353. catheter_bend, _ := c.GetInt("catheter_bend")
  1354. complication := c.GetString("complication")
  1355. is_hemorrhage, _ := c.GetInt64("is_hemorrhage", 0)
  1356. hemorrhage := c.GetString("hemorrhage")
  1357. hemorrhage_other := c.GetString("hemorrhage_other")
  1358. remark := c.GetString("remark")
  1359. puncture_method := c.GetString("puncture_method")
  1360. dialysis_count := c.GetString("dialysis_count")
  1361. emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
  1362. emergency_treatment_other := c.GetString("emergency_treatment_other")
  1363. ductus_arantii := c.GetString("ductus_arantii")
  1364. venous_catheterization_part_other := c.GetString("venous_catheterization_part_other")
  1365. venous_catheterization_part, _ := c.GetInt64("venous_catheterization_part", 0)
  1366. venous_catheterization, _ := c.GetInt64("venous_catheterization", 0)
  1367. //puncture_way, _ := c.GetInt64("puncture_way", 0)
  1368. puncture_way := c.GetString("puncture_way")
  1369. blood_access_noise, _ := c.GetInt64("blood_access_noise", 0)
  1370. internal_fistula_other := c.GetString("internal_fistula_other")
  1371. blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
  1372. breathing_rate := c.GetString("breathing_rate")
  1373. is_infect, _ := c.GetInt64("is_infect", 0)
  1374. exposed, _ := c.GetFloat("exposed", 0)
  1375. skin := c.GetString("skin")
  1376. skin_other := c.GetString("skin_other")
  1377. infect_other := c.GetString("infect_other")
  1378. ductus_arantii_other := c.GetString("ductus_arantii_other")
  1379. machine_type := c.GetString("machine_type")
  1380. puncture_needle := c.GetString("puncture_needle")
  1381. //humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
  1382. humor_excessive_symptom := c.GetString("humor_excessive_symptom")
  1383. phinholing := c.GetString("pinholing")
  1384. catheter_suture := c.GetString("catheter_suture")
  1385. catheter_suture_other := c.GetString("catheter_suture_other")
  1386. edema := c.GetString("edema")
  1387. urine_volume, _ := c.GetFloat("urine_volume", 0)
  1388. special_treatment := c.GetString("special_treatment")
  1389. catheter_maintenance := c.GetString("catheter_maintenance")
  1390. thrombusType := c.GetString("thromubus_type")
  1391. thrombusInt, _ := strconv.ParseInt(thrombusType, 10, 64)
  1392. thrombus_a := c.GetString("thromubus_a")
  1393. thrombus_av := c.GetString("thrombus_av")
  1394. thrombus_v := c.GetString("thromubus_v")
  1395. dehydration := c.GetString("dehydration")
  1396. pre_dialysis_drugs := c.GetString("pre_dialysis_drugs")
  1397. period, _ := c.GetInt64("period")
  1398. estimated_food_intake := c.GetString("estimated_food_intake")
  1399. blood_pressure_during_dialysis := c.GetString("blood_pressure_during_dialysis")
  1400. urea_befor := c.GetString("urea_befor")
  1401. suction := c.GetString("suction")
  1402. weight_befor_remake := c.GetString("weight_befor_remake")
  1403. height := c.GetString("height")
  1404. age := c.GetString("age")
  1405. his_department := c.GetString("his_department")
  1406. his_bed := c.GetString("his_bed")
  1407. assessmentBeforeDislysis := models.PredialysisEvaluation{
  1408. DialysisCount: dialysis_count,
  1409. EmergencyTreatment: emergency_treatment,
  1410. EmergencyTreatmentOther: emergency_treatment_other,
  1411. DuctusArantii: ductus_arantii,
  1412. VenousCatheterization: venous_catheterization,
  1413. VenousCatheterizationPart: venous_catheterization_part,
  1414. VenousCatheterizationPartOther: venous_catheterization_part_other,
  1415. PunctureWay: puncture_way,
  1416. BloodAccessInternalFistula: blood_access_internal_fistula,
  1417. BloodAccessNoise: blood_access_noise,
  1418. InternalFistulaOther: internal_fistula_other,
  1419. Evaluator: adminUserInfo.AdminUser.Id,
  1420. UserOrgId: adminUserInfo.CurrentOrgId,
  1421. PatientId: patient,
  1422. AssessmentDate: recordDate.Unix(),
  1423. Temperature: temperature,
  1424. PulseFrequency: pulse_frequency,
  1425. SystolicBloodPressure: systolic_blood_pressure,
  1426. DiastolicBloodPressure: diastolic_blood_pressure,
  1427. WeightBefore: weight_before,
  1428. DryWeight: dry_weight,
  1429. AdditionalWeight: additional_weight,
  1430. DialysisInterphase: dialysis_interphase,
  1431. LastPostDialysis: last_post_dialysis,
  1432. SymptomBeforeDialysis: symptom_before_dialysis,
  1433. InternalFistula: internalFistula,
  1434. InternalFistulaSkin: internal_fistula_skin,
  1435. Catheter: catheter,
  1436. CatheterBend: catheter_bend,
  1437. Complication: complication,
  1438. CreatedTime: time.Now().Unix(),
  1439. Status: 1,
  1440. Remark: remark,
  1441. IsHemorrhage: is_hemorrhage,
  1442. Hemorrhage: hemorrhage,
  1443. HemorrhageOther: hemorrhage_other,
  1444. BloodAccessPartId: bloodAccessPartId,
  1445. BloodAccessPartOperaId: bloodAccessPartOperaId,
  1446. PunctureMethod: puncture_method,
  1447. BreathingRate: breathing_rate,
  1448. IsInfect: is_infect,
  1449. Exposed: exposed,
  1450. Skin: skin,
  1451. SkinOther: skin_other,
  1452. InfectOther: infect_other,
  1453. DuctusArantiiOther: ductus_arantii_other,
  1454. MachineType: machine_type,
  1455. PunctureNeedle: puncture_needle,
  1456. HumorExcessiveSymptom: humor_excessive_symptom,
  1457. Phinholing: phinholing,
  1458. CatheterSuture: catheter_suture,
  1459. CatheterSutureOther: catheter_suture_other,
  1460. Edema: edema,
  1461. UrineVolume: urine_volume,
  1462. SpecialTreatment: special_treatment,
  1463. CatheterMaintenance: catheter_maintenance,
  1464. ThromubusType: thrombusInt,
  1465. ThrombusAv: thrombus_av,
  1466. ThromubusA: thrombus_a,
  1467. ThromubusV: thrombus_v,
  1468. Dehydration: dehydration,
  1469. PreDialysisDrugs: pre_dialysis_drugs,
  1470. Period: period,
  1471. EstimatedFoodIntake: estimated_food_intake,
  1472. BloodPressureDuringDialysis: blood_pressure_during_dialysis,
  1473. UreaBefor: urea_befor,
  1474. Suction: suction,
  1475. WeightBeforRemake: weight_befor_remake,
  1476. Height: height,
  1477. Age: age,
  1478. HisDepartment: his_department,
  1479. HisBed: his_bed,
  1480. }
  1481. appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
  1482. _, evaluation := service.FindPredialysisEvaluationByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
  1483. if evaluation.ID == 0 { //新增
  1484. if appRole.UserType == 2 || appRole.UserType == 1 {
  1485. assessmentBeforeDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
  1486. assessmentBeforeDislysis.AssessmentTime = time.Now().Unix()
  1487. } else {
  1488. assessmentBeforeDislysis.Creater = adminUserInfo.AdminUser.Id
  1489. }
  1490. err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
  1491. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
  1492. redis := service.RedisClient()
  1493. //清空key 值
  1494. redis.Set(key, "", time.Second)
  1495. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
  1496. redis.Set(keyOne, "", time.Second)
  1497. keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  1498. redis.Set(keyTwo, "", time.Second)
  1499. defer redis.Close()
  1500. if err == nil {
  1501. c.ServeSuccessJSON(map[string]interface{}{
  1502. "assessmentBeforeDislysis": &assessmentBeforeDislysis,
  1503. })
  1504. } else {
  1505. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1507. }
  1508. } else { //修改
  1509. //if appRole.UserType == 3 {
  1510. // if evaluation.Creater != adminUserInfo.AdminUser.Id && evaluation.Creater != 0 {
  1511. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  1512. // if getPermissionErr != nil {
  1513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1514. // return
  1515. // } else if headNursePermission == nil {
  1516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  1517. // return
  1518. // }
  1519. // }
  1520. //}
  1521. if appRole.UserType == 2 || appRole.UserType == 1 {
  1522. assessmentBeforeDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
  1523. assessmentBeforeDislysis.AssessmentTime = time.Now().Unix()
  1524. } else {
  1525. if evaluation.Creater == 0 {
  1526. assessmentBeforeDislysis.Modifier = adminUserInfo.AdminUser.Id
  1527. assessmentBeforeDislysis.Creater = adminUserInfo.AdminUser.Id
  1528. } else {
  1529. assessmentBeforeDislysis.Modifier = adminUserInfo.AdminUser.Id
  1530. }
  1531. }
  1532. assessmentBeforeDislysis.UpdatedTime = time.Now().Unix()
  1533. assessmentBeforeDislysis.ID = evaluation.ID
  1534. assessmentBeforeDislysis.CreatedTime = evaluation.CreatedTime
  1535. //
  1536. //新增逻辑
  1537. templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  1538. var dewater_amount float64
  1539. dewater_amount = 0
  1540. if evaluation.DryWeight > 0 {
  1541. dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
  1542. if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 {
  1543. dewater_amount = dewater_amount * 1000
  1544. }
  1545. if dewater_amount <= 0 {
  1546. dewater_amount = 0
  1547. }
  1548. } else {
  1549. dewater_amount = 0
  1550. }
  1551. // 计算透析处方的相关超滤量
  1552. schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
  1553. var lastDialysisPrescribe *models.DialysisPrescription
  1554. var dialysisSolution *models.DialysisSolution
  1555. var dialysisPrescribe *models.DialysisPrescription
  1556. var mode_id int64
  1557. if schedual != nil {
  1558. dialysisPrescribe, _ = service.MobileGetDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix(), schedual.ModeId)
  1559. if dialysisPrescribe == nil {
  1560. dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
  1561. }
  1562. lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
  1563. // 获取透析模版
  1564. dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
  1565. mode_id = schedual.ModeId
  1566. } else {
  1567. //lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribe(adminUserInfo.Org.Id, id,schedual.ModeId)
  1568. // 获取透析模版
  1569. dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
  1570. dialysisSolution, _ = service.MobileGetDialysisSolution(adminUserInfo.CurrentOrgId, patient)
  1571. if dialysisPrescribe == nil && dialysisSolution != nil {
  1572. mode_id = dialysisSolution.ModeId
  1573. }
  1574. if dialysisPrescribe == nil && dialysisSolution == nil {
  1575. mode_id = 0
  1576. }
  1577. }
  1578. // 插入透析处方
  1579. if dialysisPrescribe == nil && dialysisSolution != nil {
  1580. var newprescribe models.DialysisPrescription
  1581. newprescribe.UserOrgId = dialysisSolution.UserOrgId
  1582. newprescribe.PatientId = dialysisSolution.PatientId
  1583. newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
  1584. newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
  1585. newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
  1586. newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
  1587. newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
  1588. newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
  1589. newprescribe.ModeId = dialysisSolution.ModeId
  1590. newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
  1591. newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
  1592. newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
  1593. newprescribe.BloodFilter = dialysisSolution.BloodFilter
  1594. newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
  1595. newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
  1596. newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
  1597. newprescribe.Glucose = dialysisSolution.Glucose
  1598. newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
  1599. newprescribe.Kalium = dialysisSolution.Kalium
  1600. newprescribe.Sodium = dialysisSolution.Sodium
  1601. newprescribe.Calcium = dialysisSolution.Calcium
  1602. newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
  1603. newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
  1604. newprescribe.Conductivity = dialysisSolution.Conductivity
  1605. newprescribe.BodyFluid = dialysisSolution.BodyFluid
  1606. newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
  1607. newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
  1608. newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
  1609. newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
  1610. newprescribe.BloodAccess = dialysisSolution.BloodAccess
  1611. newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
  1612. newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
  1613. newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
  1614. newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
  1615. newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
  1616. newprescribe.Dialyzer = dialysisSolution.Dialyzer
  1617. newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
  1618. newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
  1619. newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
  1620. newprescribe.TargetKtv = dialysisSolution.TargetKtv
  1621. newprescribe.CreatedTime = time.Now().Unix()
  1622. newprescribe.UpdatedTime = time.Now().Unix()
  1623. newprescribe.RecordDate = recordDate.Unix()
  1624. newprescribe.DewaterAmount = dewater_amount
  1625. newprescribe.TargetUltrafiltration = dewater_amount
  1626. newprescribe.Status = 1
  1627. err := service.AddSigleRecord(&newprescribe)
  1628. if err != nil {
  1629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1630. }
  1631. }
  1632. if dialysisPrescribe == nil && dialysisSolution == nil {
  1633. if lastDialysisPrescribe != nil {
  1634. var newprescribe models.DialysisPrescription
  1635. newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
  1636. newprescribe.PatientId = lastDialysisPrescribe.PatientId
  1637. newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
  1638. newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
  1639. newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
  1640. newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
  1641. newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
  1642. newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
  1643. newprescribe.ModeId = lastDialysisPrescribe.ModeId
  1644. newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
  1645. newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
  1646. newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
  1647. newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
  1648. newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
  1649. newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
  1650. newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
  1651. newprescribe.Glucose = lastDialysisPrescribe.Glucose
  1652. newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
  1653. newprescribe.Kalium = lastDialysisPrescribe.Kalium
  1654. newprescribe.Sodium = lastDialysisPrescribe.Sodium
  1655. newprescribe.Calcium = lastDialysisPrescribe.Calcium
  1656. newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
  1657. newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
  1658. newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
  1659. newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
  1660. newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
  1661. newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
  1662. newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
  1663. newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
  1664. newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
  1665. newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
  1666. newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
  1667. newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
  1668. newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
  1669. newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
  1670. newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
  1671. newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
  1672. newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
  1673. newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
  1674. newprescribe.CreatedTime = time.Now().Unix()
  1675. newprescribe.UpdatedTime = time.Now().Unix()
  1676. newprescribe.RecordDate = recordDate.Unix()
  1677. newprescribe.DewaterAmount = dewater_amount
  1678. newprescribe.TargetUltrafiltration = dewater_amount
  1679. newprescribe.Status = 1
  1680. err := service.AddSigleRecord(&newprescribe)
  1681. if err != nil {
  1682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1683. }
  1684. } else {
  1685. var newprescribe models.DialysisPrescription
  1686. newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
  1687. newprescribe.PatientId = patient
  1688. newprescribe.ModeId = mode_id
  1689. newprescribe.CreatedTime = time.Now().Unix()
  1690. newprescribe.UpdatedTime = time.Now().Unix()
  1691. newprescribe.RecordDate = recordDate.Unix()
  1692. newprescribe.DewaterAmount = dewater_amount
  1693. newprescribe.TargetUltrafiltration = dewater_amount
  1694. newprescribe.Status = 1
  1695. err := service.AddSigleRecord(&newprescribe)
  1696. if err != nil {
  1697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1698. }
  1699. }
  1700. }
  1701. err := service.UpadatePredialysisEvaluation(&assessmentBeforeDislysis)
  1702. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
  1703. redis := service.RedisClient()
  1704. //清空key 值
  1705. redis.Set(key, "", time.Second)
  1706. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
  1707. redis.Set(keyOne, "", time.Second)
  1708. defer redis.Close()
  1709. keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  1710. redis.Set(keyTwo, "", time.Second)
  1711. if err == nil {
  1712. c.ServeSuccessJSON(map[string]interface{}{
  1713. "assessmentBeforeDislysis": &assessmentBeforeDislysis,
  1714. })
  1715. } else {
  1716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1717. }
  1718. }
  1719. }
  1720. func (c *DialysisApiController) PostTreatmentSummary() {
  1721. patient, _ := c.GetInt64("patient", 0)
  1722. recordDateStr := c.GetString("record_date")
  1723. if patient <= 0 {
  1724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1725. return
  1726. }
  1727. adminUserInfo := c.GetAdminUserInfo()
  1728. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  1729. if patientInfo.ID == 0 {
  1730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1731. return
  1732. }
  1733. if len(recordDateStr) == 0 {
  1734. recordDateStr = time.Now().Format("2006-01-02")
  1735. }
  1736. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  1737. if parseDateErr != nil {
  1738. c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  1739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1740. return
  1741. }
  1742. mission := c.GetString("mission")
  1743. dialysis_summary := c.GetString("dialysis_summary")
  1744. nursingRecord := c.GetString("nursing_record")
  1745. specialRecord := c.GetString("special_record")
  1746. sj_nurse := adminUserInfo.AdminUser.Id
  1747. zl_nurse := adminUserInfo.AdminUser.Id
  1748. hd_nurse := adminUserInfo.AdminUser.Id
  1749. xj_nurse := adminUserInfo.AdminUser.Id
  1750. zl_doctor := adminUserInfo.AdminUser.Id
  1751. treatmentSummary := models.TreatmentSummary{
  1752. UserOrgId: adminUserInfo.CurrentOrgId,
  1753. PatientId: patient,
  1754. AssessmentDate: recordDate.Unix(),
  1755. Mission: mission,
  1756. DialysisSummary: dialysis_summary,
  1757. SjNurse: sj_nurse,
  1758. ZlNurse: zl_nurse,
  1759. HdNurse: hd_nurse,
  1760. XjNurse: xj_nurse,
  1761. ZlDoctor: zl_doctor,
  1762. Status: 1,
  1763. CreatedTime: time.Now().Unix(),
  1764. NursingRecord: nursingRecord,
  1765. SpecialRecord: specialRecord,
  1766. }
  1767. _, tempTreatmentSummary := service.FindTreatmentSummaryByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
  1768. if tempTreatmentSummary.ID == 0 { //新增
  1769. treatmentSummary.Creater = adminUserInfo.AdminUser.Id
  1770. err := service.AddSigleSummaryRecord(&treatmentSummary)
  1771. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
  1772. redis := service.RedisClient()
  1773. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
  1774. redis.Set(keyOne, "", time.Second)
  1775. keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  1776. redis.Set(keyThree, "", time.Second)
  1777. defer redis.Close()
  1778. //清空key 值
  1779. redis.Set(key, "", time.Second)
  1780. if err == nil {
  1781. c.ServeSuccessJSON(map[string]interface{}{
  1782. "summary": treatmentSummary,
  1783. })
  1784. } else {
  1785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1786. }
  1787. } else { //修改
  1788. //if tempTreatmentSummary.Creater != adminUserInfo.AdminUser.Id {
  1789. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  1790. // if getPermissionErr != nil {
  1791. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1792. // return
  1793. // } else if headNursePermission == nil {
  1794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  1795. // return
  1796. // }
  1797. //}
  1798. treatmentSummary.Creater = tempTreatmentSummary.Creater
  1799. treatmentSummary.CreatedTime = tempTreatmentSummary.CreatedTime
  1800. treatmentSummary.UpdatedTime = time.Now().Unix()
  1801. treatmentSummary.Modifier = adminUserInfo.AdminUser.Id
  1802. treatmentSummary.ID = tempTreatmentSummary.ID
  1803. err := service.UpdateSummeRecord(&treatmentSummary)
  1804. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
  1805. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
  1806. keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  1807. //清空key 值
  1808. redis := service.RedisClient()
  1809. redis.Set(key, "", time.Second)
  1810. redis.Set(keyOne, "", time.Second)
  1811. redis.Set(keyThree, "", time.Second)
  1812. defer redis.Close()
  1813. if err == nil {
  1814. c.ServeSuccessJSON(map[string]interface{}{
  1815. "summary": treatmentSummary,
  1816. })
  1817. } else {
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  1819. }
  1820. }
  1821. }
  1822. func (c *DialysisApiController) GetDeviceList() {
  1823. adminUserInfo := c.GetAdminUserInfo()
  1824. device, _ := service.FindAllDeviceInfo(adminUserInfo.CurrentOrgId)
  1825. c.ServeSuccessJSON(map[string]interface{}{
  1826. "device": device,
  1827. })
  1828. }
  1829. func (c *DialysisApiController) GetAllDeviceZone() {
  1830. adminUserInfo := c.GetAdminUserInfo()
  1831. err, zone := service.GetAllDeviceZone(adminUserInfo.CurrentOrgId)
  1832. dics, _, err := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
  1833. if err == nil {
  1834. c.ServeSuccessJSON(map[string]interface{}{
  1835. "zone": zone,
  1836. "dics": dics,
  1837. })
  1838. }
  1839. }
  1840. func (c *DialysisApiController) GetDialysisWatch() {
  1841. page, _ := c.GetInt64("page", 1)
  1842. limit, _ := c.GetInt64("limit", 10)
  1843. schedulType, _ := c.GetInt64("schedul_type", 0)
  1844. startTime, _ := c.GetInt64("schedul_time", 0)
  1845. partitionType, _ := c.GetInt64("partition_type", 0)
  1846. keywords := c.GetString("keywords")
  1847. start_time, _ := c.GetInt64("start_time")
  1848. end_time, _ := c.GetInt64("end_time")
  1849. adminUserInfo := c.GetAdminUserInfo()
  1850. if len(keywords) > 0 {
  1851. dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
  1852. if err == nil {
  1853. c.ServeSuccessJSON(map[string]interface{}{
  1854. "schedule": dialysisSchedule,
  1855. "total": total,
  1856. })
  1857. } else {
  1858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1859. }
  1860. } else {
  1861. dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
  1862. if err == nil {
  1863. c.ServeSuccessJSON(map[string]interface{}{
  1864. "schedule": dialysisSchedule,
  1865. "total": total,
  1866. })
  1867. } else {
  1868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1869. }
  1870. }
  1871. }
  1872. //func (c *DialysisApiController) GetDialysisWatch() {
  1873. // page, _ := c.GetInt64("page", 1)
  1874. // limit, _ := c.GetInt64("limit", 10)
  1875. // schedulType, _ := c.GetInt64("schedul_type", 0)
  1876. // startTime, _ := c.GetInt64("schedul_time", 0)
  1877. // partitionType, _ := c.GetInt64("partition_type", 0)
  1878. // keywords := c.GetString("keywords")
  1879. //
  1880. // adminUserInfo := c.GetAdminUserInfo()
  1881. // if len(keywords) > 0 {
  1882. // dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit)
  1883. //
  1884. // //获取所有床位号
  1885. // numberList, _ := service.GetAllDeviceNumberByListSix(adminUserInfo.CurrentOrgId)
  1886. //
  1887. // //获取透析处方
  1888. // prescriptions, _ := service.GetAllPrescriptionByListTwo(adminUserInfo.CurrentOrgId, startTime)
  1889. // //获取透前评估
  1890. // assessmentBefores, _ := service.GetAllAssessmentBeforesByListThree(adminUserInfo.CurrentOrgId, startTime)
  1891. // //获取上机
  1892. // dialysisOrders, _ := service.GetAllDialysisOrdersByListThree(adminUserInfo.CurrentOrgId, startTime)
  1893. // //获取透后
  1894. // AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListThree(adminUserInfo.CurrentOrgId, startTime)
  1895. //
  1896. // //获取透后监测
  1897. // monitorlist, _ := service.GetAllMonitorListThree(adminUserInfo.CurrentOrgId, startTime)
  1898. //
  1899. // //获取所有的患者
  1900. // patients, _ := service.GetAllPatientListByListSix(adminUserInfo.CurrentOrgId,keywords)
  1901. //
  1902. // //获取所有透析模式
  1903. // treatments, _ := service.GetAllTreatModeByList(adminUserInfo.CurrentOrgId)
  1904. //
  1905. // for key, scheduals := range dialysisSchedule {
  1906. // // 获取患者信息
  1907. // for _, patient := range patients {
  1908. // if scheduals.PatientId == patient.ID {
  1909. // dialysisSchedule[key].MonitorPatients = patient
  1910. // break
  1911. // }
  1912. // }
  1913. // // 床位信息
  1914. // for _, device := range numberList {
  1915. // if scheduals.BedId == device.ID {
  1916. // dialysisSchedule[key].DeviceNumber = device
  1917. // break
  1918. // }
  1919. // }
  1920. //
  1921. // // 医嘱信息
  1922. // for _, prescription := range prescriptions {
  1923. // if scheduals.PatientId == prescription.PatientId {
  1924. // dialysisSchedule[key].Prescription = prescription
  1925. // break
  1926. // }
  1927. // }
  1928. //
  1929. // // 透前评估
  1930. // for _, assessmentBefore := range assessmentBefores {
  1931. // if scheduals.PatientId == assessmentBefore.PatientId {
  1932. // dialysisSchedule[key].AssessmentBeforeDislysis = assessmentBefore
  1933. // break
  1934. // }
  1935. // }
  1936. //
  1937. // // 透析上下机
  1938. // for _, dialysisOrder := range dialysisOrders {
  1939. // if scheduals.PatientId == dialysisOrder.PatientId {
  1940. // dialysisSchedule[key].DialysisOrder = dialysisOrder
  1941. // break
  1942. // }
  1943. // }
  1944. //
  1945. // records := make([]*models.MonitoringRecord, 0)
  1946. // // 透析监测
  1947. // for _, it := range monitorlist {
  1948. // records := append(records, it)
  1949. // if scheduals.PatientId == it.PatientId {
  1950. // dialysisSchedule[key].MonitoringRecord = records
  1951. // }
  1952. // }
  1953. //
  1954. // // 透后评估
  1955. // for _, afterDislysis := range AssessmentAfterDislysis {
  1956. // if scheduals.PatientId == afterDislysis.PatientId {
  1957. // dialysisSchedule[key].AssessmentAfterDislysis = afterDislysis
  1958. // break
  1959. // }
  1960. // }
  1961. //
  1962. // //透析模式
  1963. // for _, treatment := range treatments {
  1964. // if scheduals.ModeId == treatment.ID {
  1965. // dialysisSchedule[key].TreatmentMode = treatment
  1966. // break
  1967. // }
  1968. // }
  1969. // }
  1970. // //获取所有床位号
  1971. // if err == nil {
  1972. // c.ServeSuccessJSON(map[string]interface{}{
  1973. // "schedule": dialysisSchedule,
  1974. // "total": total,
  1975. // })
  1976. // } else {
  1977. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1978. // }
  1979. //
  1980. // } else {
  1981. // dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit)
  1982. // if err == nil {
  1983. // c.ServeSuccessJSON(map[string]interface{}{
  1984. // "schedule": dialysisSchedule,
  1985. // "total": total,
  1986. // })
  1987. // } else {
  1988. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1989. // }
  1990. // }
  1991. //}
  1992. func (c *DialysisApiController) GetSchedualPatientsInfo() {
  1993. patientId, _ := c.GetInt64("id", 0)
  1994. record_date, _ := c.GetInt64("record_date", 0)
  1995. adminUserInfo := c.GetAdminUserInfo()
  1996. _, dialysisOrder := service.FindDialysisRecordById(adminUserInfo.CurrentOrgId, patientId, record_date)
  1997. var dialysisStatus int64
  1998. if dialysisOrder == nil { //没有透析记录
  1999. dialysisStatus = 0 //未透析
  2000. } else {
  2001. dialysisStatus = dialysisOrder.Stage
  2002. }
  2003. //用户基本信息
  2004. schedualPatientInfo, _ := service.FindPatientInfoById(adminUserInfo.CurrentOrgId, patientId, record_date)
  2005. //接诊评估
  2006. receiverTreatmentAccess, _ := service.FindReceiverTreatmentAccessRecordById(adminUserInfo.CurrentOrgId, patientId, record_date)
  2007. //透前评估
  2008. PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.CurrentOrgId, patientId, record_date)
  2009. //临时医嘱
  2010. DoctorAdvice, _ := service.FindDoctorAdviceById(adminUserInfo.CurrentOrgId, patientId, record_date)
  2011. //双人核对
  2012. DoubleCheck, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientId, record_date)
  2013. //透析监测
  2014. Record, _ := service.FindAllMonitorRecord(adminUserInfo.CurrentOrgId, patientId, record_date)
  2015. //透后评估
  2016. AssessmentAfterDislysis, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patientId, record_date)
  2017. //透析小结
  2018. TreatmentSummary, _ := service.FindTreatmentSummaryById(adminUserInfo.CurrentOrgId, patientId, record_date)
  2019. //透析处方
  2020. dialysisPrescription, _ := service.FindPatientPrescribeById(adminUserInfo.CurrentOrgId, patientId, record_date)
  2021. if dialysisPrescription.ID == 0 {
  2022. solution, _ := service.FindDialysisSolution(adminUserInfo.CurrentOrgId, patientId)
  2023. c.ServeSuccessJSON(map[string]interface{}{
  2024. "patientInfo": schedualPatientInfo,
  2025. "dialysisPrescription": solution,
  2026. "receiverTreatmentAccess": receiverTreatmentAccess,
  2027. "predialysisEvaluation": PredialysisEvaluation,
  2028. "doctorAdvice": DoctorAdvice,
  2029. "doubleCheck": DoubleCheck,
  2030. "assessmentAfterDislysis": AssessmentAfterDislysis,
  2031. "treatmentSummary": TreatmentSummary,
  2032. "monitorRecord": Record,
  2033. "dialysisStatus": dialysisStatus,
  2034. "dialysisOrder": dialysisOrder,
  2035. "isSolution": 1,
  2036. })
  2037. } else {
  2038. c.ServeSuccessJSON(map[string]interface{}{
  2039. "patientInfo": schedualPatientInfo,
  2040. "dialysisPrescription": dialysisPrescription,
  2041. "receiverTreatmentAccess": receiverTreatmentAccess,
  2042. "predialysisEvaluation": PredialysisEvaluation,
  2043. "doctorAdvice": DoctorAdvice,
  2044. "doubleCheck": DoubleCheck,
  2045. "assessmentAfterDislysis": AssessmentAfterDislysis,
  2046. "treatmentSummary": TreatmentSummary,
  2047. "monitorRecord": Record,
  2048. "dialysisStatus": dialysisStatus,
  2049. "dialysisOrder": dialysisOrder,
  2050. "isSolution": 2,
  2051. })
  2052. }
  2053. }
  2054. func (c *DialysisApiController) CreateDoctorAdvice() {
  2055. patient, _ := c.GetInt64("id", 0)
  2056. dialysis_id, _ := c.GetInt64("dialysis_id", 0)
  2057. record_date, _ := c.GetInt64("record_date", 0)
  2058. if patient <= 0 {
  2059. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2060. return
  2061. }
  2062. adminUserInfo := c.GetAdminUserInfo()
  2063. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  2064. if patientInfo.ID == 0 {
  2065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2066. return
  2067. }
  2068. var advice models.DoctorAdvice
  2069. code, subAdivice := adviceFormDatas(&advice, c.Ctx.Input.RequestBody, "create")
  2070. if code > 0 {
  2071. c.ServeFailJSONWithSGJErrorCode(code)
  2072. return
  2073. }
  2074. if advice.ParentId > 0 {
  2075. old, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, advice.ParentId)
  2076. if old.ID == 0 || old.PatientId != patient {
  2077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
  2078. return
  2079. }
  2080. if old.StopState == 1 || old.ExecutionState == 1 {
  2081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
  2082. return
  2083. }
  2084. if old.ParentId > 0 {
  2085. advice.ParentId = old.ParentId
  2086. }
  2087. advice.StartTime = old.StartTime
  2088. advice.AdviceDoctor = old.AdviceDoctor
  2089. advice.DeliveryWay = old.DeliveryWay
  2090. advice.ExecutionFrequency = old.ExecutionFrequency
  2091. }
  2092. advice.RecordDate = record_date
  2093. advice.DialysisOrderId = dialysis_id
  2094. advice.Status = 1
  2095. advice.CreatedTime = time.Now().Unix()
  2096. advice.UpdatedTime = time.Now().Unix()
  2097. advice.StopState = 2
  2098. advice.ExecutionState = 2
  2099. advice.AdviceType = 2
  2100. advice.UserOrgId = adminUserInfo.CurrentOrgId
  2101. advice.PatientId = patient
  2102. advice.AdviceDoctor = adminUserInfo.AdminUser.Id
  2103. err := service.CreateDoctorAdvice(&advice)
  2104. if err != nil {
  2105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
  2106. return
  2107. }
  2108. for _, subAdvice := range subAdivice {
  2109. subAdvice.ParentId = advice.ID
  2110. subAdvice.PatientId = patient
  2111. subAdvice.RecordDate = record_date
  2112. subAdvice.CreatedTime = time.Now().Unix()
  2113. subAdvice.UpdatedTime = time.Now().Unix()
  2114. subAdvice.UserOrgId = adminUserInfo.CurrentOrgId
  2115. }
  2116. service.CreateSubDoctorAdvice(subAdivice)
  2117. _, subAdivices := service.FindAllSubDoctorAdvice(patient, advice.ID)
  2118. c.ServeSuccessJSON(map[string]interface{}{
  2119. "msg": "ok",
  2120. "advice": advice,
  2121. "subAdvice": subAdivices,
  2122. })
  2123. return
  2124. }
  2125. func (c *DialysisApiController) EditDoctorAdvice() {
  2126. patient, _ := c.GetInt64("patient", 0)
  2127. id, _ := c.GetInt64("id", 0)
  2128. parent_id, _ := c.GetInt64("parent_id", 0)
  2129. execution_time := c.GetString("execution_time")
  2130. // execution_staff, _ := c.GetInt64("execution_staff", 0)
  2131. // checker, _ := c.GetInt64("checker", 0)
  2132. if id <= 0 || patient <= 0 {
  2133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2134. return
  2135. }
  2136. adminUserInfo := c.GetAdminUserInfo()
  2137. advice, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
  2138. if advice.ID == 0 || advice.PatientId != patient {
  2139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
  2140. return
  2141. }
  2142. if len(execution_time) <= 0 {
  2143. utils.ErrorLog("execution_time")
  2144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2145. return
  2146. }
  2147. execution_staff := adminUserInfo.AdminUser.Id
  2148. checker := adminUserInfo.AdminUser.Id
  2149. timeLayout2 := "2006-01-02 15:04"
  2150. loc, _ := time.LoadLocation("Local")
  2151. theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
  2152. if errs != nil {
  2153. utils.ErrorLog(errs.Error())
  2154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2155. return
  2156. }
  2157. advices := models.DoctorAdvice{
  2158. ExecutionStaff: execution_staff,
  2159. ExecutionTime: theTime.Unix(),
  2160. Checker: checker,
  2161. UpdatedTime: time.Now().Unix(),
  2162. }
  2163. var err error
  2164. if parent_id > 0 {
  2165. err = service.ExceDoctorAdviceById(&advices, parent_id, patient)
  2166. } else {
  2167. err = service.ExceDoctorAdviceById(&advices, id, patient)
  2168. }
  2169. if err != nil {
  2170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
  2171. return
  2172. }
  2173. c.ServeSuccessJSON(map[string]interface{}{
  2174. "msg": "ok",
  2175. "advice": advice,
  2176. })
  2177. return
  2178. }
  2179. func (c *DialysisApiController) GetDoctorAdvice() {
  2180. patient, _ := c.GetInt64("patient_id", 0)
  2181. parent_id, _ := c.GetInt64("parent_id", 0)
  2182. adviceId, _ := c.GetInt64("id", 0)
  2183. if patient <= 0 {
  2184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2185. return
  2186. }
  2187. dminUserInfo := c.GetAdminUserInfo()
  2188. patientInfo, _ := service.FindPatientById(dminUserInfo.CurrentOrgId, patient)
  2189. if patientInfo.ID == 0 {
  2190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2191. return
  2192. }
  2193. var subAdvice []*models.DoctorAdvice
  2194. var advice models.DoctorAdvice
  2195. if parent_id > 0 {
  2196. _, advice = service.FindAdivceById(dminUserInfo.CurrentOrgId, patient, parent_id)
  2197. if advice.ID == 0 || advice.PatientId != patient {
  2198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
  2199. return
  2200. }
  2201. subAdvice = service.FindSubAdivceById(patient, parent_id)
  2202. } else {
  2203. _, advice = service.FindAdivceById(dminUserInfo.CurrentOrgId, patient, adviceId)
  2204. if advice.ID == 0 || advice.PatientId != patient {
  2205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
  2206. return
  2207. }
  2208. subAdvice = service.FindSubAdivceById(patient, adviceId)
  2209. }
  2210. c.ServeSuccessJSON(map[string]interface{}{
  2211. "msg": "ok",
  2212. "advice": advice,
  2213. "subAdvice": subAdvice,
  2214. })
  2215. }
  2216. func (this *DialysisApiController) DelMonitor() {
  2217. recordID, _ := this.GetInt64("record_id")
  2218. patientID, _ := this.GetInt64("patient_id")
  2219. if recordID <= 0 || patientID <= 0 {
  2220. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2221. return
  2222. }
  2223. adminInfo := this.GetAdminUserInfo()
  2224. patient, getPatientErr := service.MobileGetPatientById(adminInfo.CurrentOrgId, patientID)
  2225. if getPatientErr != nil {
  2226. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  2227. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2228. return
  2229. } else if patient == nil {
  2230. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2231. return
  2232. }
  2233. monitor, getMonitorErr := service.GetMonitor(adminInfo.CurrentOrgId, patientID, recordID)
  2234. if getMonitorErr != nil {
  2235. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2236. return
  2237. }
  2238. //if monitor != nil {
  2239. // if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
  2240. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.CurrentOrgId, adminInfo.CurrentAppId, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  2241. // if getPermissionErr != nil {
  2242. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2243. // return
  2244. // } else if headNursePermission == nil {
  2245. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  2246. // return
  2247. // }
  2248. // }
  2249. //}
  2250. err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
  2251. key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
  2252. redis := service.RedisClient()
  2253. //清空key 值
  2254. redis.Set(key, "", time.Second)
  2255. keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_record_list_all"
  2256. redis.Set(keyOne, "", time.Second)
  2257. defer redis.Close()
  2258. if err != nil {
  2259. this.ErrorLog("删除透析监测记录失败:%v", err)
  2260. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
  2261. return
  2262. }
  2263. this.ServeSuccessJSON(map[string]interface{}{
  2264. "record_id": monitor.ID,
  2265. })
  2266. }
  2267. func (c *DialysisApiController) CreateMonitor() {
  2268. patient, _ := c.GetInt64("id", 0)
  2269. dialysis_order_id, _ := c.GetInt64("dialysis_order_id", 0)
  2270. monitoring_date, _ := c.GetInt64("monitoring_date", 0)
  2271. operate_time, _ := c.GetInt64("operate_time", 0)
  2272. // monitoring_time := c.GetString("monitoring_time")
  2273. pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
  2274. breathing_rated := c.GetString("breathing_rated")
  2275. systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
  2276. diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
  2277. blood_pressure_type, _ := c.GetInt64("blood_pressure_type", 0)
  2278. blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
  2279. venous_pressure, _ := c.GetFloat("venous_pressure", 0)
  2280. venous_pressure_type, _ := c.GetInt64("venous_pressure_type", 1)
  2281. transmembrane_pressure, _ := c.GetFloat("transmembrane_pressure", 0)
  2282. transmembrane_pressure_type, _ := c.GetInt64("transmembrane_pressure_type", 1)
  2283. ultrafiltration_rate, _ := c.GetFloat("ultrafiltration_rate", 0)
  2284. ultrafiltration_volume, _ := c.GetFloat("ultrafiltration_volume", 0)
  2285. sodium_concentration, _ := c.GetFloat("sodium_concentration", 0)
  2286. arterial_pressure, _ := c.GetFloat("arterial_pressure", 0)
  2287. arterial_pressure_type, _ := c.GetInt64("arterial_pressure_type", 1)
  2288. dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
  2289. temperature, _ := c.GetFloat("temperature", 0)
  2290. replacement_rate, _ := c.GetFloat("replacement_rate", 0)
  2291. displacement_quantity, _ := c.GetFloat("displacement_quantity", 0)
  2292. conductivity, _ := c.GetFloat("conductivity", 0)
  2293. displacement_flow_quantity, _ := c.GetFloat("displacement_flow_quantity", 0)
  2294. heparin, _ := c.GetFloat("heparin", 0)
  2295. dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
  2296. ktv, _ := c.GetFloat("ktv", 0)
  2297. symptom := c.GetString("symptom")
  2298. dispose := c.GetString("dispose")
  2299. result := c.GetString("results")
  2300. monitoring_nurse, _ := c.GetInt64("monitoring_nurse", 0)
  2301. monitor_anticoagulant, _ := c.GetInt64("monitor_anticoagulant")
  2302. monitor_anticoagulant_value := c.GetString("monitor_anticoagulant_value")
  2303. monitoring_date = monitoring_date / 1000
  2304. // operate_time = operate_time / 1000
  2305. if patient <= 0 {
  2306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2307. return
  2308. }
  2309. adminUserInfo := c.GetAdminUserInfo()
  2310. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  2311. if patientInfo.ID == 0 {
  2312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2313. return
  2314. }
  2315. monitorRecord := models.MonitoringRecord{
  2316. PatientId: patient,
  2317. MonitoringDate: monitoring_date,
  2318. DialysisOrderId: dialysis_order_id,
  2319. OperateTime: operate_time,
  2320. // MonitoringTime: monitoring_time,
  2321. PulseFrequency: pulse_frequency,
  2322. BreathingRate: breathing_rated,
  2323. SystolicBloodPressure: systolic_blood_pressure,
  2324. DiastolicBloodPressure: diastolic_blood_pressure,
  2325. BloodPressureType: blood_pressure_type,
  2326. BloodFlowVolume: blood_flow_volume,
  2327. VenousPressure: venous_pressure,
  2328. VenousPressureType: venous_pressure_type,
  2329. TransmembranePressure: transmembrane_pressure,
  2330. TransmembranePressureType: transmembrane_pressure_type,
  2331. UltrafiltrationRate: ultrafiltration_rate,
  2332. UltrafiltrationVolume: ultrafiltration_volume,
  2333. SodiumConcentration: sodium_concentration,
  2334. ArterialPressure: arterial_pressure,
  2335. ArterialPressureType: arterial_pressure_type,
  2336. DialysateTemperature: dialysate_temperature,
  2337. Temperature: temperature,
  2338. ReplacementRate: replacement_rate,
  2339. DisplacementQuantity: displacement_quantity,
  2340. Ktv: ktv,
  2341. Symptom: symptom,
  2342. Dispose: dispose,
  2343. Result: result,
  2344. MonitoringNurse: monitoring_nurse,
  2345. Status: 1,
  2346. CreatedTime: time.Now().Unix(),
  2347. UpdatedTime: time.Now().Unix(),
  2348. UserOrgId: adminUserInfo.CurrentOrgId,
  2349. Conductivity: conductivity,
  2350. DisplacementFlowQuantity: displacement_flow_quantity,
  2351. Heparin: heparin,
  2352. DialysateFlow: dialysate_flow,
  2353. MonitorAnticoagulant: monitor_anticoagulant,
  2354. MonitorAnticoagulantValue: monitor_anticoagulant_value,
  2355. }
  2356. err := service.CreateMonitor(&monitorRecord)
  2357. redis := service.RedisClient()
  2358. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(monitoring_date, 10) + ":monitor_record_list_all"
  2359. redis.Set(key, "", time.Second)
  2360. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(monitoring_date, 10) + ":monitor_records"
  2361. redis.Set(keyOne, "", time.Second)
  2362. redis.Close()
  2363. if err != nil {
  2364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
  2365. return
  2366. }
  2367. c.ServeSuccessJSON(map[string]interface{}{
  2368. "msg": "ok",
  2369. "monitor": monitorRecord,
  2370. })
  2371. return
  2372. }
  2373. // 已弃用
  2374. // func (c *DialysisApiController) CreateRecordData() {
  2375. // patient, _ := c.GetInt64("id", 0)
  2376. // status, _ := c.GetInt64("status", 0)
  2377. // now := time.Now()
  2378. // year, month, day := now.Date()
  2379. // today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
  2380. // todayTimeStamp := today_time.Unix()
  2381. // if patient <= 0 {
  2382. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2383. // return
  2384. // }
  2385. // adminUserInfo := c.GetAdminUserInfo()
  2386. // patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  2387. // if patientInfo.ID == 0 {
  2388. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  2389. // return
  2390. // }
  2391. // record := &models.DialysisOrder{
  2392. // DialysisDate: todayTimeStamp,
  2393. // UserOrgId: adminUserInfo.CurrentOrgId,
  2394. // PatientId: patient,
  2395. // Stage: status,
  2396. // Status: 1,
  2397. // CreatedTime: time.Now().Unix(),
  2398. // UpdatedTime: time.Now().Unix(),
  2399. // }
  2400. // if status == 1 {
  2401. // //创建透析记录
  2402. // err := service.CreateDialysisRecord(patient, adminUserInfo.CurrentOrgId, record)
  2403. // if err == nil {
  2404. // c.ServeSuccessJSON(map[string]interface{}{
  2405. // "dialysisOrder": record,
  2406. // })
  2407. // } else {
  2408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2409. // }
  2410. // } else {
  2411. // record_id, _ := c.GetInt64("record_id", 0)
  2412. // //修改透析记录状态
  2413. // errs := service.ModifyDialysisRecord(record_id)
  2414. // //结束时候透析次数加1
  2415. // service.UpdateSolutionByPatientId(patient)
  2416. // if errs == nil {
  2417. // c.ServeSuccessJSON(map[string]interface{}{
  2418. // "dialysisOrder": record,
  2419. // })
  2420. // } else {
  2421. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2422. // }
  2423. // }
  2424. // }
  2425. func adviceFormDatas(advice *models.DoctorAdvice, data []byte, action string) (code int, subAdvice []*models.DoctorAdvice) {
  2426. dataBody := make(map[string]interface{}, 0)
  2427. err := json.Unmarshal(data, &dataBody)
  2428. if err != nil {
  2429. utils.ErrorLog(err.Error())
  2430. code = enums.ErrorCodeParamWrong
  2431. return
  2432. }
  2433. timeLayout := "2006-01-02 "
  2434. timeLayout2 := "2006-01-02 15:04"
  2435. loc, _ := time.LoadLocation("Local")
  2436. if action == "create" {
  2437. if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
  2438. utils.ErrorLog("advice_type")
  2439. code = enums.ErrorCodeParamWrong
  2440. return
  2441. }
  2442. adviceType := int64(dataBody["advice_type"].(float64))
  2443. if adviceType != 1 && adviceType != 2 {
  2444. utils.ErrorLog("advice_type != 1&&2")
  2445. code = enums.ErrorCodeParamWrong
  2446. return
  2447. }
  2448. advice.AdviceType = adviceType
  2449. if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
  2450. utils.ErrorLog("advice_date")
  2451. code = enums.ErrorCodeParamWrong
  2452. return
  2453. }
  2454. adviceDate, _ := dataBody["advice_date"].(string)
  2455. if len(adviceDate) == 0 {
  2456. utils.ErrorLog("len(adviceDate) == 0")
  2457. code = enums.ErrorCodeParamWrong
  2458. return
  2459. }
  2460. theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
  2461. if err != nil {
  2462. utils.ErrorLog(err.Error())
  2463. code = enums.ErrorCodeParamWrong
  2464. return
  2465. }
  2466. advice.AdviceDate = theTime.Unix()
  2467. }
  2468. if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
  2469. utils.ErrorLog("start_time")
  2470. code = enums.ErrorCodeParamWrong
  2471. return
  2472. }
  2473. startDate, _ := dataBody["start_time"].(string)
  2474. if len(startDate) == 0 {
  2475. utils.ErrorLog("len(startDate) == 0")
  2476. code = enums.ErrorCodeParamWrong
  2477. return
  2478. }
  2479. theTime, err := time.ParseInLocation(timeLayout2, startDate, loc)
  2480. if err != nil {
  2481. utils.ErrorLog(err.Error())
  2482. code = enums.ErrorCodeParamWrong
  2483. return
  2484. }
  2485. advice.StartTime = theTime.Unix()
  2486. if dataBody["advice_name"] == nil || reflect.TypeOf(dataBody["advice_name"]).String() != "string" {
  2487. utils.ErrorLog("advice_name")
  2488. code = enums.ErrorCodeParamWrong
  2489. return
  2490. }
  2491. adviceName, _ := dataBody["advice_name"].(string)
  2492. if len(adviceName) == 0 {
  2493. utils.ErrorLog("len(advice_name) == 0")
  2494. code = enums.ErrorCodeParamWrong
  2495. return
  2496. }
  2497. advice.AdviceName = adviceName
  2498. if dataBody["delivery_way"] == nil || reflect.TypeOf(dataBody["delivery_way"]).String() != "string" {
  2499. utils.ErrorLog("delivery_way")
  2500. code = enums.ErrorCodeParamWrong
  2501. return
  2502. }
  2503. deliveryWay, _ := dataBody["delivery_way"].(string)
  2504. if len(deliveryWay) == 0 {
  2505. utils.ErrorLog("len(deliveryWay) == 0")
  2506. code = enums.ErrorCodeParamWrong
  2507. return
  2508. }
  2509. advice.DeliveryWay = deliveryWay
  2510. if dataBody["execution_frequency"] == nil || reflect.TypeOf(dataBody["execution_frequency"]).String() != "string" {
  2511. utils.ErrorLog("execution_frequency")
  2512. code = enums.ErrorCodeParamWrong
  2513. return
  2514. }
  2515. execution_frequency, _ := dataBody["execution_frequency"].(string)
  2516. if len(execution_frequency) == 0 {
  2517. utils.ErrorLog("len(execution_frequency) == 0")
  2518. code = enums.ErrorCodeParamWrong
  2519. return
  2520. }
  2521. advice.ExecutionFrequency = execution_frequency
  2522. if dataBody["advice_desc"] != nil && reflect.TypeOf(dataBody["advice_desc"]).String() == "string" {
  2523. adviceDsc, _ := dataBody["advice_desc"].(string)
  2524. advice.AdviceDesc = adviceDsc
  2525. }
  2526. if dataBody["drug_spec_unit"] != nil && reflect.TypeOf(dataBody["drug_spec_unit"]).String() == "string" {
  2527. drugSpecUnit, _ := dataBody["drug_spec_unit"].(string)
  2528. advice.DrugSpecUnit = drugSpecUnit
  2529. }
  2530. if dataBody["single_dose"] != nil && reflect.TypeOf(dataBody["single_dose"]).String() == "string" {
  2531. singleDose, _ := strconv.ParseFloat(dataBody["single_dose"].(string), 64)
  2532. advice.SingleDose = singleDose
  2533. }
  2534. if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "string" {
  2535. singleDoseUnit, _ := dataBody["single_dose_unit"].(string)
  2536. advice.SingleDoseUnit = singleDoseUnit
  2537. }
  2538. if dataBody["prescribing_number"] != nil && reflect.TypeOf(dataBody["prescribing_number"]).String() == "string" {
  2539. prescribingNumber, _ := strconv.ParseFloat(dataBody["prescribing_number"].(string), 64)
  2540. advice.PrescribingNumber = prescribingNumber
  2541. }
  2542. if dataBody["prescribing_number_unit"] != nil && reflect.TypeOf(dataBody["prescribing_number_unit"]).String() == "string" {
  2543. prescribingNumberUnit, _ := dataBody["prescribing_number_unit"].(string)
  2544. advice.PrescribingNumberUnit = prescribingNumberUnit
  2545. }
  2546. if dataBody["subAdviceForm"] != nil && reflect.TypeOf(dataBody["subAdviceForm"]).String() == "[]interface {}" {
  2547. thisContagions, _ := dataBody["subAdviceForm"].([]interface{})
  2548. if len(thisContagions) > 0 {
  2549. for _, item := range thisContagions {
  2550. items := item.(map[string]interface{})
  2551. advice_name, _ := items["advice_name"].(string)
  2552. advice_desc, _ := items["advice_desc"].(string)
  2553. drug_spec_unit, _ := items["drug_spec_unit"].(string)
  2554. prescribing_number_unit, _ := items["prescribing_number_unit"].(string)
  2555. single_dose_unit, _ := items["single_dose_unit"].(string)
  2556. prescribing_number, _ := strconv.ParseFloat(items["prescribing_number"].(string), 64)
  2557. single_dose, _ := strconv.ParseFloat(items["single_dose"].(string), 64)
  2558. advice := &models.DoctorAdvice{
  2559. AdviceName: advice_name,
  2560. AdviceDesc: advice_desc,
  2561. SingleDose: single_dose,
  2562. SingleDoseUnit: single_dose_unit,
  2563. DrugSpecUnit: drug_spec_unit,
  2564. PrescribingNumber: prescribing_number,
  2565. PrescribingNumberUnit: prescribing_number_unit,
  2566. }
  2567. subAdvice = append(subAdvice, advice)
  2568. }
  2569. }
  2570. }
  2571. return
  2572. }
  2573. func (c *DialysisApiController) GetDialysisOrder() {
  2574. xtno := c.GetString("xtno")
  2575. xtdate := c.GetString("xtdate")
  2576. timeLayout := "2006-01-02"
  2577. loc, _ := time.LoadLocation("Local")
  2578. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", xtdate+" 00:00:00", loc)
  2579. if err != nil {
  2580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2581. return
  2582. }
  2583. xttime := theTime.Unix()
  2584. operatorIDs := make([]int64, 0)
  2585. adminUserInfo := c.GetAdminUserInfo()
  2586. adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  2587. patientInfo, _ := service.FindPatientWithDeviceByNo(adminUserInfo.CurrentOrgId, xtno, xttime)
  2588. //透析单
  2589. dialysisOrder, _ := service.MobileGetSchedualDialysisRecordTen(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2590. if dialysisOrder != nil {
  2591. if dialysisOrder.FinishNurse > 0 {
  2592. operatorIDs = append(operatorIDs, dialysisOrder.FinishNurse)
  2593. }
  2594. if dialysisOrder.StartNurse > 0 {
  2595. operatorIDs = append(operatorIDs, dialysisOrder.StartNurse)
  2596. }
  2597. }
  2598. //透前评估
  2599. PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2600. predialysName, err := service.FindPredialysisName(PredialysisEvaluation.BloodAccessPartOperaId, adminUserInfo.CurrentOrgId)
  2601. //透后评估
  2602. AssessmentAfterDislysis, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2603. if AssessmentAfterDislysis.Modifier > 0 {
  2604. operatorIDs = append(operatorIDs, AssessmentAfterDislysis.Modifier)
  2605. }
  2606. //上次透前评估
  2607. lastPredialysisEvaluation, _ := service.GetLastTimePredialysisEvaluation(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2608. lastOrder, _ := service.GetLastTimeOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2609. //透析处方
  2610. dialysisPrescription, _ := service.FindPatientPrescribeWidyDevideById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2611. if dialysisPrescription.PrescriptionDoctor > 0 {
  2612. operatorIDs = append(operatorIDs, dialysisPrescription.PrescriptionDoctor)
  2613. }
  2614. //获取病人的透析模式
  2615. schedule, err := service.FindDialysisMode(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2616. order, err := service.FindDialysisMacher(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2617. nurse, err := service.FindPunctureNurse(order.PunctureNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
  2618. startNuse, err := service.FindeStartNuse(order.StartNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
  2619. FinishNuse, err := service.FindeStartNuse(order.FinishNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
  2620. //获取透析处方
  2621. dialysisway, err := service.FindDialysisWay(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2622. //获取临时医嘱
  2623. doctorAdvice, _ := service.FindDoctorOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2624. //config, err := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
  2625. //获取医嘱内容
  2626. doctor, err := service.FindDoctor(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
  2627. DoctorName, err := service.FindDoctorName(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
  2628. DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2629. doctorAdevieInfo, err := service.FindDoctorAdviceByInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2630. //获取上次的透后体重
  2631. // assessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2632. assessmentAfterDislysis, _ := service.MobileGetLast(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2633. //获取透析次数
  2634. _, total, err := service.GetTotalDialysisCout(adminUserInfo.CurrentOrgId, patientInfo.ID)
  2635. if len(DoctorAdvice) > 0 {
  2636. for _, item := range DoctorAdvice {
  2637. if item.AdviceDoctor > 0 {
  2638. operatorIDs = append(operatorIDs, item.AdviceDoctor)
  2639. }
  2640. if item.ExecutionStaff > 0 {
  2641. operatorIDs = append(operatorIDs, item.ExecutionStaff)
  2642. }
  2643. if item.Checker > 0 {
  2644. operatorIDs = append(operatorIDs, item.Checker)
  2645. }
  2646. }
  2647. }
  2648. //透析监测
  2649. Record, _ := service.FindAllMonitorRecord(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2650. //透析检测
  2651. //monitor, err := service.FindAllMonitor(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2652. //透析小结
  2653. TreatmentSummary, _ := service.FindTreatmentSummaryById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2654. //接诊评估
  2655. receiverTreatmentAccess, _ := service.FindReceiverTreatmentAccessRecordById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2656. check, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2657. if adminUserInfo.CurrentOrgId != 10101 && adminUserInfo.CurrentOrgId != 10445 && adminUserInfo.CurrentOrgId != 10345 {
  2658. dialysis_count, _ := service.GetDialysisOrderCount(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2659. patientInfo.TotalDialysis = dialysis_count
  2660. }
  2661. if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 10345 {
  2662. if xttime <= 1672416000 {
  2663. dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2664. patientInfo.TotalDialysis = dialysis_count
  2665. }
  2666. if xttime >= 1672502400 {
  2667. dialysis_count, _ := service.GetDialysisOrderCountTwo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2668. patientInfo.TotalDialysis = dialysis_count
  2669. }
  2670. }
  2671. //相关操作对应的操作人
  2672. //operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
  2673. operators, err := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
  2674. templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  2675. //获取当前日期月份的第一天
  2676. firstmonth := service.GetFirstDateOfMonth(theTime)
  2677. firstMonthDate := firstmonth.Unix()
  2678. //获取当前月份的病人透析次数
  2679. dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.CurrentOrgId)
  2680. //获取his数据
  2681. hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2682. //hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
  2683. config, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
  2684. project_config, _ := service.GetHisProjectConfig(adminUserInfo.CurrentOrgId)
  2685. projects, _ := service.FindAllHisProjectById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
  2686. //if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
  2687. // for _, item := range projects {
  2688. // var advice *models.HisDoctorAdviceInfo
  2689. // advice.ID = item.ID
  2690. // advice.Checker = item.Checker
  2691. // advice.CheckTime = item.CheckTime
  2692. // advice.CheckState = item.CheckState
  2693. // advice.ExecutionState = item.ExecutionState
  2694. // advice.ExecutionStaff = item.ExecutionStaff
  2695. // advice.PrescribingNumber = float64(item.Count)
  2696. // advice.PrescribingNumberUnit = item.Unit
  2697. // advice.AdviceDoctor = item.Doctor
  2698. // if item.Type == 3 {
  2699. // advice.AdviceName = item.GoodInfo.GoodName
  2700. // } else if item.Type == 2 {
  2701. // advice.AdviceName = item.HisProject.ProjectName
  2702. // }
  2703. // advice.StartTime = item.StartTime
  2704. // hisAdvice = append(hisAdvice, advice)
  2705. // }
  2706. //}
  2707. if config.IsOpen == 1 {
  2708. c.ServeSuccessJSON(map[string]interface{}{
  2709. "xtdate": xtdate,
  2710. "users": adminUser,
  2711. "patientInfo": patientInfo,
  2712. "PredialysisEvaluation": PredialysisEvaluation,
  2713. "AssessmentAfterDislysis": AssessmentAfterDislysis,
  2714. "dialysisPrescription": dialysisPrescription,
  2715. "advices": hisAdvice,
  2716. "monitors": Record,
  2717. "summary": TreatmentSummary,
  2718. "receiverTreatmentAccess": receiverTreatmentAccess,
  2719. "dialysisOrder": dialysisOrder,
  2720. "operators": operators,
  2721. "org_template_info": templateInfo,
  2722. "check": check,
  2723. "schedule": schedule,
  2724. "dialysisway": dialysisway,
  2725. "order": order,
  2726. "doctorAdvice": doctorAdvice,
  2727. "doctor": doctor,
  2728. "nurse": nurse,
  2729. "doctorAdevieInfo": doctorAdevieInfo,
  2730. "total": total,
  2731. "startNuse": startNuse,
  2732. "DoctorName": DoctorName,
  2733. "assessmentAfterDislysis": assessmentAfterDislysis,
  2734. "predialysName": predialysName,
  2735. "FinishNuse": FinishNuse,
  2736. "lastPredialysisEvaluation": lastPredialysisEvaluation,
  2737. "dialysiscount": dialysiscount,
  2738. "last_order": lastOrder,
  2739. "project_config": project_config,
  2740. "projects": projects,
  2741. })
  2742. }
  2743. if config.IsOpen == 0 || config.IsOpen == 2 {
  2744. c.ServeSuccessJSON(map[string]interface{}{
  2745. "xtdate": xtdate,
  2746. "users": adminUser,
  2747. "patientInfo": patientInfo,
  2748. "PredialysisEvaluation": PredialysisEvaluation,
  2749. "AssessmentAfterDislysis": AssessmentAfterDislysis,
  2750. "dialysisPrescription": dialysisPrescription,
  2751. "advices": DoctorAdvice,
  2752. "monitors": Record,
  2753. "summary": TreatmentSummary,
  2754. "receiverTreatmentAccess": receiverTreatmentAccess,
  2755. "dialysisOrder": dialysisOrder,
  2756. "operators": operators,
  2757. "org_template_info": templateInfo,
  2758. "check": check,
  2759. "schedule": schedule,
  2760. "dialysisway": dialysisway,
  2761. "order": order,
  2762. "doctorAdvice": doctorAdvice,
  2763. "doctor": doctor,
  2764. "nurse": nurse,
  2765. "doctorAdevieInfo": doctorAdevieInfo,
  2766. "total": total,
  2767. "startNuse": startNuse,
  2768. "DoctorName": DoctorName,
  2769. "assessmentAfterDislysis": assessmentAfterDislysis,
  2770. "predialysName": predialysName,
  2771. "FinishNuse": FinishNuse,
  2772. "lastPredialysisEvaluation": lastPredialysisEvaluation,
  2773. "dialysiscount": dialysiscount,
  2774. "last_order": lastOrder,
  2775. "project_config": project_config,
  2776. "projects": projects,
  2777. })
  2778. }
  2779. }
  2780. func (c *DialysisApiController) GetLongAdvice() {
  2781. patient_id, _ := c.GetInt64("patient_id")
  2782. adminUserInfo := c.GetAdminUserInfo()
  2783. _, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
  2784. //patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
  2785. if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有 不开启推送功能,不做任何处理
  2786. c.ServeSuccessJSON(map[string]interface{}{
  2787. "status": "1",
  2788. })
  2789. return
  2790. } else { //开启推送提醒
  2791. //开启推送提醒逻辑 提交长期处方的时候,弹起长期医嘱推送
  2792. var advice_three []*models.DoctorAdvice
  2793. //groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
  2794. recordDateStr := time.Now().Format("2006-01-02")
  2795. recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  2796. nowtime := recordDate.Unix()
  2797. advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, nowtime)
  2798. advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, nowtime)
  2799. for _, advice := range advices {
  2800. if advice.FrequencyType == 3 {
  2801. t := time.Now()
  2802. week := int(t.Weekday())
  2803. switch week {
  2804. case 1:
  2805. if strings.Index(advice.WeekDay, "周一") == -1 {
  2806. advice_three = append(advice_three, advice)
  2807. }
  2808. break
  2809. case 2:
  2810. if strings.Index(advice.WeekDay, "周二") == -1 {
  2811. advice_three = append(advice_three, advice)
  2812. }
  2813. break
  2814. case 3:
  2815. if strings.Index(advice.WeekDay, "周三") == -1 {
  2816. advice_three = append(advice_three, advice)
  2817. }
  2818. break
  2819. case 4:
  2820. if strings.Index(advice.WeekDay, "周四") == -1 {
  2821. advice_three = append(advice_three, advice)
  2822. }
  2823. break
  2824. case 5:
  2825. if strings.Index(advice.WeekDay, "周五") == -1 {
  2826. advice_three = append(advice_three, advice)
  2827. }
  2828. break
  2829. case 6:
  2830. if strings.Index(advice.WeekDay, "周六") == -1 {
  2831. advice_three = append(advice_three, advice)
  2832. }
  2833. break
  2834. case 0:
  2835. if strings.Index(advice.WeekDay, "周日") == -1 {
  2836. advice_three = append(advice_three, advice)
  2837. }
  2838. break
  2839. }
  2840. }
  2841. }
  2842. for _, advice := range advices_two {
  2843. p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
  2844. now := p.Unix()
  2845. dayStr := strconv.FormatInt(advice.DayCount, 10)
  2846. dayStr2 := "-" + dayStr
  2847. count, _ := strconv.ParseInt(dayStr2, 10, 64)
  2848. oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
  2849. advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
  2850. for _, ad := range advices {
  2851. advice_three = append(advice_three, ad)
  2852. }
  2853. }
  2854. if err == nil {
  2855. c.ServeSuccessJSON(map[string]interface{}{
  2856. "status": "2",
  2857. "advices": advices,
  2858. "advices_two": RemoveRepeatedElement(advice_three),
  2859. "is_open_remind": config.IsOpenRemind,
  2860. })
  2861. }
  2862. }
  2863. }
  2864. func (c *DialysisApiController) GetLongAdviceOne() {
  2865. patient_id, _ := c.GetInt64("patient_id")
  2866. schedule_date := c.GetString("schedule_date")
  2867. adminUserInfo := c.GetAdminUserInfo()
  2868. _, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
  2869. timeLayout := "2006-01-02"
  2870. loc, _ := time.LoadLocation("Local")
  2871. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
  2872. //patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
  2873. if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有 不开启推送功能,不做任何处理
  2874. c.ServeSuccessJSON(map[string]interface{}{
  2875. "status": "1",
  2876. })
  2877. return
  2878. } else { //开启推送提醒
  2879. //开启推送提醒逻辑 提交长期处方的时候,弹起长期医嘱推送
  2880. var advice_three []*models.DoctorAdvice
  2881. //groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
  2882. //recordDateStr := time.Now().Format("2006-01-02")
  2883. //recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  2884. //
  2885. //nowtime := recordDate.Unix()
  2886. advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, theTime.Unix())
  2887. advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, theTime.Unix())
  2888. for _, advice := range advices {
  2889. if advice.FrequencyType == 3 {
  2890. t := time.Now()
  2891. week := int(t.Weekday())
  2892. switch week {
  2893. case 1:
  2894. if strings.Index(advice.WeekDay, "周一") == -1 {
  2895. advice_three = append(advice_three, advice)
  2896. }
  2897. break
  2898. case 2:
  2899. if strings.Index(advice.WeekDay, "周二") == -1 {
  2900. advice_three = append(advice_three, advice)
  2901. }
  2902. break
  2903. case 3:
  2904. if strings.Index(advice.WeekDay, "周三") == -1 {
  2905. advice_three = append(advice_three, advice)
  2906. }
  2907. break
  2908. case 4:
  2909. if strings.Index(advice.WeekDay, "周四") == -1 {
  2910. advice_three = append(advice_three, advice)
  2911. }
  2912. break
  2913. case 5:
  2914. if strings.Index(advice.WeekDay, "周五") == -1 {
  2915. advice_three = append(advice_three, advice)
  2916. }
  2917. break
  2918. case 6:
  2919. if strings.Index(advice.WeekDay, "周六") == -1 {
  2920. advice_three = append(advice_three, advice)
  2921. }
  2922. break
  2923. case 0:
  2924. if strings.Index(advice.WeekDay, "周日") == -1 {
  2925. advice_three = append(advice_three, advice)
  2926. }
  2927. break
  2928. }
  2929. }
  2930. }
  2931. for _, advice := range advices_two {
  2932. p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
  2933. now := p.Unix()
  2934. dayStr := strconv.FormatInt(advice.DayCount, 10)
  2935. dayStr2 := "-" + dayStr
  2936. count, _ := strconv.ParseInt(dayStr2, 10, 64)
  2937. oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
  2938. advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
  2939. for _, ad := range advices {
  2940. advice_three = append(advice_three, ad)
  2941. }
  2942. }
  2943. if err == nil {
  2944. c.ServeSuccessJSON(map[string]interface{}{
  2945. "status": "2",
  2946. "advices": advices,
  2947. "advices_two": RemoveRepeatedElement(advice_three),
  2948. "is_open_remind": config.IsOpenRemind,
  2949. })
  2950. }
  2951. }
  2952. }
  2953. func (c *DialysisApiController) GetLongAdviceTwo() {
  2954. patient_id, _ := c.GetInt64("patient_id")
  2955. schedule_date, _ := c.GetInt64("schedule_date")
  2956. adminUserInfo := c.GetAdminUserInfo()
  2957. _, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
  2958. //patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
  2959. if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有 不开启推送功能,不做任何处理
  2960. c.ServeSuccessJSON(map[string]interface{}{
  2961. "status": "1",
  2962. })
  2963. return
  2964. } else { //开启推送提醒
  2965. //开启推送提醒逻辑 提交长期处方的时候,弹起长期医嘱推送
  2966. var advice_three []*models.DoctorAdvice
  2967. //groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
  2968. advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, schedule_date)
  2969. advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, schedule_date)
  2970. for _, advice := range advices {
  2971. if advice.FrequencyType == 3 {
  2972. t := time.Now()
  2973. week := int(t.Weekday())
  2974. switch week {
  2975. case 1:
  2976. if strings.Index(advice.WeekDay, "周一") == -1 {
  2977. advice_three = append(advice_three, advice)
  2978. }
  2979. break
  2980. case 2:
  2981. if strings.Index(advice.WeekDay, "周二") == -1 {
  2982. advice_three = append(advice_three, advice)
  2983. }
  2984. break
  2985. case 3:
  2986. if strings.Index(advice.WeekDay, "周三") == -1 {
  2987. advice_three = append(advice_three, advice)
  2988. }
  2989. break
  2990. case 4:
  2991. if strings.Index(advice.WeekDay, "周四") == -1 {
  2992. advice_three = append(advice_three, advice)
  2993. }
  2994. break
  2995. case 5:
  2996. if strings.Index(advice.WeekDay, "周五") == -1 {
  2997. advice_three = append(advice_three, advice)
  2998. }
  2999. break
  3000. case 6:
  3001. if strings.Index(advice.WeekDay, "周六") == -1 {
  3002. advice_three = append(advice_three, advice)
  3003. }
  3004. break
  3005. case 0:
  3006. if strings.Index(advice.WeekDay, "周日") == -1 {
  3007. advice_three = append(advice_three, advice)
  3008. }
  3009. break
  3010. }
  3011. }
  3012. }
  3013. for _, advice := range advices_two {
  3014. p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
  3015. now := p.Unix()
  3016. dayStr := strconv.FormatInt(advice.DayCount, 10)
  3017. dayStr2 := "-" + dayStr
  3018. count, _ := strconv.ParseInt(dayStr2, 10, 64)
  3019. oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
  3020. advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
  3021. for _, ad := range advices {
  3022. advice_three = append(advice_three, ad)
  3023. }
  3024. }
  3025. if err == nil {
  3026. c.ServeSuccessJSON(map[string]interface{}{
  3027. "status": "2",
  3028. "advices": advices,
  3029. "advices_two": RemoveRepeatedElement(advice_three),
  3030. "is_open_remind": config.IsOpenRemind,
  3031. })
  3032. }
  3033. }
  3034. }
  3035. func RemoveRepeatedElement(arr []*models.DoctorAdvice) (newArr []*models.DoctorAdvice) {
  3036. newArr = make([]*models.DoctorAdvice, 0)
  3037. for i := 0; i < len(arr); i++ {
  3038. repeat := false
  3039. for j := i + 1; j < len(arr); j++ {
  3040. if arr[i].ID == arr[j].ID {
  3041. repeat = true
  3042. break
  3043. }
  3044. }
  3045. if !repeat {
  3046. newArr = append(newArr, arr[i])
  3047. }
  3048. }
  3049. return
  3050. }
  3051. func (c *DialysisApiController) CreateRemindDoctorAdvice() {
  3052. patient, _ := c.GetInt64("id", 0)
  3053. groupNo, _ := c.GetInt64("groupno", 0)
  3054. if patient <= 0 {
  3055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3056. return
  3057. }
  3058. adminUserInfo := c.GetAdminUserInfo()
  3059. dataBody := make(map[string]interface{}, 0)
  3060. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  3061. if err != nil {
  3062. utils.ErrorLog(err.Error())
  3063. return
  3064. }
  3065. utils.ErrorLog("%v", dataBody)
  3066. timeLayout := "2006-01-02 15:04"
  3067. loc, _ := time.LoadLocation("Local")
  3068. timeLayout2 := "2006-01-02"
  3069. loc2, _ := time.LoadLocation("Local")
  3070. if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
  3071. utils.ErrorLog("advice_type")
  3072. return
  3073. }
  3074. adviceType := int64(2)
  3075. if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
  3076. utils.ErrorLog("advice_date")
  3077. return
  3078. }
  3079. adviceDate, _ := dataBody["advice_date"].(string)
  3080. theTime, err := time.ParseInLocation(timeLayout2, adviceDate, loc2)
  3081. AdviceDate := theTime.Unix()
  3082. RecordDate := theTime.Unix()
  3083. if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
  3084. utils.ErrorLog("start_time")
  3085. return
  3086. }
  3087. startTime, _ := dataBody["start_time"].(string)
  3088. if len(startTime) == 0 {
  3089. utils.ErrorLog("len(start_time) == 0")
  3090. return
  3091. }
  3092. theTimeUnix, err := time.ParseInLocation(timeLayout, startTime, loc)
  3093. if err != nil {
  3094. utils.ErrorLog(err.Error())
  3095. return
  3096. }
  3097. StartTime := theTimeUnix.Unix()
  3098. fmt.Println("startTIME", StartTime)
  3099. Remark := ""
  3100. if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
  3101. remark, _ := dataBody["remark"].(string)
  3102. Remark = remark
  3103. }
  3104. var advices []*models.GroupAdvice
  3105. if dataBody["advices"] == nil || reflect.TypeOf(dataBody["advices"]).String() != "[]interface {}" {
  3106. utils.ErrorLog("advices")
  3107. return
  3108. }
  3109. adviceNames := dataBody["advices"].([]interface{})
  3110. for _, adviceNameMap := range adviceNames {
  3111. adviceNameM := adviceNameMap.(map[string]interface{})
  3112. var advice models.GroupAdvice
  3113. advice.Remark = Remark
  3114. advice.AdviceType = adviceType
  3115. advice.StartTime = StartTime
  3116. advice.AdviceDate = AdviceDate
  3117. advice.RecordDate = RecordDate
  3118. advice.Status = 1
  3119. advice.CreatedTime = time.Now().Unix()
  3120. advice.UpdatedTime = time.Now().Unix()
  3121. advice.StopState = 2
  3122. advice.ExecutionState = 2
  3123. advice.UserOrgId = adminUserInfo.CurrentOrgId
  3124. advice.PatientId = patient
  3125. advice.AdviceDoctor = adminUserInfo.AdminUser.Id
  3126. advice.IsSettle = 2
  3127. if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
  3128. utils.ErrorLog("advice_name")
  3129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3130. return
  3131. }
  3132. adviceName, _ := adviceNameM["advice_name"].(string)
  3133. if len(adviceName) == 0 {
  3134. utils.ErrorLog("len(advice_name) == 0")
  3135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3136. return
  3137. }
  3138. advice.AdviceName = adviceName
  3139. if adviceNameM["drug_spec"] != nil && reflect.TypeOf(adviceNameM["drug_spec"]).String() == "string" {
  3140. drugSpec, _ := strconv.ParseFloat(adviceNameM["drug_spec"].(string), 64)
  3141. advice.DrugSpec = drugSpec
  3142. }
  3143. if adviceNameM["advice_desc"] != nil && reflect.TypeOf(adviceNameM["advice_desc"]).String() == "string" {
  3144. adviceDesc, _ := adviceNameM["advice_desc"].(string)
  3145. advice.AdviceDesc = adviceDesc
  3146. }
  3147. if adviceNameM["drug_spec_unit"] != nil && reflect.TypeOf(adviceNameM["drug_spec_unit"]).String() == "string" {
  3148. drugSpecUnit, _ := adviceNameM["drug_spec_unit"].(string)
  3149. advice.DrugSpecUnit = drugSpecUnit
  3150. }
  3151. //if adviceNameM["single_dose"] != nil && reflect.TypeOf(adviceNameM["single_dose"]).String() == "string" {
  3152. // singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
  3153. // advice.SingleDose = singleDose
  3154. //}
  3155. if adviceNameM["single_dose"] != nil || reflect.TypeOf(adviceNameM["single_dose"]).String() == "float64" {
  3156. //single_dose := int64(adviceNameM["single_dose"].(float64))
  3157. advice.SingleDose = adviceNameM["single_dose"].(float64)
  3158. }
  3159. if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "string" {
  3160. singleDoseUnit, _ := adviceNameM["single_dose_unit"].(string)
  3161. advice.SingleDoseUnit = singleDoseUnit
  3162. }
  3163. //if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
  3164. // prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
  3165. // advice.PrescribingNumber = prescribingNumber
  3166. //}
  3167. if adviceNameM["prescribing_number"] != nil || reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "float64" {
  3168. advice.PrescribingNumber = adviceNameM["prescribing_number"].(float64)
  3169. }
  3170. if adviceNameM["prescribing_number_unit"] != nil && reflect.TypeOf(adviceNameM["prescribing_number_unit"]).String() == "string" {
  3171. prescribingNumberUnit, _ := adviceNameM["prescribing_number_unit"].(string)
  3172. advice.PrescribingNumberUnit = prescribingNumberUnit
  3173. }
  3174. if adviceNameM["delivery_way"] != nil && reflect.TypeOf(adviceNameM["delivery_way"]).String() == "string" {
  3175. deliveryWay, _ := adviceNameM["delivery_way"].(string)
  3176. advice.DeliveryWay = deliveryWay
  3177. }
  3178. if adviceNameM["execution_frequency"] != nil && reflect.TypeOf(adviceNameM["execution_frequency"]).String() == "string" {
  3179. executionFrequency, _ := adviceNameM["execution_frequency"].(string)
  3180. advice.ExecutionFrequency = executionFrequency
  3181. }
  3182. if adviceNameM["frequency_type"] != nil || reflect.TypeOf(adviceNameM["frequency_type"]).String() == "float64" {
  3183. frequency_type := int64(adviceNameM["frequency_type"].(float64))
  3184. advice.FrequencyType = frequency_type
  3185. }
  3186. if adviceNameM["day_count"] != nil || reflect.TypeOf(adviceNameM["day_count"]).String() == "float64" {
  3187. day_count := int64(adviceNameM["day_count"].(float64))
  3188. advice.DayCount = day_count
  3189. }
  3190. if adviceNameM["way"] != nil || reflect.TypeOf(adviceNameM["way"]).String() == "float64" {
  3191. way := int64(adviceNameM["way"].(float64))
  3192. advice.Way = way
  3193. }
  3194. if adviceNameM["drug_id"] != nil || reflect.TypeOf(adviceNameM["drug_id"]).String() == "float64" {
  3195. drug_id := int64(adviceNameM["drug_id"].(float64))
  3196. advice.DrugId = drug_id
  3197. }
  3198. if adviceNameM["drug_name_id"] != nil || reflect.TypeOf(adviceNameM["drug_name_id"]).String() == "float64" {
  3199. drug_name_id := int64(adviceNameM["drug_name_id"].(float64))
  3200. advice.DrugNameId = drug_name_id
  3201. }
  3202. if adviceNameM["week_day"] != nil && reflect.TypeOf(adviceNameM["week_day"]).String() == "string" {
  3203. week_day, _ := adviceNameM["week_day"].(string)
  3204. advice.WeekDay = week_day
  3205. }
  3206. if adviceNameM["template_id"] != nil && reflect.TypeOf(adviceNameM["template_id"]).String() == "string" {
  3207. template_id, _ := adviceNameM["template_id"].(string)
  3208. advice.TemplateId = template_id
  3209. }
  3210. if adviceNameM["execution_frequency"] != nil && reflect.TypeOf(adviceNameM["execution_frequency"]).String() == "string" {
  3211. executionFrequency, _ := adviceNameM["execution_frequency"].(string)
  3212. advice.ExecutionFrequency = executionFrequency
  3213. }
  3214. if adviceNameM["child"] != nil && reflect.TypeOf(adviceNameM["child"]).String() == "[]interface {}" {
  3215. children := adviceNameM["child"].([]interface{})
  3216. if len(children) > 0 {
  3217. for _, childrenMap := range children {
  3218. childMap := childrenMap.(map[string]interface{})
  3219. var child models.GroupAdvice
  3220. child.Remark = Remark
  3221. child.AdviceType = adviceType
  3222. child.StartTime = StartTime
  3223. child.AdviceDate = AdviceDate
  3224. child.RecordDate = RecordDate
  3225. child.Status = 1
  3226. child.CreatedTime = time.Now().Unix()
  3227. child.UpdatedTime = time.Now().Unix()
  3228. child.StopState = 2
  3229. child.ExecutionState = 2
  3230. child.UserOrgId = adminUserInfo.CurrentOrgId
  3231. child.PatientId = patient
  3232. child.AdviceDoctor = adminUserInfo.AdminUser.Id
  3233. child.IsSettle = 2
  3234. if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
  3235. utils.ErrorLog("child advice_name")
  3236. return
  3237. }
  3238. childAdviceName, _ := childMap["advice_name"].(string)
  3239. if len(childAdviceName) == 0 {
  3240. utils.ErrorLog("len(child advice_name) == 0")
  3241. return
  3242. }
  3243. child.AdviceName = childAdviceName
  3244. if childMap["advice_desc"] != nil && reflect.TypeOf(childMap["advice_desc"]).String() == "string" {
  3245. childAdviceDesc, _ := childMap["advice_desc"].(string)
  3246. child.AdviceDesc = childAdviceDesc
  3247. }
  3248. if childMap["drug_spec"] != nil && reflect.TypeOf(childMap["drug_spec"]).String() == "string" {
  3249. childDrugSpec, _ := strconv.ParseFloat(childMap["drug_spec"].(string), 64)
  3250. child.DrugSpec = childDrugSpec
  3251. }
  3252. if childMap["drug_spec_unit"] != nil && reflect.TypeOf(childMap["drug_spec_unit"]).String() == "string" {
  3253. childDrugSpecUnit, _ := childMap["drug_spec_unit"].(string)
  3254. child.DrugSpecUnit = childDrugSpecUnit
  3255. }
  3256. if childMap["single_dose"] != nil && reflect.TypeOf(childMap["single_dose"]).String() == "string" {
  3257. childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
  3258. child.SingleDose = childSingleDose
  3259. }
  3260. if childMap["single_dose"] != nil && reflect.TypeOf(childMap["single_dose"]).String() == "float64" {
  3261. //childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
  3262. child.SingleDose = childMap["single_dose"].(float64)
  3263. }
  3264. if childMap["remark"] != nil && reflect.TypeOf(childMap["remark"]).String() == "string" {
  3265. //childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
  3266. child.Remark = childMap["remark"].(string)
  3267. }
  3268. if childMap["drug_id"] != nil && reflect.TypeOf(childMap["drug_id"]).String() == "float64" {
  3269. //childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
  3270. child.DrugId = int64(childMap["drug_id"].(float64))
  3271. }
  3272. if childMap["single_dose_unit"] != nil && reflect.TypeOf(childMap["single_dose_unit"]).String() == "string" {
  3273. childSingleDoseUnit, _ := childMap["single_dose_unit"].(string)
  3274. child.SingleDoseUnit = childSingleDoseUnit
  3275. }
  3276. if childMap["prescribing_number"] != nil && reflect.TypeOf(childMap["prescribing_number"]).String() == "string" {
  3277. childPrescribingNumber, _ := strconv.ParseFloat(childMap["prescribing_number"].(string), 64)
  3278. child.PrescribingNumber = childPrescribingNumber
  3279. }
  3280. if childMap["prescribing_number"] != nil && reflect.TypeOf(childMap["prescribing_number"]).String() == "float64" {
  3281. //childPrescribingNumber, _ := strconv.ParseFloat(childMap["prescribing_number"].(string), 64)
  3282. child.PrescribingNumber = childMap["prescribing_number"].(float64)
  3283. }
  3284. if childMap["prescribing_number_unit"] != nil && reflect.TypeOf(childMap["prescribing_number_unit"]).String() == "string" {
  3285. childPrescribingNumberUnit, _ := childMap["prescribing_number_unit"].(string)
  3286. child.PrescribingNumberUnit = childPrescribingNumberUnit
  3287. }
  3288. child.DeliveryWay = advice.DeliveryWay
  3289. child.ExecutionFrequency = advice.ExecutionFrequency
  3290. advice.Children = append(advice.Children, &child)
  3291. }
  3292. }
  3293. }
  3294. advices = append(advices, &advice)
  3295. }
  3296. list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
  3297. redis := service.RedisClient()
  3298. formatAdviceDate := theTime.Format("2006-01-02")
  3299. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
  3300. redis.Set(key, "", time.Second)
  3301. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
  3302. redis.Set(keyOne, "", time.Second)
  3303. keyFour := "scheduals_" + formatAdviceDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
  3304. redis.Set(keyFour, "", time.Second)
  3305. defer redis.Close()
  3306. if err != nil {
  3307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
  3308. return
  3309. }
  3310. c.ServeSuccessJSON(map[string]interface{}{
  3311. "msg": "ok",
  3312. "advices": list,
  3313. })
  3314. return
  3315. }
  3316. func (c *DialysisApiController) GetSolution() {
  3317. patient_id, _ := c.GetInt64("patient_id")
  3318. mode_id, _ := c.GetInt64("mode_id")
  3319. adminUserInfo := c.GetAdminUserInfo()
  3320. solution, err := service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
  3321. prescription, err := service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
  3322. system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, mode_id)
  3323. dialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient_id, adminUserInfo.CurrentOrgId)
  3324. if err != nil {
  3325. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3326. return
  3327. }
  3328. c.ServeSuccessJSON(map[string]interface{}{
  3329. "solution": solution,
  3330. "prescription": prescription,
  3331. "system_prescription": system_prescription,
  3332. "dialysisPrescription": dialysisPrescription,
  3333. })
  3334. }
  3335. func (c *DialysisApiController) GetSchedule() {
  3336. schedual_type, _ := c.GetInt64("schedual_type")
  3337. adminUserInfo := c.GetAdminUserInfo()
  3338. //timeLayout := "2006-01-02 15:04:05"
  3339. //
  3340. //date := time.Now().Format("2006-01-02") + " 00:00:00"
  3341. //loc, _ := time.LoadLocation("Local")
  3342. //theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
  3343. //scheduleTime := theStartTime.Unix()
  3344. scheduleTime, _ := c.GetInt64("record_date")
  3345. deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.CurrentOrgId, scheduleTime, schedual_type)
  3346. c.ServeSuccessJSON(map[string]interface{}{
  3347. "number": deviceNumber,
  3348. })
  3349. }
  3350. func (this *DialysisApiController) GetTodayMonitor() {
  3351. thisTime := time.Now()
  3352. scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
  3353. timeLayout := "2006-01-02 15:04:05"
  3354. loc, _ := time.LoadLocation("Local")
  3355. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  3356. theAssessmentDateTime := theStartTime.Unix()
  3357. patientID, _ := this.GetInt64("patient_id")
  3358. monitorDate, _ := this.GetInt64("monitoring_date", theAssessmentDateTime)
  3359. adminInfo := this.GetAdminUserInfo()
  3360. record, _ := service.FindLastMonitorRecordToday(patientID, adminInfo.CurrentOrgId, monitorDate)
  3361. fristrecord, _ := service.FindFirstMonitorRecordToday(patientID, adminInfo.CurrentOrgId, monitorDate)
  3362. template, _ := service.GetOrgInfoTemplate(adminInfo.CurrentOrgId)
  3363. var ultrafiltration_rate float64
  3364. _, prescription := service.FindDialysisPrescriptionByReordDate(patientID, theAssessmentDateTime, adminInfo.CurrentOrgId)
  3365. //针对福建医师汇 获取透前评估预增脱水量
  3366. _, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, theAssessmentDateTime, adminInfo.CurrentOrgId)
  3367. fmt.Println("透前评估数据", evaluation)
  3368. if prescription.ID > 0 {
  3369. if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
  3370. totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
  3371. if template.TemplateId == 6 { //adminInfo.CurrentOrgId == 9538
  3372. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
  3373. record.UltrafiltrationRate = ultrafiltration_rate
  3374. }
  3375. if template.TemplateId == 6 && adminInfo.CurrentOrgId == 10121 {
  3376. dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
  3377. ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
  3378. record.UltrafiltrationRate = ultrafiltration_rate
  3379. }
  3380. if template.TemplateId == 6 && adminInfo.CurrentOrgId == 10234 {
  3381. dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
  3382. ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
  3383. record.UltrafiltrationRate = ultrafiltration_rate
  3384. }
  3385. if template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 { //adminInfo.CurrentOrgId == 9538
  3386. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
  3387. record.UltrafiltrationRate = ultrafiltration_rate
  3388. }
  3389. if template.TemplateId == 41 { //adminInfo.CurrentOrgId == 9538
  3390. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
  3391. record.UltrafiltrationRate = ultrafiltration_rate
  3392. }
  3393. if template.TemplateId == 43 { //adminInfo.CurrentOrgId == 9538
  3394. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
  3395. record.UltrafiltrationRate = ultrafiltration_rate
  3396. }
  3397. if template.TemplateId == 46 || template.TemplateId == 54 { //adminInfo.CurrentOrgId == 9538
  3398. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
  3399. record.UltrafiltrationRate = ultrafiltration_rate
  3400. }
  3401. if template.TemplateId == 47 { //adminInfo.CurrentOrgId == 9538
  3402. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
  3403. record.UltrafiltrationRate = ultrafiltration_rate
  3404. }
  3405. // 只针对方济医院
  3406. if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
  3407. value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
  3408. ultrafiltration_rate = value
  3409. record.UltrafiltrationRate = ultrafiltration_rate
  3410. }
  3411. //长沙南雅
  3412. if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 || adminInfo.CurrentOrgId == 10432 || adminInfo.CurrentOrgId == 10441 || adminInfo.CurrentOrgId == 10445 || adminInfo.CurrentOrgId == 9829 {
  3413. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
  3414. record.UltrafiltrationRate = ultrafiltration_rate
  3415. }
  3416. }
  3417. }
  3418. // record.UltrafiltrationRate = ultrafiltration_rate
  3419. record.UltrafiltrationVolume = 0
  3420. if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
  3421. if ultrafiltration_rate > 0 {
  3422. value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", float64(record.OperateTime+3600-fristrecord.OperateTime)/3600*ultrafiltration_rate), 6)
  3423. record.UltrafiltrationVolume = value
  3424. }
  3425. }
  3426. if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 41 || template.TemplateId == 43 || template.TemplateId == 47 || template.TemplateId == 54 {
  3427. if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
  3428. ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
  3429. record.UltrafiltrationVolume = ultrafiltration_volume
  3430. }
  3431. }
  3432. //长沙南雅
  3433. if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10432 || adminInfo.CurrentOrgId == 10441 || adminInfo.CurrentOrgId == 10445 {
  3434. if ultrafiltration_rate > 0 {
  3435. ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
  3436. record.UltrafiltrationVolume = ultrafiltration_volume
  3437. }
  3438. }
  3439. if template.TemplateId == 47 || template.TemplateId == 54 {
  3440. record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
  3441. }
  3442. this.ServeSuccessJSON(map[string]interface{}{
  3443. "monitor": record,
  3444. })
  3445. }
  3446. func (c *DialysisApiController) UploadDryWeight() {
  3447. patient_id, _ := c.GetInt64("id")
  3448. dry_weight, _ := c.GetFloat("dry_weight")
  3449. doctor_id, _ := c.GetInt64("doctor_id")
  3450. remark := c.GetString("remark")
  3451. adminUserInfo := c.GetAdminUserInfo()
  3452. weightAdjust, err := service.FindLastDryWeightAdjust(adminUserInfo.CurrentOrgId, patient_id)
  3453. fmt.Println(err)
  3454. if err == gorm.ErrRecordNotFound {
  3455. dryWeight := &models.SgjPatientDryweight{
  3456. PatientId: patient_id,
  3457. DryWeight: dry_weight,
  3458. Remakes: remark,
  3459. Ctime: time.Now().Unix(),
  3460. Mtime: time.Now().Unix(),
  3461. Creator: doctor_id,
  3462. Status: 1,
  3463. UserOrgId: adminUserInfo.CurrentOrgId,
  3464. AdjustedValue: "/",
  3465. UserId: adminUserInfo.AdminUser.Id,
  3466. }
  3467. createErr := service.CreatePatientWeightAdjust(dryWeight)
  3468. loc, _ := time.LoadLocation("Local")
  3469. nowTime := time.Now()
  3470. nowDay := nowTime.Format("2006-01-02")
  3471. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  3472. redis := service.RedisClient()
  3473. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  3474. redis.Set(keyOne, "", time.Second)
  3475. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  3476. redis.Set(key, "", time.Second)
  3477. keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
  3478. redis.Set(keyTwo, "", time.Second)
  3479. redis.Close()
  3480. if createErr == nil {
  3481. c.ServeSuccessJSON(map[string]interface{}{
  3482. "msg": "提交成功",
  3483. "weight": dryWeight,
  3484. })
  3485. }
  3486. } else {
  3487. dryWeight := &models.SgjPatientDryweight{
  3488. PatientId: patient_id,
  3489. DryWeight: dry_weight,
  3490. Remakes: remark,
  3491. Ctime: time.Now().Unix(),
  3492. Mtime: time.Now().Unix(),
  3493. Creator: doctor_id,
  3494. Status: 1,
  3495. UserOrgId: adminUserInfo.CurrentOrgId,
  3496. AdjustedValue: "/",
  3497. UserId: adminUserInfo.AdminUser.Id,
  3498. }
  3499. var value float64
  3500. value = dry_weight - weightAdjust.DryWeight
  3501. fmt.Println(value)
  3502. if value < 0 {
  3503. dryWeight.AdjustedValue = strconv.FormatFloat(math.Abs(value), 'f', 1, 64) + "(下调)"
  3504. } else if value == 0 {
  3505. dryWeight.AdjustedValue = "/"
  3506. } else if value > 0 {
  3507. dryWeight.AdjustedValue = strconv.FormatFloat(value, 'f', 1, 64) + "(上调)"
  3508. }
  3509. fmt.Println(value)
  3510. createErr := service.CreatePatientWeightAdjust(dryWeight)
  3511. loc, _ := time.LoadLocation("Local")
  3512. nowTime := time.Now()
  3513. nowDay := nowTime.Format("2006-01-02")
  3514. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  3515. redis := service.RedisClient()
  3516. keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  3517. redis.Set(keyOne, "", time.Second)
  3518. key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  3519. redis.Set(key, "", time.Second)
  3520. keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
  3521. redis.Set(keyTwo, "", time.Second)
  3522. redis.Close()
  3523. if createErr == nil {
  3524. c.ServeSuccessJSON(map[string]interface{}{
  3525. "msg": "提交成功",
  3526. "weight": dryWeight,
  3527. })
  3528. }
  3529. }
  3530. }
  3531. func (this *DialysisApiController) GetFuncPurview() {
  3532. adminUserInfo := this.GetAdminUserInfo()
  3533. user_id := adminUserInfo.AdminUser.Id
  3534. app_id := adminUserInfo.CurrentAppId
  3535. org_id := adminUserInfo.CurrentOrgId
  3536. create_url := this.GetString("create_url")
  3537. modify_url := this.GetString("modify_url")
  3538. modify_other_url := this.GetString("modify_other_url")
  3539. del_url := this.GetString("del_url")
  3540. del_other_url := this.GetString("del_other_url")
  3541. exce_url := this.GetString("exce_url")
  3542. check_url := this.GetString("check_url")
  3543. modify_exce_url := this.GetString("modify_exce_url")
  3544. module, _ := this.GetInt64("module", 0)
  3545. app_role, _ := service.GetAppRole(org_id, app_id, user_id)
  3546. var is_has_create bool
  3547. var is_has_modify bool
  3548. var is_has_modify_other bool
  3549. var is_has_del bool
  3550. var is_has_del_other bool
  3551. var is_has_exce bool
  3552. var is_has_check bool
  3553. var is_has_modify_exce bool
  3554. org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
  3555. if adminUserInfo.AdminUser.Id != org.Creator {
  3556. if app_role != nil {
  3557. if len(app_role.RoleIds) > 0 {
  3558. roles := strings.Split(app_role.RoleIds, ",")
  3559. var userRolePurviews string
  3560. for _, item := range roles {
  3561. role_id, _ := strconv.ParseInt(item, 10, 64)
  3562. purviews, _ := service.GetRoleFuncPurviewIds(role_id)
  3563. if len(userRolePurviews) == 0 {
  3564. userRolePurviews = purviews
  3565. } else {
  3566. userRolePurviews = userRolePurviews + "," + purviews
  3567. }
  3568. }
  3569. userRolePurviewsArr := RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
  3570. funcPurviews, _ := service.FindAllFuncPurview(userRolePurviewsArr)
  3571. for _, item := range funcPurviews {
  3572. //for _, url := range strings.Split(item.Urlfor,","){
  3573. if strings.Split(item.Urlfor, ",")[1] == create_url {
  3574. is_has_create = true
  3575. }
  3576. if strings.Split(item.Urlfor, ",")[1] == modify_url {
  3577. is_has_modify = true
  3578. }
  3579. if strings.Split(item.Urlfor, ",")[1] == modify_other_url {
  3580. is_has_modify_other = true
  3581. }
  3582. if strings.Split(item.Urlfor, ",")[1] == del_url {
  3583. is_has_del = true
  3584. }
  3585. if strings.Split(item.Urlfor, ",")[1] == del_other_url {
  3586. is_has_del_other = true
  3587. }
  3588. if strings.Split(item.Urlfor, ",")[1] == exce_url {
  3589. is_has_exce = true
  3590. }
  3591. if strings.Split(item.Urlfor, ",")[1] == check_url {
  3592. is_has_check = true
  3593. }
  3594. if strings.Split(item.Urlfor, ",")[1] == modify_exce_url {
  3595. is_has_modify_exce = true
  3596. }
  3597. }
  3598. } else {
  3599. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRole)
  3600. return
  3601. }
  3602. this.ServeSuccessJSON(map[string]interface{}{
  3603. "is_has_create": is_has_create,
  3604. "is_has_modify": is_has_modify,
  3605. "is_has_modify_other": is_has_modify_other,
  3606. "is_has_del": is_has_del,
  3607. "is_has_del_other": is_has_del_other,
  3608. "is_has_exce": is_has_exce,
  3609. "is_has_check": is_has_check,
  3610. "is_has_modify_exce": is_has_modify_exce,
  3611. "module": module,
  3612. })
  3613. } else {
  3614. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
  3615. return
  3616. }
  3617. } else {
  3618. this.ServeSuccessJSON(map[string]interface{}{
  3619. "is_has_create": true,
  3620. "is_has_modify": true,
  3621. "is_has_modify_other": true,
  3622. "is_has_del": true,
  3623. "is_has_del_other": true,
  3624. "is_has_exce": true,
  3625. "is_has_check": true,
  3626. "is_has_modify_exce": true,
  3627. "module": true,
  3628. })
  3629. }
  3630. }
  3631. func (this *DialysisApiController) GetOrderDoctorAdvice() {
  3632. patient_id, _ := this.GetInt64("patient_id", 0)
  3633. advice_date, _ := this.GetInt64("advice_date")
  3634. adminUserInfo := this.GetAdminUserInfo()
  3635. doctorAdvice, _ := service.GetBloodDoctorAdvice(advice_date, adminUserInfo.CurrentOrgId, patient_id)
  3636. hisDoctorAdvice, _ := service.GetHisDoctorAdvice(advice_date, adminUserInfo.CurrentOrgId, patient_id)
  3637. this.ServeSuccessJSON(map[string]interface{}{
  3638. "doctorAdvice": doctorAdvice,
  3639. "hisDoctorAdvice": hisDoctorAdvice,
  3640. })
  3641. }
  3642. func (this *DialysisApiController) GetLastOrNextDoctorAdvice() {
  3643. change_type, _ := this.GetInt64("type", 0)
  3644. record_date := this.GetString("record_time")
  3645. patient_id, _ := this.GetInt64("patient_id", 0)
  3646. timeLayout := "2006-01-02"
  3647. loc, _ := time.LoadLocation("Local")
  3648. theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
  3649. record_time := theAdviceRecordTime.Unix()
  3650. adminUserInfo := this.GetAdminUserInfo()
  3651. advices, sch, err := service.GetDoctorAdviceByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
  3652. if err == nil {
  3653. if len(advices) == 0 {
  3654. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
  3655. return
  3656. } else {
  3657. this.ServeSuccessJSON(map[string]interface{}{
  3658. "advices": advices,
  3659. "schedule": sch,
  3660. })
  3661. return
  3662. }
  3663. } else {
  3664. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3665. return
  3666. }
  3667. }
  3668. func (c *DialysisApiController) GetDialysisGoods() {
  3669. schedualDate := c.GetString("schedule_date")
  3670. schedule_type, _ := c.GetInt64("schedule_type")
  3671. partition_id, _ := c.GetInt64("partition_id")
  3672. page, _ := c.GetInt("page")
  3673. limit, _ := c.GetInt("limit")
  3674. keywords := c.GetString("keywords")
  3675. patient_id, _ := c.GetInt64("patient_id")
  3676. good_type, _ := c.GetInt64("good_type")
  3677. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  3678. if parseDateErr != nil && len(schedualDate) != 0 {
  3679. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3680. return
  3681. }
  3682. schedualEndDate := int64(0)
  3683. endDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", schedualDate+" 23:59:59")
  3684. if parseDateErr != nil && len(schedualDate) != 0 {
  3685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3686. return
  3687. }
  3688. schedualEndDate = endDate.Unix()
  3689. adminUser := c.GetAdminUserInfo()
  3690. _, err := service.FindStockOutByIsSys(adminUser.CurrentOrgId, 1, date.Unix())
  3691. goodTypes, _ := service.FindAllGoodType(adminUser.CurrentOrgId)
  3692. if err == gorm.ErrRecordNotFound {
  3693. list, _ := service.GetDialysisGood(adminUser.CurrentOrgId, date.Unix())
  3694. var ids []int64
  3695. for _, item := range list {
  3696. ids = append(ids, item.PatientId)
  3697. }
  3698. dialysisGoods, _, total := service.PCGetDialysisGoods(adminUser.CurrentOrgId, date.Unix(), schedule_type, partition_id, page, limit, patient_id, keywords, schedualEndDate, good_type, ids)
  3699. for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
  3700. goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.CurrentOrgId, date.Unix())
  3701. lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.CurrentOrgId, date.Unix())
  3702. item.LastAutomaticReduceDetail = goodUser
  3703. item.LastDialysisBeforePrepare = lastGoodUserDetial
  3704. }
  3705. c.ServeSuccessJSON(map[string]interface{}{
  3706. "dialysis_goods": dialysisGoods,
  3707. "good_type": goodTypes,
  3708. "total": total,
  3709. })
  3710. return
  3711. } else if err == nil {
  3712. //获取当天排班的每个患者的库存使用情况
  3713. list, _ := service.GetDialysisGood(adminUser.CurrentOrgId, date.Unix())
  3714. var ids []int64
  3715. for _, item := range list {
  3716. ids = append(ids, item.PatientId)
  3717. }
  3718. dialysisGoods, err, total := service.PCGetDialysisGoods(adminUser.CurrentOrgId, date.Unix(), schedule_type, partition_id, page, limit, patient_id, keywords, schedualEndDate, good_type, ids)
  3719. for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
  3720. goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.CurrentOrgId, date.Unix())
  3721. lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.CurrentOrgId, date.Unix())
  3722. fmt.Println(goodUser)
  3723. fmt.Println(lastGoodUserDetial)
  3724. item.LastAutomaticReduceDetail = goodUser
  3725. item.LastDialysisBeforePrepare = lastGoodUserDetial
  3726. }
  3727. if err == nil {
  3728. c.ServeSuccessJSON(map[string]interface{}{
  3729. "dialysis_goods": dialysisGoods,
  3730. "good_type": goodTypes,
  3731. "total": total,
  3732. })
  3733. return
  3734. } else {
  3735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3736. return
  3737. }
  3738. } else if err != nil {
  3739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3740. return
  3741. }
  3742. }
  3743. func (c *DialysisApiController) GetDialysisGoodsStatistics() {
  3744. start_time := c.GetString("start_time")
  3745. end_time := c.GetString("end_time")
  3746. timeLayout := "2006-01-02"
  3747. loc, _ := time.LoadLocation("Local")
  3748. var theStartTime int64
  3749. if len(start_time) > 0 {
  3750. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3751. if err != nil {
  3752. utils.ErrorLog(err.Error())
  3753. }
  3754. theStartTime = theTime.Unix()
  3755. }
  3756. var theEndtTime int64
  3757. if len(end_time) > 0 {
  3758. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3759. if err != nil {
  3760. utils.ErrorLog(err.Error())
  3761. }
  3762. theEndtTime = theTime.Unix()
  3763. }
  3764. adminUser := c.GetAdminUserInfo()
  3765. outInfo, err := service.MobileGetGoodsStatistics(adminUser.CurrentOrgId, theStartTime, theEndtTime)
  3766. if err == nil {
  3767. c.ServeSuccessJSON(map[string]interface{}{
  3768. "stock_out": outInfo,
  3769. })
  3770. return
  3771. } else {
  3772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3773. return
  3774. }
  3775. }
  3776. func (c *DialysisApiController) GetRoleList() {
  3777. orgId := c.GetAdminUserInfo().CurrentOrgId
  3778. admin_user_id, _ := c.GetInt64("admin_user_id")
  3779. list, err := service.GetRoleList(orgId, admin_user_id)
  3780. if err == nil {
  3781. c.ServeSuccessJSON(map[string]interface{}{
  3782. "adminRole": list,
  3783. })
  3784. return
  3785. } else {
  3786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3787. return
  3788. }
  3789. }
  3790. func (c *DialysisApiController) GetInitPrintData() {
  3791. patient_id, _ := c.GetInt64("patient_id")
  3792. record_date, _ := c.GetInt64("record_date")
  3793. orgId := c.GetAdminUserInfo().CurrentOrgId
  3794. list, err := service.GetInitPrintData(patient_id, record_date, orgId)
  3795. assessmentAfterDislysis, _ := service.GetLastWeightAfter(patient_id, record_date, orgId)
  3796. if err == nil {
  3797. c.ServeSuccessJSON(map[string]interface{}{
  3798. "list": list,
  3799. "assessmentAfterDislysis": assessmentAfterDislysis,
  3800. })
  3801. return
  3802. } else {
  3803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3804. return
  3805. }
  3806. }
  3807. func (c *DialysisApiController) GetInitPrintDataOne() {
  3808. patient_id, _ := c.GetInt64("patient_id")
  3809. start_time := c.GetString("record_date")
  3810. timeLayout := "2006-01-02"
  3811. loc, _ := time.LoadLocation("Local")
  3812. var theStartTime int64
  3813. if len(start_time) > 0 {
  3814. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3815. if err != nil {
  3816. utils.ErrorLog(err.Error())
  3817. }
  3818. theStartTime = theTime.Unix()
  3819. }
  3820. orgId := c.GetAdminUserInfo().CurrentOrgId
  3821. list, err := service.GetInitPrintData(patient_id, theStartTime, orgId)
  3822. assessmentAfterDislysis, _ := service.GetLastWeightAfter(patient_id, theStartTime, orgId)
  3823. if err == nil {
  3824. c.ServeSuccessJSON(map[string]interface{}{
  3825. "list": list,
  3826. "assessmentAfterDislysis": assessmentAfterDislysis,
  3827. })
  3828. return
  3829. } else {
  3830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3831. return
  3832. }
  3833. }
  3834. // 新接口
  3835. func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
  3836. keyword := this.GetString("keywords")
  3837. limit, _ := this.GetInt64("limit")
  3838. page, _ := this.GetInt64("page")
  3839. partition_id, _ := this.GetInt64("partition_id")
  3840. schedule_type, _ := this.GetInt64("schedule_type")
  3841. start_time := this.GetString("schedule_date")
  3842. advice_ids := this.GetString("ids")
  3843. var ids []string
  3844. if advice_ids != "" {
  3845. ids = strings.Split(advice_ids, ",")
  3846. }
  3847. timeLayout := "2006-01-02"
  3848. loc, _ := time.LoadLocation("Local")
  3849. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3850. orgId := this.GetAdminUserInfo().CurrentOrgId
  3851. _, config := service.FindXTHisRecordByOrgId(orgId)
  3852. goodType, _ := service.GetAllGoodType(orgId)
  3853. if config.IsOpen != 1 {
  3854. list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
  3855. fmt.Println("list2232323223332323232", list)
  3856. if err == nil {
  3857. this.ServeSuccessJSON(map[string]interface{}{
  3858. "list": list,
  3859. "total": total,
  3860. "config": config,
  3861. "goodType": goodType,
  3862. })
  3863. return
  3864. } else {
  3865. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3866. return
  3867. }
  3868. }
  3869. if config.IsOpen == 1 {
  3870. list, total, err := service.GetHisPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
  3871. if err == nil {
  3872. this.ServeSuccessJSON(map[string]interface{}{
  3873. "list": list,
  3874. "total": total,
  3875. "config": config,
  3876. "goodType": goodType,
  3877. })
  3878. return
  3879. }
  3880. }
  3881. }
  3882. func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
  3883. keyword := this.GetString("keywords")
  3884. limit, _ := this.GetInt64("limit")
  3885. page, _ := this.GetInt64("page")
  3886. partition_id, _ := this.GetInt64("partition_id")
  3887. schedule_type, _ := this.GetInt64("schedule_type")
  3888. start_time := this.GetString("schedule_date")
  3889. ids := this.GetString("ids")
  3890. var idArray []string
  3891. if ids != "" {
  3892. idArray = strings.Split(ids, ",")
  3893. }
  3894. timeLayout := "2006-01-02"
  3895. loc, _ := time.LoadLocation("Local")
  3896. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3897. orgId := this.GetAdminUserInfo().CurrentOrgId
  3898. list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
  3899. tablelist, _, err := service.GetDialysisAdviceSchedulistSix(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
  3900. //获取长期医嘱
  3901. adviceList, _ := service.GetAllLongAdviceList(orgId)
  3902. _, config := service.FindXTHisRecordByOrgId(orgId)
  3903. drugList, _ := service.GetAllBaseDrugListTwenty(orgId)
  3904. if err == nil {
  3905. this.ServeSuccessJSON(map[string]interface{}{
  3906. "list": list,
  3907. "total": total,
  3908. "adviceList": adviceList,
  3909. "config": config,
  3910. "drugList": drugList,
  3911. "tablelist": tablelist,
  3912. })
  3913. return
  3914. } else {
  3915. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3916. return
  3917. }
  3918. }
  3919. func (this *DialysisApiController) SaveDialysisSetting() {
  3920. orgId := this.GetAdminUserInfo().CurrentOrgId
  3921. device_number_set, _ := this.GetInt64("device_number_set")
  3922. device_type_set, _ := this.GetInt64("device_type_set")
  3923. name_set, _ := this.GetInt64("name_set")
  3924. admission_number_set, _ := this.GetInt64("admission_number_set")
  3925. dialysis_no_set, _ := this.GetInt64("dialysis_no_set")
  3926. weight_befor_set, _ := this.GetInt64("weight_befor_set")
  3927. dry_weight_set, _ := this.GetInt64("dry_weight_set")
  3928. blood_pressure_set, _ := this.GetInt64("blood_pressure_set")
  3929. ultrafiltration_volume_set, _ := this.GetInt64("ultrafiltration_volume_set")
  3930. internal_fistula_set, _ := this.GetInt64("internal_fistula_set")
  3931. blood_flow_volume_set, _ := this.GetInt64("blood_flow_volume_set")
  3932. anticoagulant_set, _ := this.GetInt64("anticoagulant_set")
  3933. sealing_fluid_dispose_set, _ := this.GetInt64("sealing_fluid_dispose_set")
  3934. mode_id_set, _ := this.GetInt64("mode_id_set")
  3935. dialysis_time_set, _ := this.GetInt64("dialysis_time_set")
  3936. dialysis_dialyszers_set, _ := this.GetInt64("dialysis_dialyszers_set")
  3937. dialysis_irrigation_set, _ := this.GetInt64("dialysis_irrigation_set")
  3938. gaijiliang_set, _ := this.GetInt64("gaijiliang_set")
  3939. kalium_set, _ := this.GetInt64("kalium_set")
  3940. displace_liqui_value_set, _ := this.GetInt64("displace_liqui_value_set")
  3941. bicarbonate_set, _ := this.GetInt64("bicarbonate_set")
  3942. glucose_set, _ := this.GetInt64("glucose_set")
  3943. sodium_set, _ := this.GetInt64("sodium_set")
  3944. calcium_set, _ := this.GetInt64("calcium_set")
  3945. blood_access_set, _ := this.GetInt64("blood_access_set")
  3946. dialyzer_perfusion_apparatus_set, _ := this.GetInt64("dialyzer_perfusion_apparatus_set")
  3947. displace_liqui_part_set, _ := this.GetInt64("displace_liqui_part_set")
  3948. dialysisSetting := models.XtDialysisSetting{
  3949. Sodium: sodium_set,
  3950. Calcium: calcium_set,
  3951. BloodAccess: blood_access_set,
  3952. DialyzerPerfusionApparatus: dialyzer_perfusion_apparatus_set,
  3953. DisplaceLiquiPart: displace_liqui_part_set,
  3954. UserOrgId: orgId,
  3955. Status: 1,
  3956. DeviceNumber: device_number_set,
  3957. DeviceType: device_type_set,
  3958. Name: name_set,
  3959. AdmissionNumber: admission_number_set,
  3960. DialysisNo: dialysis_no_set,
  3961. WeightBefor: weight_befor_set,
  3962. DryWeight: dry_weight_set,
  3963. BloodPressure: blood_pressure_set,
  3964. UltrafiltrationVolume: ultrafiltration_volume_set,
  3965. InternalFistula: internal_fistula_set,
  3966. BloodFlowVolume: blood_flow_volume_set,
  3967. Anticoagulant: anticoagulant_set,
  3968. SealingFluidDispose: sealing_fluid_dispose_set,
  3969. ModeId: mode_id_set,
  3970. DialysisTime: dialysis_time_set,
  3971. DialysisDialyszers: dialysis_dialyszers_set,
  3972. DialysisIrrigation: dialysis_irrigation_set,
  3973. Gaijiliang: gaijiliang_set,
  3974. Kalium: kalium_set,
  3975. DisplaceLiquiValue: displace_liqui_value_set,
  3976. Bicarbonate: bicarbonate_set,
  3977. Glucose: glucose_set,
  3978. Ctime: time.Now().Unix(),
  3979. Mtime: time.Now().Unix(),
  3980. }
  3981. err := service.SaveDialysisSetting(dialysisSetting)
  3982. if err == nil {
  3983. this.ServeSuccessJSON(map[string]interface{}{
  3984. "dialysisSetting": dialysisSetting,
  3985. })
  3986. return
  3987. } else {
  3988. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  3989. return
  3990. }
  3991. }
  3992. func (this *DialysisApiController) GetDialysisSetting() {
  3993. orgId := this.GetAdminUserInfo().CurrentOrgId
  3994. dialysisSett, _ := service.GetDialysisSetting(orgId)
  3995. this.ServeSuccessJSON(map[string]interface{}{
  3996. "dialysisSett": dialysisSett,
  3997. })
  3998. return
  3999. }
  4000. func (this *DialysisApiController) GetDialysisParameterList() {
  4001. keyword := this.GetString("keywords")
  4002. limit, _ := this.GetInt64("limit")
  4003. page, _ := this.GetInt64("page")
  4004. partition_id, _ := this.GetInt64("partition_id")
  4005. schedule_type, _ := this.GetInt64("schedule_type")
  4006. start_time := this.GetString("schedule_date")
  4007. timeLayout := "2006-01-02"
  4008. loc, _ := time.LoadLocation("Local")
  4009. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4010. orgId := this.GetAdminUserInfo().CurrentOrgId
  4011. scheduids := this.GetString("ids")
  4012. var ids []string
  4013. if scheduids != "" {
  4014. ids = strings.Split(scheduids, ",")
  4015. }
  4016. list, total, err := service.GetDialysisParameterList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
  4017. dialysisSett, _ := service.GetDialysisSetting(orgId)
  4018. if err == nil {
  4019. this.ServeSuccessJSON(map[string]interface{}{
  4020. "list": list,
  4021. "total": total,
  4022. "dialysisSett": dialysisSett,
  4023. })
  4024. return
  4025. } else {
  4026. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4027. return
  4028. }
  4029. }
  4030. func (this *DialysisApiController) GetDialysisGoodTotalCount() {
  4031. orgId := this.GetAdminUserInfo().CurrentOrgId
  4032. schedule_type, _ := this.GetInt64("schedule_type")
  4033. partion_type, _ := this.GetInt64("partion_type")
  4034. start_time := this.GetString("selected_date")
  4035. timeLayout := "2006-01-02"
  4036. loc, _ := time.LoadLocation("Local")
  4037. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4038. list, err := service.GetDialysisGoodTotalCount(orgId, schedule_type, partion_type, startTime.Unix())
  4039. if err == nil {
  4040. this.ServeSuccessJSON(map[string]interface{}{
  4041. "list": list,
  4042. })
  4043. return
  4044. } else {
  4045. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4046. return
  4047. }
  4048. }
  4049. func (this *DialysisApiController) GetDialysisAdviceSchedulist() {
  4050. orgId := this.GetAdminUserInfo().CurrentOrgId
  4051. schedule_type, _ := this.GetInt64("schedule_type")
  4052. partion_type, _ := this.GetInt64("partion_type")
  4053. start_time := this.GetString("selected_date")
  4054. timeLayout := "2006-01-02"
  4055. loc, _ := time.LoadLocation("Local")
  4056. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4057. list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
  4058. tablelist, _ := service.GetDialysisAdviceSchedulistTwo(orgId, schedule_type, partion_type, startTime.Unix())
  4059. //获取长期医嘱
  4060. adviceList, _ := service.GetAllLongAdviceList(orgId)
  4061. drug, _ := service.GetAllBaseDrugListTwenty(orgId)
  4062. _, config := service.FindXTHisRecordByOrgId(orgId)
  4063. if err == nil {
  4064. this.ServeSuccessJSON(map[string]interface{}{
  4065. "list": list,
  4066. "drug": drug,
  4067. "adviceList": adviceList,
  4068. "config": config,
  4069. "tablelist": tablelist,
  4070. })
  4071. return
  4072. } else {
  4073. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4074. return
  4075. }
  4076. }
  4077. func (this *DialysisApiController) GetDialysisParameterGoodList() {
  4078. orgId := this.GetAdminUserInfo().CurrentOrgId
  4079. schedule_type, _ := this.GetInt64("schedule_type")
  4080. partion_type, _ := this.GetInt64("partion_type")
  4081. start_time := this.GetString("selected_date")
  4082. timeLayout := "2006-01-02"
  4083. loc, _ := time.LoadLocation("Local")
  4084. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4085. list, err := service.GetDialysisParameterGoodList(orgId, schedule_type, partion_type, startTime.Unix())
  4086. if err == nil {
  4087. this.ServeSuccessJSON(map[string]interface{}{
  4088. "list": list,
  4089. })
  4090. return
  4091. } else {
  4092. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4093. return
  4094. }
  4095. }
  4096. func (this *DialysisApiController) SaveHisDialysis() {
  4097. var ids []string
  4098. advice_ids := this.GetString("ids")
  4099. ids = strings.Split(advice_ids, ",")
  4100. orgId := this.GetAdminUserInfo().CurrentOrgId
  4101. service.SaveHisDialysis(orgId, ids)
  4102. returnData := make(map[string]interface{}, 0)
  4103. returnData["msg"] = "ok"
  4104. this.ServeSuccessJSON(returnData)
  4105. return
  4106. }
  4107. func (this *DialysisApiController) GetHisDialysisGoodCount() {
  4108. orgId := this.GetAdminUserInfo().CurrentOrgId
  4109. schedule_type, _ := this.GetInt64("schedule_type")
  4110. partion_type, _ := this.GetInt64("partion_type")
  4111. start_time := this.GetString("selected_date")
  4112. timeLayout := "2006-01-02"
  4113. loc, _ := time.LoadLocation("Local")
  4114. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4115. list, _ := service.GetHisDialysisGoodCount(orgId, schedule_type, partion_type, startTime.Unix())
  4116. this.ServeSuccessJSON(map[string]interface{}{
  4117. "list": list,
  4118. })
  4119. return
  4120. }
  4121. func (this *DialysisApiController) GetPatientSchedule() {
  4122. orgId := this.GetAdminUserInfo().CurrentOrgId
  4123. patient_id, _ := this.GetInt64("patient_id")
  4124. schedule_date, _ := this.GetInt64("schedule_date")
  4125. schedulePatient, _ := service.GetScheduleByPatient(patient_id, schedule_date, orgId)
  4126. this.ServeSuccessJSON(map[string]interface{}{
  4127. "schedulePatient": schedulePatient,
  4128. })
  4129. }
  4130. func (c *DialysisApiController) GetSchedulePrintList() {
  4131. page, _ := c.GetInt64("page", 1)
  4132. limit, _ := c.GetInt64("limit", 10)
  4133. schedulType, _ := c.GetInt64("schedule_type", 0)
  4134. partitionType, _ := c.GetInt64("partition_type", 0)
  4135. keywords := c.GetString("keywords")
  4136. schedule_date := c.GetString("schedule_date")
  4137. timeLayout := "2006-01-02"
  4138. loc, _ := time.LoadLocation("Local")
  4139. var theStartTime int64
  4140. if len(schedule_date) > 0 {
  4141. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
  4142. if err != nil {
  4143. utils.ErrorLog(err.Error())
  4144. }
  4145. theStartTime = theTime.Unix()
  4146. }
  4147. adminUserInfo := c.GetAdminUserInfo()
  4148. list, total, _ := service.GetSchedulePrintList(page, limit, schedulType, partitionType, keywords, theStartTime, adminUserInfo.CurrentOrgId)
  4149. for _, item := range list {
  4150. order, _ := service.GetLastOrder(item.UserOrgId, item.PatientId, item.ScheduleDate)
  4151. item.DialysisOrderTwenty = order
  4152. }
  4153. listOne, _ := service.GetSchedulePrintListOne(page, limit, schedulType, partitionType, keywords, theStartTime, adminUserInfo.CurrentOrgId)
  4154. numberList, _ := service.GetAllBedNumberSix(adminUserInfo.CurrentOrgId)
  4155. c.ServeSuccessJSON(map[string]interface{}{
  4156. "list": list,
  4157. "total": total,
  4158. "numberList": numberList,
  4159. "listOne": listOne,
  4160. })
  4161. }
  4162. func (this *DialysisApiController) GetSolutionListByOrgId() {
  4163. orgId := this.GetAdminUserInfo().CurrentOrgId
  4164. list, _ := service.GetSolutionListByOrgId(orgId)
  4165. for _, item := range list {
  4166. //获取该模式最新的1条数据
  4167. solution, _ := service.GetNewPatientSolutionByModeId(item.PatientId, item.ModeId, orgId)
  4168. //更新状态值
  4169. service.UpdateDialysisSolutionStatus(solution.ID, item.ModeId, orgId, item.PatientId)
  4170. }
  4171. this.ServeSuccessJSON(map[string]interface{}{
  4172. "list": list,
  4173. })
  4174. }
  4175. func (this *DialysisApiController) ExcutionDoctorAdvice() {
  4176. orgId := this.GetAdminUserInfo().CurrentOrgId
  4177. is_open, _ := this.GetInt64("is_open")
  4178. idsStr := this.GetString("str")
  4179. recordIDStrs := strings.Split(idsStr, ",")
  4180. start_time := this.GetString("advice_date")
  4181. exec_time, _ := this.GetInt64("exec_time")
  4182. timeLayout := "2006-01-02"
  4183. loc, _ := time.LoadLocation("Local")
  4184. var startTime int64
  4185. if len(start_time) > 0 {
  4186. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4187. if err != nil {
  4188. //fmt.Println(err)
  4189. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4190. return
  4191. }
  4192. startTime = theTime.Unix()
  4193. }
  4194. config, _ := service.GetDrugOpenConfigOne(orgId)
  4195. pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
  4196. storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
  4197. //his医嘱
  4198. if is_open == 1 {
  4199. groupList, _ := service.GetHisExcutionDoctorAdviceListGroupList(recordIDStrs, startTime, orgId)
  4200. //查找未执行医嘱
  4201. list, _ := service.GetHisExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
  4202. for _, item := range list {
  4203. if item.Checker == this.GetAdminUserInfo().AdminUser.Id {
  4204. this.ServeSuccessJSON(map[string]interface{}{
  4205. "msg": "3",
  4206. })
  4207. return
  4208. }
  4209. }
  4210. for _, item := range groupList {
  4211. for _, it := range list {
  4212. if item.DrugId == it.DrugId {
  4213. item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
  4214. }
  4215. }
  4216. }
  4217. for _, item := range groupList {
  4218. medical, _ := service.GetBaseDrugMedical(item.DrugId)
  4219. var sum_out_count int64
  4220. for _, it := range item.ChildDoctorAdvice {
  4221. var prescribing_number int64
  4222. stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
  4223. parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
  4224. if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  4225. prescribing_number = parseIntPrescribingNumber * medical.MinNumber
  4226. }
  4227. if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  4228. prescribing_number = parseIntPrescribingNumber
  4229. }
  4230. if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
  4231. prescribing_number = parseIntPrescribingNumber
  4232. }
  4233. sum_out_count += prescribing_number
  4234. houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
  4235. drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId, houseConfig.DrugStorehouseOut)
  4236. //库存不足
  4237. if sum_out_count > drugStockOut.FlushCount {
  4238. this.ServeSuccessJSON(map[string]interface{}{
  4239. "msg": "2",
  4240. "drug": medical,
  4241. })
  4242. return
  4243. }
  4244. }
  4245. }
  4246. creater := this.GetAdminUserInfo().AdminUser.Id
  4247. //执行出库逻辑
  4248. for _, item := range list {
  4249. hisadvice := &models.HisDoctorAdviceInfo{
  4250. ID: item.ID,
  4251. UserOrgId: item.UserOrgId,
  4252. PatientId: item.PatientId,
  4253. AdviceType: item.AdviceType,
  4254. AdviceDate: item.AdviceDate,
  4255. StartTime: item.StartTime,
  4256. AdviceName: item.AdviceName,
  4257. AdviceDesc: item.AdviceDesc,
  4258. ReminderDate: item.ReminderDate,
  4259. SingleDose: item.SingleDose,
  4260. SingleDoseUnit: item.SingleDoseUnit,
  4261. DrugSpec: item.DrugSpec,
  4262. DrugSpecUnit: item.DrugSpecUnit,
  4263. PrescribingNumber: item.PrescribingNumber,
  4264. PrescribingNumberUnit: item.PrescribingNumberUnit,
  4265. DeliveryWay: item.DeliveryWay,
  4266. ExecutionFrequency: item.ExecutionFrequency,
  4267. AdviceDoctor: item.AdviceDoctor,
  4268. Status: 1,
  4269. CreatedTime: item.CreatedTime,
  4270. UpdatedTime: item.UpdatedTime,
  4271. AdviceAffirm: item.AdviceAffirm,
  4272. Remark: item.Remark,
  4273. StopTime: item.StopTime,
  4274. StopReason: item.StopReason,
  4275. StopDoctor: item.StopDoctor,
  4276. StopState: item.StopState,
  4277. ParentId: item.ParentId,
  4278. ExecutionTime: item.ExecutionTime,
  4279. ExecutionStaff: creater,
  4280. ExecutionState: item.ExecutionState,
  4281. Checker: item.Checker,
  4282. RecordDate: item.RecordDate,
  4283. DialysisOrderId: item.DialysisOrderId,
  4284. CheckTime: item.CheckTime,
  4285. CheckState: item.CheckState,
  4286. RemindType: item.RemindType,
  4287. FrequencyType: item.FrequencyType,
  4288. DayCount: item.DayCount,
  4289. WeekDay: item.WeekDay,
  4290. TemplateId: item.TemplateId,
  4291. Modifier: item.Modifier,
  4292. Way: item.Way,
  4293. DrugId: item.DrugId,
  4294. ExecutionFrequencyId: item.ExecutionFrequencyId,
  4295. }
  4296. medical, _ := service.GetBaseDrugMedical(item.DrugId)
  4297. if medical.IsUse == 2 {
  4298. if config.IsOpen != 1 {
  4299. if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
  4300. service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
  4301. }
  4302. //不通过药房发药
  4303. if pharmacyConfig.IsOpen != 1 {
  4304. service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
  4305. }
  4306. //查询默认仓库
  4307. storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
  4308. //查询默认仓库剩余多少库存
  4309. var sum_count int64
  4310. stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
  4311. for _, its := range stockInfo {
  4312. if its.MaxUnit == medical.MaxUnit {
  4313. its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
  4314. }
  4315. sum_count += its.StockMaxNumber + its.StockMinNumber
  4316. }
  4317. service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
  4318. service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
  4319. }
  4320. }
  4321. info := models.HisDoctorAdviceInfo{
  4322. ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
  4323. ExecutionTime: exec_time,
  4324. ExecutionState: 1,
  4325. UpdatedTime: time.Now().Unix(),
  4326. }
  4327. //执行医嘱
  4328. service.UpdateHisDoctorAdviceExecution(info, item.ID)
  4329. key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
  4330. redis := service.RedisClient()
  4331. //清空key 值
  4332. redis.Set(key, "", time.Second)
  4333. keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
  4334. redis.Set(keyTwo, "", time.Second)
  4335. keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
  4336. redis.Set(keyThree, "", time.Second)
  4337. toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
  4338. theTime := toTime.Format("2006-01-02")
  4339. fmt.Println("theTIME", theTime)
  4340. keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
  4341. redis.Set(keyFour, "", time.Second)
  4342. keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
  4343. redis.Set(keyFive, "", time.Second)
  4344. }
  4345. } else {
  4346. groupList, _ := service.GetExcutionDoctorAdviceGroupList(recordIDStrs, startTime, orgId)
  4347. //查找未执行医嘱
  4348. list, _ := service.GetExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
  4349. for _, item := range groupList {
  4350. for _, it := range list {
  4351. if item.DrugId == it.DrugId {
  4352. item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
  4353. }
  4354. }
  4355. }
  4356. for _, item := range groupList {
  4357. medical, _ := service.GetBaseDrugMedical(item.DrugId)
  4358. var sum_out_count int64
  4359. for _, it := range item.ChildDoctorAdvice {
  4360. var prescribing_number int64
  4361. stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
  4362. parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
  4363. if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  4364. prescribing_number = parseIntPrescribingNumber * medical.MinNumber
  4365. }
  4366. if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  4367. prescribing_number = parseIntPrescribingNumber
  4368. }
  4369. if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
  4370. prescribing_number = parseIntPrescribingNumber
  4371. }
  4372. sum_out_count += prescribing_number
  4373. houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
  4374. drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId, houseConfig.DrugStorehouseOut)
  4375. //库存不足
  4376. if sum_out_count > drugStockOut.FlushCount {
  4377. this.ServeSuccessJSON(map[string]interface{}{
  4378. "msg": "2",
  4379. "drug": medical,
  4380. })
  4381. return
  4382. }
  4383. }
  4384. }
  4385. for _, item := range list {
  4386. medical, _ := service.GetBaseDrugMedical(item.DrugId)
  4387. dadvice := &models.DoctorAdvice{
  4388. ID: item.ID,
  4389. UserOrgId: item.UserOrgId,
  4390. PatientId: item.PatientId,
  4391. AdviceType: item.AdviceType,
  4392. AdviceDate: item.AdviceDate,
  4393. StartTime: item.StartTime,
  4394. AdviceName: item.AdviceName,
  4395. AdviceDesc: item.AdviceDesc,
  4396. ReminderDate: item.ReminderDate,
  4397. SingleDose: item.SingleDose,
  4398. SingleDoseUnit: item.SingleDoseUnit,
  4399. DrugSpec: item.DrugSpec,
  4400. DrugSpecUnit: item.DrugSpecUnit,
  4401. PrescribingNumber: item.PrescribingNumber,
  4402. PrescribingNumberUnit: item.PrescribingNumberUnit,
  4403. DeliveryWay: item.DeliveryWay,
  4404. ExecutionFrequency: item.ExecutionFrequency,
  4405. AdviceDoctor: item.AdviceDoctor,
  4406. Status: 1,
  4407. CreatedTime: item.CreatedTime,
  4408. UpdatedTime: item.UpdatedTime,
  4409. AdviceAffirm: item.AdviceAffirm,
  4410. Remark: item.Remark,
  4411. StopTime: item.StopTime,
  4412. StopReason: item.StopReason,
  4413. StopDoctor: item.StopDoctor,
  4414. StopState: item.StopState,
  4415. ParentId: item.ParentId,
  4416. ExecutionTime: item.ExecutionTime,
  4417. ExecutionStaff: item.ExecutionStaff,
  4418. ExecutionState: item.ExecutionState,
  4419. Checker: item.Checker,
  4420. RecordDate: item.ReminderDate,
  4421. DialysisOrderId: item.DialysisOrderId,
  4422. CheckTime: item.CheckTime,
  4423. CheckState: item.CheckState,
  4424. RemindType: item.RemindType,
  4425. FrequencyType: item.FrequencyType,
  4426. DayCount: item.DayCount,
  4427. WeekDay: item.WeekDay,
  4428. TemplateId: item.TemplateId,
  4429. Modifier: item.Modifier,
  4430. Way: item.Way,
  4431. DrugId: item.DrugId,
  4432. }
  4433. if medical.IsUse == 2 {
  4434. if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
  4435. service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
  4436. }
  4437. if pharmacyConfig.IsOpen != 1 {
  4438. service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
  4439. }
  4440. //更新字典里面的库存
  4441. stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
  4442. var sum_count int64
  4443. for _, its := range stockInfo {
  4444. baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
  4445. if its.MaxUnit == baseDrug.MaxUnit {
  4446. its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
  4447. }
  4448. sum_count += its.StockMaxNumber + its.StockMinNumber
  4449. }
  4450. service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
  4451. //剩余库存
  4452. service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
  4453. }
  4454. info := models.DoctorAdvice{
  4455. ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
  4456. ExecutionTime: exec_time,
  4457. ExecutionState: 1,
  4458. UpdatedTime: time.Now().Unix(),
  4459. }
  4460. //执行医嘱
  4461. service.UpdateDoctorAdviceExecution(info, item.ID)
  4462. }
  4463. }
  4464. this.ServeSuccessJSON(map[string]interface{}{
  4465. "msg": "1",
  4466. })
  4467. return
  4468. }
  4469. func (this *DialysisApiController) CheckNewDoctorAdvice() {
  4470. orgId := this.GetAdminUserInfo().CurrentOrgId
  4471. idsStr := this.GetString("str")
  4472. recordIDStrs := strings.Split(idsStr, ",")
  4473. start_time := this.GetString("advice_date")
  4474. timeLayout := "2006-01-02"
  4475. loc, _ := time.LoadLocation("Local")
  4476. var startTime int64
  4477. if len(start_time) > 0 {
  4478. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4479. if err != nil {
  4480. //fmt.Println(err)
  4481. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4482. return
  4483. }
  4484. startTime = theTime.Unix()
  4485. }
  4486. config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
  4487. if config.IsOpen == 1 {
  4488. creater := this.GetAdminUserInfo().AdminUser.Id
  4489. //查询未核对的医嘱
  4490. advicelist, _ := service.GetHisCheckDoctorAdvice(orgId, recordIDStrs, startTime)
  4491. for _, item := range advicelist {
  4492. if item.ExecutionStaff == creater {
  4493. this.ServeSuccessJSON(map[string]interface{}{
  4494. "msg": "2",
  4495. "advice": item,
  4496. })
  4497. return
  4498. }
  4499. service.CheckHisDoctorAdvice(item.ID, creater)
  4500. key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
  4501. redis := service.RedisClient()
  4502. //清空key 值
  4503. redis.Set(key, "", time.Second)
  4504. keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
  4505. redis.Set(keyTwo, "", time.Second)
  4506. keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
  4507. redis.Set(keyThree, "", time.Second)
  4508. theTime := time.Now()
  4509. recordDate := theTime.Format("2006-01-02")
  4510. keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
  4511. redis.Set(keyFour, "", time.Second)
  4512. keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
  4513. redis.Set(keyFive, "", time.Second)
  4514. }
  4515. } else {
  4516. //查询未核对的医嘱
  4517. advicelist, _ := service.GetCheckDoctorAdvice(orgId, recordIDStrs, startTime)
  4518. creater := this.GetAdminUserInfo().AdminUser.Id
  4519. for _, item := range advicelist {
  4520. if item.ExecutionStaff == creater {
  4521. this.ServeSuccessJSON(map[string]interface{}{
  4522. "msg": "2",
  4523. "advice": item,
  4524. })
  4525. return
  4526. }
  4527. service.CheckDoctorAdvice(item.ID, creater)
  4528. key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
  4529. redis := service.RedisClient()
  4530. //清空key 值
  4531. redis.Set(key, "", time.Second)
  4532. keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
  4533. redis.Set(keyTwo, "", time.Second)
  4534. keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
  4535. redis.Set(keyThree, "", time.Second)
  4536. theTime := time.Now()
  4537. recordDate := theTime.Format("2006-01-02")
  4538. keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
  4539. redis.Set(keyFour, "", time.Second)
  4540. keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
  4541. redis.Set(keyFive, "", time.Second)
  4542. }
  4543. }
  4544. this.ServeSuccessJSON(map[string]interface{}{
  4545. "msg": "1",
  4546. })
  4547. return
  4548. }
  4549. func (this *DialysisApiController) SettleNewDoctorAdvice() {
  4550. orgId := this.GetAdminUserInfo().CurrentOrgId
  4551. is_open, _ := this.GetInt64("is_open")
  4552. idsStr := this.GetString("str")
  4553. recordIDStrs := strings.Split(idsStr, ",")
  4554. start_time := this.GetString("advice_date")
  4555. timeLayout := "2006-01-02"
  4556. loc, _ := time.LoadLocation("Local")
  4557. var startTime int64
  4558. if len(start_time) > 0 {
  4559. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4560. if err != nil {
  4561. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4562. return
  4563. }
  4564. startTime = theTime.Unix()
  4565. }
  4566. if is_open == 1 {
  4567. service.SettleHisNewDoctorAdvice(recordIDStrs, startTime, orgId)
  4568. } else {
  4569. service.SettleNewDoctorAdvice(recordIDStrs, startTime, orgId)
  4570. }
  4571. this.ServeSuccessJSON(map[string]interface{}{
  4572. "msg": "1",
  4573. })
  4574. return
  4575. }
  4576. func (this *DialysisApiController) ExcutionDoctorAdviceById() {
  4577. advice_id, _ := this.GetInt64("advice_id")
  4578. start_time := this.GetString("advice_date")
  4579. orgId := this.GetAdminUserInfo().CurrentOrgId
  4580. config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
  4581. exec_time, _ := this.GetInt64("exec_time")
  4582. //his医嘱
  4583. if config.IsOpen == 1 {
  4584. //查询医嘱
  4585. advice, _ := service.GetHisDocById(advice_id, orgId)
  4586. if advice.Checker == this.GetAdminUserInfo().AdminUser.Id {
  4587. this.ServeSuccessJSON(map[string]interface{}{
  4588. "msg": "3",
  4589. })
  4590. return
  4591. }
  4592. medical, _ := service.GetBaseDrugMedical(orgId)
  4593. var prescribing_number int64
  4594. stringPrescribingNumber := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 64)
  4595. parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
  4596. if advice.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  4597. prescribing_number = parseIntPrescribingNumber * medical.MinNumber
  4598. }
  4599. if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  4600. prescribing_number = parseIntPrescribingNumber
  4601. }
  4602. if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
  4603. prescribing_number = parseIntPrescribingNumber
  4604. }
  4605. houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
  4606. drugStockOut, _ := service.GetDrugSumOutCountByDrugId(advice.DrugId, orgId, houseConfig.DrugStorehouseOut)
  4607. //库存不足
  4608. if prescribing_number > drugStockOut.FlushCount {
  4609. this.ServeSuccessJSON(map[string]interface{}{
  4610. "msg": "2",
  4611. "drug": medical,
  4612. })
  4613. return
  4614. }
  4615. info := models.HisDoctorAdviceInfo{
  4616. ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
  4617. ExecutionTime: exec_time,
  4618. ExecutionState: 1,
  4619. UpdatedTime: time.Now().Unix(),
  4620. }
  4621. //执行医嘱
  4622. service.UpdateHisDoctorAdviceExecution(info, advice.ID)
  4623. key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
  4624. redis := service.RedisClient()
  4625. //清空key 值
  4626. redis.Set(key, "", time.Second)
  4627. keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
  4628. redis.Set(keyTwo, "", time.Second)
  4629. keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
  4630. redis.Set(keyThree, "", time.Second)
  4631. toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
  4632. theTime := toTime.Format("2006-01-02")
  4633. fmt.Println("theTIME", theTime)
  4634. keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
  4635. redis.Set(keyFour, "", time.Second)
  4636. keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
  4637. redis.Set(keyFive, "", time.Second)
  4638. //出库
  4639. if prescribing_number <= drugStockOut.FlushCount {
  4640. pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
  4641. //执行出库逻辑
  4642. hisadvice := &models.HisDoctorAdviceInfo{
  4643. ID: advice.ID,
  4644. UserOrgId: advice.UserOrgId,
  4645. PatientId: advice.PatientId,
  4646. AdviceType: advice.AdviceType,
  4647. AdviceDate: advice.AdviceDate,
  4648. StartTime: advice.StartTime,
  4649. AdviceName: advice.AdviceName,
  4650. AdviceDesc: advice.AdviceDesc,
  4651. ReminderDate: advice.ReminderDate,
  4652. SingleDose: advice.SingleDose,
  4653. SingleDoseUnit: advice.SingleDoseUnit,
  4654. DrugSpec: advice.DrugSpec,
  4655. DrugSpecUnit: advice.DrugSpecUnit,
  4656. PrescribingNumber: advice.PrescribingNumber,
  4657. PrescribingNumberUnit: advice.PrescribingNumberUnit,
  4658. DeliveryWay: advice.DeliveryWay,
  4659. ExecutionFrequency: advice.ExecutionFrequency,
  4660. AdviceDoctor: advice.AdviceDoctor,
  4661. Status: 1,
  4662. CreatedTime: advice.CreatedTime,
  4663. UpdatedTime: advice.UpdatedTime,
  4664. AdviceAffirm: advice.AdviceAffirm,
  4665. Remark: advice.Remark,
  4666. StopTime: advice.StopTime,
  4667. StopReason: advice.StopReason,
  4668. StopDoctor: advice.StopDoctor,
  4669. StopState: advice.StopState,
  4670. ParentId: advice.ParentId,
  4671. ExecutionTime: advice.ExecutionTime,
  4672. ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
  4673. ExecutionState: advice.ExecutionState,
  4674. Checker: advice.Checker,
  4675. RecordDate: advice.RecordDate,
  4676. DialysisOrderId: advice.DialysisOrderId,
  4677. CheckTime: advice.CheckTime,
  4678. CheckState: advice.CheckState,
  4679. RemindType: advice.RemindType,
  4680. FrequencyType: advice.FrequencyType,
  4681. DayCount: advice.DayCount,
  4682. WeekDay: advice.WeekDay,
  4683. TemplateId: advice.TemplateId,
  4684. Modifier: advice.Modifier,
  4685. Way: advice.Way,
  4686. DrugId: advice.DrugId,
  4687. ExecutionFrequencyId: advice.ExecutionFrequencyId,
  4688. }
  4689. if medical.IsUse == 2 {
  4690. if config.IsOpen != 1 {
  4691. if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
  4692. service.HisDrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, hisadvice)
  4693. }
  4694. //不通过药房发药
  4695. if pharmacyConfig.IsOpen != 1 {
  4696. service.HisDrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, hisadvice)
  4697. }
  4698. //查询默认仓库
  4699. storeHouseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
  4700. //查询默认仓库剩余多少库存
  4701. var sum_count int64
  4702. stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
  4703. for _, its := range stockInfo {
  4704. if its.MaxUnit == medical.MaxUnit {
  4705. its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
  4706. }
  4707. sum_count += its.StockMaxNumber + its.StockMinNumber
  4708. }
  4709. service.UpdateBaseDrugSumTwo(advice.DrugId, sum_count, advice.UserOrgId)
  4710. service.UpdateDrugStockCount(advice.DrugId, advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
  4711. }
  4712. }
  4713. }
  4714. this.ServeSuccessJSON(map[string]interface{}{
  4715. "msg": "1",
  4716. })
  4717. return
  4718. }
  4719. if config.IsOpen == 2 || config.IsOpen == 0 {
  4720. advice, _ := service.GetBloodDocById(advice_id, orgId)
  4721. medical, _ := service.GetBaseDrugMedical(orgId)
  4722. pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
  4723. storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
  4724. var prescribing_number int64
  4725. stringPrescribingNumber := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 64)
  4726. parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
  4727. if advice.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
  4728. prescribing_number = parseIntPrescribingNumber * medical.MinNumber
  4729. }
  4730. if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
  4731. prescribing_number = parseIntPrescribingNumber
  4732. }
  4733. if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
  4734. prescribing_number = parseIntPrescribingNumber
  4735. }
  4736. houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
  4737. drugStockOut, _ := service.GetDrugSumOutCountByDrugId(advice.DrugId, orgId, houseConfig.DrugStorehouseOut)
  4738. //库存不足
  4739. if prescribing_number > drugStockOut.FlushCount {
  4740. this.ServeSuccessJSON(map[string]interface{}{
  4741. "msg": "2",
  4742. "drug": medical,
  4743. })
  4744. return
  4745. }
  4746. info := models.DoctorAdvice{
  4747. ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
  4748. ExecutionTime: exec_time,
  4749. ExecutionState: 1,
  4750. UpdatedTime: time.Now().Unix(),
  4751. }
  4752. //执行医嘱
  4753. service.UpdateDoctorAdviceExecution(info, advice.ID)
  4754. dadvice := &models.DoctorAdvice{
  4755. ID: advice.ID,
  4756. UserOrgId: advice.UserOrgId,
  4757. PatientId: advice.PatientId,
  4758. AdviceType: advice.AdviceType,
  4759. AdviceDate: advice.AdviceDate,
  4760. StartTime: advice.StartTime,
  4761. AdviceName: advice.AdviceName,
  4762. AdviceDesc: advice.AdviceDesc,
  4763. ReminderDate: advice.ReminderDate,
  4764. SingleDose: advice.SingleDose,
  4765. SingleDoseUnit: advice.SingleDoseUnit,
  4766. DrugSpec: advice.DrugSpec,
  4767. DrugSpecUnit: advice.DrugSpecUnit,
  4768. PrescribingNumber: advice.PrescribingNumber,
  4769. PrescribingNumberUnit: advice.PrescribingNumberUnit,
  4770. DeliveryWay: advice.DeliveryWay,
  4771. ExecutionFrequency: advice.ExecutionFrequency,
  4772. AdviceDoctor: advice.AdviceDoctor,
  4773. Status: 1,
  4774. CreatedTime: advice.CreatedTime,
  4775. UpdatedTime: advice.UpdatedTime,
  4776. AdviceAffirm: advice.AdviceAffirm,
  4777. Remark: advice.Remark,
  4778. StopTime: advice.StopTime,
  4779. StopReason: advice.StopReason,
  4780. StopDoctor: advice.StopDoctor,
  4781. StopState: advice.StopState,
  4782. ParentId: advice.ParentId,
  4783. ExecutionTime: advice.ExecutionTime,
  4784. ExecutionStaff: advice.ExecutionStaff,
  4785. ExecutionState: advice.ExecutionState,
  4786. Checker: advice.Checker,
  4787. RecordDate: advice.ReminderDate,
  4788. DialysisOrderId: advice.DialysisOrderId,
  4789. CheckTime: advice.CheckTime,
  4790. CheckState: advice.CheckState,
  4791. RemindType: advice.RemindType,
  4792. FrequencyType: advice.FrequencyType,
  4793. DayCount: advice.DayCount,
  4794. WeekDay: advice.WeekDay,
  4795. TemplateId: advice.TemplateId,
  4796. Modifier: advice.Modifier,
  4797. Way: advice.Way,
  4798. DrugId: advice.DrugId,
  4799. }
  4800. if medical.IsUse == 2 {
  4801. if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
  4802. service.DrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, dadvice)
  4803. }
  4804. if pharmacyConfig.IsOpen != 1 {
  4805. service.DrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, dadvice)
  4806. }
  4807. //更新字典里面的库存
  4808. stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
  4809. var sum_count int64
  4810. for _, its := range stockInfo {
  4811. baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
  4812. if its.MaxUnit == baseDrug.MaxUnit {
  4813. its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
  4814. }
  4815. sum_count += its.StockMaxNumber + its.StockMinNumber
  4816. }
  4817. service.UpdateBaseDrugSumTwo(advice.DrugId, sum_count, advice.UserOrgId)
  4818. //剩余库存
  4819. service.UpdateDrugStockCount(advice.DrugId, advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
  4820. }
  4821. }
  4822. this.ServeSuccessJSON(map[string]interface{}{
  4823. "msg": "1",
  4824. })
  4825. return
  4826. }
  4827. func (this *DialysisApiController) GetDialysisAdviceToday() {
  4828. orgId := this.GetAdminUserInfo().CurrentOrgId
  4829. schedule_type, _ := this.GetInt64("schedule_type")
  4830. partion_type, _ := this.GetInt64("partion_type")
  4831. start_time := this.GetString("selected_date")
  4832. timeLayout := "2006-01-02"
  4833. loc, _ := time.LoadLocation("Local")
  4834. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4835. list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, partion_type, startTime.Unix())
  4836. drug, _ := service.GetAllBaseDrugListTwenty(orgId)
  4837. _, config := service.FindXTHisRecordByOrgId(orgId)
  4838. if err == nil {
  4839. this.ServeSuccessJSON(map[string]interface{}{
  4840. "list": list,
  4841. "drug": drug,
  4842. "config": config,
  4843. })
  4844. return
  4845. } else {
  4846. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  4847. return
  4848. }
  4849. }