dialysis_api_controller.go 177KB

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