1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341 |
- package controllers
-
- import (
- "encoding/json"
- "fmt"
- "math"
- "reflect"
- "strconv"
- "strings"
-
- "XT_New/models"
- "XT_New/service"
- "XT_New/utils"
- "github.com/jinzhu/gorm"
-
- //"strings"
- "time"
-
- "XT_New/enums"
-
- "github.com/astaxie/beego"
- )
-
- type DialysisApiController struct {
- BaseAuthAPIController
- }
-
- func DialysisApiRegistRouters() {
- beego.Router("/api/dialysis/device", &DialysisApiController{}, "get:GetDeviceList")
- beego.Router("/api/dialysis/patients", &DialysisApiController{}, "get:GetDialysisWatch")
- beego.Router("/api/dialysis/zone", &DialysisApiController{}, "get:GetAllDeviceZone")
- beego.Router("/api/dialysis/info", &DialysisApiController{}, "get:GetSchedualPatientsInfo")
- beego.Router("/api/dialysis/advice/create", &DialysisApiController{}, "Post:CreateDoctorAdvice")
- beego.Router("/api/dialysis/advice/get", &DialysisApiController{}, "Get:GetDoctorAdvice")
- beego.Router("/api/dialysis/advice/edit", &DialysisApiController{}, "put:EditDoctorAdvice")
- beego.Router("/api/dialysis/monitor/create", &DialysisApiController{}, "Post:CreateMonitor")
- beego.Router("/api/dialysis/monitor/del", &DialysisApiController{}, "Post:DelMonitor")
- beego.Router("/api/dialysis/dialysisorder", &DialysisApiController{}, "Get:GetDialysisOrder")
- beego.Router("/api/dialysis/prescription", &DialysisApiController{}, "Post:PostPrescription")
- beego.Router("/api/dialysis/soulution", &DialysisApiController{}, "Post:PostSoulution")
- beego.Router("/api/dialysis/dobule", &DialysisApiController{}, "Post:PostDouleCheck")
- beego.Router("/api/dialysis/accepts", &DialysisApiController{}, "Post:PostReceiveTreatmentAsses")
- beego.Router("/api/dialysis/assessmentbeforedislysis", &DialysisApiController{}, "Post:PostAssessmentBeforeDislysis")
- beego.Router("/api/dialysis/assessmentafterdislysis", &DialysisApiController{}, "Post:PostAssessmentAfterDislysis")
- beego.Router("/api/dialysis/treatmentsummary", &DialysisApiController{}, "Post:PostTreatmentSummary")
-
- beego.Router("/api/dialysis/advice_remind", &DialysisApiController{}, "Get:GetLongAdvice")
- beego.Router("/api/dialysis/advice_remind/one", &DialysisApiController{}, "Get:GetLongAdviceOne")
- beego.Router("/api/dialysis/advice_remind/two", &DialysisApiController{}, "Get:GetLongAdviceTwo")
- beego.Router("/api/advice_remind/create", &DialysisApiController{}, "Post:CreateRemindDoctorAdvice")
-
- beego.Router("/api/solution/get", &DialysisApiController{}, "Get:GetSolution")
-
- beego.Router("/api/schedule/get", &DialysisApiController{}, "Get:GetSchedule")
-
- beego.Router("/api/today_monitor/get", &DialysisApiController{}, "Get:GetTodayMonitor")
-
- beego.Router("/api/dryweight/commit", &DialysisApiController{}, "Post:UploadDryWeight")
-
- beego.Router("/api/func_per/get", &DialysisApiController{}, "Get:GetFuncPurview")
-
- beego.Router("/api/doctoradvice/get", &DialysisApiController{}, "Get:GetLastOrNextDoctorAdvice")
-
- beego.Router("/api/dialysisgoods/get", &DialysisApiController{}, "Get:GetDialysisGoods")
- beego.Router("/api/goodstatistics/get", &DialysisApiController{}, "Get:GetDialysisGoodsStatistics")
- beego.Router("/api/queue/get", &DialysisApiController{}, "Get:GetQueueCall")
- beego.Router("/api/queue/update", &DialysisApiController{}, "Get:UpdateQueueCall")
-
- beego.Router("/api/get/getrolelist", &DialysisApiController{}, "Get:GetRoleList")
-
- beego.Router("/api/getinitprintdata", &DialysisApiController{}, "Get:GetInitPrintData")
-
- beego.Router("/api/schedule/getorderdoctoradvice", &DialysisApiController{}, "Get:GetOrderDoctorAdvice")
-
- beego.Router("/api/getinitprintdateone", &DialysisApiController{}, "Get:GetInitPrintDataOne")
-
- //新接口
- beego.Router("/api/patient/getpatientdialysissolutiongrouplist", &DialysisApiController{}, "Get:GetPatientDialysisSolutionGroupList")
-
- beego.Router("/api/patient/getdialysisadvicetemplatelist", &DialysisApiController{}, "Get:GetDialysisAdviceTemplateList")
-
- beego.Router("/api/patient/savedialysissetting", &DialysisApiController{}, "Get:SaveDialysisSetting")
-
- beego.Router("/api/patient/getdialysissetting", &DialysisApiController{}, "Get:GetDialysisSetting")
-
- beego.Router("/api/patient/getdialysisparameter", &DialysisApiController{}, "Get:GetDialysisParameterList")
-
- beego.Router("/api/patient/getdialysisgoodtotalcount", &DialysisApiController{}, "Get:GetDialysisGoodTotalCount")
-
- beego.Router("/api/patient/getdialysisadvicescheduelist", &DialysisApiController{}, "Get:GetDialysisAdviceSchedulist")
-
- beego.Router("/api/patient/getdialysisparametergoodlist", &DialysisApiController{}, "Get:GetDialysisParameterGoodList")
-
- beego.Router("/api/patient/savehisdialysis", &DialysisApiController{}, "Get:SaveHisDialysis")
-
- beego.Router("/api/patient/gethisdialysisgoodcount", &DialysisApiController{}, "Get:GetHisDialysisGoodCount")
-
- beego.Router("/api/schedule/getpatientshedule", &DialysisApiController{}, "Get:GetPatientSchedule")
-
- beego.Router("/api/patient/getscheduleprintlist", &DialysisApiController{}, "Get:GetSchedulePrintList")
-
- beego.Router("/api/patient/getsolutionlistbyorgid", &DialysisApiController{}, "Get:GetSolutionListByOrgId")
-
- beego.Router("/api/schedule/excutiondoctoradvice", &DialysisApiController{}, "Get:ExcutionDoctorAdvice")
-
- beego.Router("/api/schedule/checknewdoctoradvice", &DialysisApiController{}, "Get:CheckNewDoctorAdvice")
-
- beego.Router("/api/schedule/settlenewdoctoradvice", &DialysisApiController{}, "Get:SettleNewDoctorAdvice")
-
- beego.Router("/api/schedule/excutiondoctoradvicebyid", &DialysisApiController{}, "Get:ExcutionDoctorAdviceById")
-
- beego.Router("/api/patient/getdialysisadvicetoday", &DialysisApiController{}, "Get:GetDialysisAdviceToday")
-
- beego.Router("/api/schedule/getmobileschedulelist", &DialysisApiController{}, "Get:GetMobileScheduleList")
-
- beego.Router("/api/patient/saveinformation", &DialysisApiController{}, "Get:SaveInformation")
-
- beego.Router("/api/patient/savedialysisInformationsetting", &DialysisApiController{}, "Get:SaveDialysisInformationSetting")
-
- beego.Router("/api/patient/getdialyisinformationsetting", &DialysisApiController{}, "Get:GetDialysisInformationSetting")
-
- beego.Router("/api/patient/checkdialysisinformation", &DialysisApiController{}, "Get:CheckDialysisInformation")
-
- beego.Router("/api/dialysis/patientsflow", &DialysisApiController{}, "Get:GetDialysisPatientsFlow")
-
- beego.Router("/api/patient/getlongdialysisadvicetoday", &DialysisApiController{}, "Get:GetLongDialysisAdviceToday")
-
- beego.Router("/api/patient/getpatientlist", &DialysisApiController{}, "Get:GetPatientList")
-
- beego.Router("/api/patient/getprescriptionloglist", &DialysisApiController{}, "Get:GetPrescriptionLogList")
-
- beego.Router("/api/patient/getbeforloglist", &DialysisApiController{}, "Get:GetBeforLogList")
-
- beego.Router("/api/patient/getdocloglist", &DialysisApiController{}, "Get:GetDocLogList")
-
- beego.Router("/api/patient/getmonitorloglist", &DialysisApiController{}, "Get:GetMonitorLogList")
-
- beego.Router("/api/patient/getafterloglist", &DialysisApiController{}, "Get:GetAfterLogList")
-
- beego.Router("/api/patient/savegathersetting", &DialysisApiController{}, "Get:SaveGatherSetting")
-
- beego.Router("/api/patient/getgathersetting", &DialysisApiController{}, "Get:GetGatherSetting")
-
- beego.Router("/api/patient/getdialysisgatherlist", &DialysisApiController{}, "Get:GetDialysisGatherList")
-
- beego.Router("/api/getpatientdialysisrecordlist", &DialysisApiController{}, "Get:GetPatientDialysisRecordList")
-
- beego.Router("/api/patient/getpatientrecordlist", &DialysisApiController{}, "Get:GetPatientRecordList")
-
- beego.Router("/api/patient/getdialysistotalcount", &DialysisApiController{}, "Get:GetDialysisTotalCount")
-
- beego.Router("/api/schedule/getdialysisproject", &DialysisApiController{}, "Get:GetDialysisProject")
-
- beego.Router("/api/schedule/getpatientbefor", &DialysisApiController{}, "Get:GetPatientBefor")
-
- }
-
- func (c *DialysisApiController) GetQueueCall() {
- adminUserInfo := c.GetAdminUserInfo()
- queueConfig, _ := service.FindQueueCallInfo(adminUserInfo.CurrentOrgId)
-
- if queueConfig.ID <= 0 {
- queueConfig.OrgId = adminUserInfo.CurrentOrgId
- queueConfig.Qhsj = 10
- queueConfig.Jzdcbbcs = 3
- queueConfig.Jzbbsy = 1
- queueConfig.Jzjhyc = 0
- queueConfig.Sjdcbbcs = 3
- queueConfig.Sjbbsy = 0
- queueConfig.Sjjhyc = 0
- queueConfig.Txxqyxs = 0
- queueConfig.Txglsyxs = 0
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "queue_config": queueConfig,
- })
- }
-
- func (c *DialysisApiController) UpdateQueueCall() {
- adminUserInfo := c.GetAdminUserInfo()
- queueConfig, _ := service.FindQueueCallInfo(adminUserInfo.CurrentOrgId)
-
- if queueConfig.ID <= 0 {
- queueConfig.OrgId = adminUserInfo.CurrentOrgId
- queueConfig.Qhsj = 10
- queueConfig.Jzdcbbcs = 3
- queueConfig.Jzbbsy = 1
- queueConfig.Jzjhyc = 0
- queueConfig.Sjdcbbcs = 3
- queueConfig.Sjbbsy = 0
- queueConfig.Sjjhyc = 0
- queueConfig.Txxqyxs = 0
- queueConfig.Txglsyxs = 0
- queueConfig.CreateTime = time.Now().Unix()
- queueConfig.UpdateTime = time.Now().Unix()
- }
-
- qhsj, _ := c.GetInt64("qhsj", 0)
- if qhsj > 0 {
- queueConfig.Qhsj = qhsj
- }
-
- jzdcbbcs, _ := c.GetInt64("jzdcbbcs", 0)
- if jzdcbbcs > 0 {
- queueConfig.Jzdcbbcs = jzdcbbcs
- }
-
- jzbbsy, _ := c.GetInt64("jzbbsy", 0)
- if jzbbsy > 0 {
- queueConfig.Jzbbsy = jzbbsy
- }
-
- jzjhyc, _ := c.GetInt64("jzjhyc", 0)
- queueConfig.Jzjhyc = jzjhyc
-
- sjdcbbcs, _ := c.GetInt64("sjdcbbcs", 0)
- if sjdcbbcs > 0 {
- queueConfig.Sjdcbbcs = sjdcbbcs
- }
-
- sjbbsy, _ := c.GetInt64("sjbbsy", 0)
- if sjbbsy > 0 {
- queueConfig.Sjbbsy = sjbbsy
- }
-
- sjjhyc, _ := c.GetInt64("sjjhyc", 0)
- queueConfig.Sjjhyc = sjjhyc
-
- txxqyxs, _ := c.GetInt64("txxqyxs", 0)
- queueConfig.Txxqyxs = txxqyxs
-
- txglsyxs, _ := c.GetInt64("txglsyxs", 0)
- queueConfig.Txglsyxs = txglsyxs
-
- queueConfig.UpdateTime = time.Now().Unix()
-
- service.UpDateQueueCallInfo(queueConfig)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "queue_config": queueConfig,
- })
- }
-
- func (c *DialysisApiController) PostPrescription() {
- patient, _ := c.GetInt64("patient_id", 0)
- recordDateStr := c.GetString("record_date")
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- mode_id, _ := c.GetInt64("mode_id", 0)
- dialysis_duration, _ := c.GetFloat("dialysis_duration", 0)
- dialyzer, _ := c.GetInt64("dialyzer", 0)
- dialyzerPerfusionApparatus := c.GetString("dialyzer_perfusion_apparatus")
- perfusion_apparatus, _ := c.GetInt64("perfusion_apparatus", 0)
- blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
- dewater_amount, _ := c.GetFloat("dewater_amount", 0)
- displace_liqui, _ := c.GetFloat("displace_liqui", 0)
- replacement_way, _ := c.GetInt64("replacement_way", 0)
- anticoagulant, _ := c.GetInt64("anticoagulant", 0)
- anticoagulant_shouji, _ := c.GetFloat("anticoagulant_shouji", 0)
- anticoagulant_weichi, _ := c.GetFloat("anticoagulant_weichi", 0)
- anticoagulant_zongliang, _ := c.GetFloat("anticoagulant_zongliang", 0)
- anticoagulant_gaimingcheng := c.GetString("anticoagulant_gaimingcheng")
- anticoagulant_gaijiliang := c.GetString("anticoagulant_gaijiliang")
- kalium, _ := c.GetFloat("kalium", 0)
- sodium, _ := c.GetFloat("sodium", 0)
- replacement_total, _ := c.GetFloat("replacement_total", 0)
-
- calcium, _ := c.GetFloat("calcium", 0)
- bicarbonate, _ := c.GetFloat("bicarbonate", 0)
- glucose, _ := c.GetFloat("glucose", 0)
- // dry_weight, _ := c.GetFloat("dry_weight", 0)
- dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
- dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
- conductivity, _ := c.GetFloat("conductivity", 0)
- remark := c.GetString("remark")
- dialysisDurationHour, _ := c.GetInt64("dialysis_duration_hour", 0)
- dialysisDurationMinute, _ := c.GetInt64("dialysis_duration_minute", 0)
- targetUltrafiltration, _ := c.GetFloat("target_ultrafiltration", 0)
- dialysateFormulation, _ := c.GetInt64("dialysate_formulation", 0)
- body_fluid, _ := c.GetInt64("body_fluid", 0)
- special_medicine, _ := c.GetInt64("special_medicine", 0)
- special_medicine_other := c.GetString("special_medicine_other")
- displace_liqui_part, _ := c.GetInt64("displace_liqui_part", 0)
- displace_liqui_value, _ := c.GetFloat("displace_liqui_value", 0)
- blood_access, _ := c.GetInt64("blood_access", 0)
- ultrafiltration, _ := c.GetFloat("ultrafiltration", 0)
- body_fluid_other := c.GetString("body_fluid_other")
- target_ktv, _ := c.GetFloat("target_ktv", 0)
-
- niprocart, _ := c.GetInt64("niprocart", 0)
- jms, _ := c.GetInt64("jms", 0)
- fistula_needle_set, _ := c.GetInt64("fistula_needle_set", 0)
- fistula_needle_set_16, _ := c.GetInt64("fistula_needle_set_16", 0)
- hemoperfusion, _ := c.GetInt64("hemoperfusion", 0)
- dialyser_sterilised, _ := c.GetInt64("dialyser_sterilised", 0)
- filtryzer, _ := c.GetInt64("filtryzer", 0)
-
- dialyzers, _ := c.GetInt64("dialyzers", 0)
- injector, _ := c.GetInt64("injector", 0)
- bloodlines, _ := c.GetInt64("bloodlines", 0)
- tubing_hemodialysis, _ := c.GetInt64("tubing_hemodialysis", 0)
- safe_package, _ := c.GetInt64("package", 0)
- a_liquid, _ := c.GetInt64("a_liquid", 0)
- preImpules, _ := c.GetFloat("pre_impulse", 0)
- fmt.Println("", preImpules)
-
- anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
- anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
-
- //heparin_sodium := c.GetString("heparin_sodium")
- //fmt.Println("肝素钠",heparin_sodium)
- //nucleoprotamine := c.GetString("nucleoprotamine")
- //fmt.Println("鱼精蛋白",nucleoprotamine)
- //push_the_protamine := c.GetString("push_the_protamine")
- //fmt.Println("下机前推注鱼精蛋白",push_the_protamine)
- // var prescription_doctor int64
- blood := c.GetString("blood")
- dialysis_dialyszers := c.GetString("dialysis_dialyszers")
-
- dialysis_irrigation := c.GetString("dialysis_irrigation")
- antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
- displace_speed := c.GetString("displace_speed")
- illness, _ := c.GetInt64("illness")
- amylaceum := c.GetString("amylaceum")
- single_time := c.GetString("single_time")
- single_water := c.GetString("single_water")
- replacement_flow := c.GetString("replacement_flow")
- plasma_separator := c.GetString("plasma_separator")
- bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
- oxygen_uptake, _ := c.GetInt64("oxygen_uptake")
- oxygen_flow := c.GetString("oxygen_flow")
- oxygen_time := c.GetString("oxygen_time")
-
- hemodialysis_pipelines := c.GetString("hemodialysis_pipelines")
- hemodialysis_pipelines_count, _ := c.GetFloat("hemodialysis_pipelines_count", 0)
-
- puncture_needle := c.GetString("puncture_needle")
- puncture_needle_count, _ := c.GetFloat("puncture_needle_count", 0)
-
- epo := c.GetString("epo")
- epo_count, _ := c.GetFloat("epo_count", 0)
- max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
- admin_user_id, _ := c.GetInt64("admin_user_id")
- is_water, _ := c.GetInt64("is_water")
- drhy_water := c.GetString("drhy_water")
- dry_water_hour := c.GetString("dry_water_hour")
- water_machine := c.GetString("water_machine")
- add_amount, _ := c.GetFloat("add_amount")
- reduce_amount, _ := c.GetFloat("reduce_amount")
- dialysis_remark := c.GetString("dialysis_remark")
- prescribing_number, _ := c.GetFloat("prescribing_number")
- treatment_remark := c.GetString("treatment_remark")
- prescription_sodium := c.GetString("prescription_sodium")
- start_sodium := c.GetString("start_sodium")
- sodium_curve := c.GetString("sodium_curve")
- dialysis_fluid_flow := c.GetString("dialysis_fluid_flow")
- sodium_bicarbonate_flow := c.GetString("sodium_bicarbonate_flow")
- prescription_water, _ := c.GetFloat("prescription_water")
- dialysis_strainer := c.GetString("dialysis_strainer")
- chaptalization := c.GetString("chaptalization")
- washing_time := c.GetString("washing_time")
- warsh_count := c.GetString("warsh_count")
- blood_access_part_id := c.GetString("blood_access_part_id")
- anticoagulant_weichi_hour := c.GetString("anticoagulant_weichi_hour")
- dialyzate := c.GetString("dialyzate")
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- //if template.TemplateId == 2 || template.TemplateId == 6 {
- // if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- goodList, _ := service.GetMobileGoodList(adminUserInfo.CurrentOrgId)
-
- var dialysis_dialyszers_id int64
- var dialysis_strainer_id int64
- var dialysis_irrigation_id int64
- if len(goodList) > 0 {
- for _, item := range goodList {
- if item.SpecificationName == dialysis_dialyszers {
- dialysis_dialyszers_id = item.ID
- }
- if item.SpecificationName == dialysis_irrigation {
- dialysis_irrigation_id = item.ID
- }
- if item.SpecificationName == dialysis_strainer {
- dialysis_strainer_id = item.ID
- }
- }
- }
-
- prescription := models.DialysisPrescription{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- RecordDate: recordDate.Unix(),
- ModeId: mode_id,
- DialysisDuration: dialysis_duration,
- Dialyzer: dialyzer,
- ReplacementTotal: replacement_total,
- PerfusionApparatus: perfusion_apparatus,
- BloodFlowVolume: blood_flow_volume,
- DewaterAmount: dewater_amount,
- DisplaceLiqui: displace_liqui,
- ReplacementWay: replacement_way,
- Anticoagulant: anticoagulant,
- AnticoagulantShouji: anticoagulant_shouji,
- AnticoagulantWeichi: anticoagulant_weichi,
- AnticoagulantZongliang: anticoagulant_zongliang,
- AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
- AnticoagulantGaijiliang: anticoagulant_gaijiliang,
- Kalium: kalium,
- Sodium: sodium,
- Calcium: calcium,
- Bicarbonate: bicarbonate,
- Glucose: glucose,
- // DryWeight: dry_weight,
- DialysateFlow: dialysate_flow,
- DialysateTemperature: dialysate_temperature,
- Conductivity: conductivity,
- Remark: remark,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DialysisDurationMinute: dialysisDurationMinute,
- DialysisDurationHour: dialysisDurationHour,
- TargetUltrafiltration: targetUltrafiltration,
- DialysateFormulation: dialysateFormulation,
- DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
- BodyFluid: body_fluid,
- SpecialMedicine: special_medicine,
- SpecialMedicineOther: special_medicine_other,
- DisplaceLiquiPart: displace_liqui_part,
- DisplaceLiquiValue: displace_liqui_value,
- BloodAccess: blood_access,
- Ultrafiltration: ultrafiltration,
- BodyFluidOther: body_fluid_other,
- TargetKtv: target_ktv,
- Niprocart: niprocart,
- Jms: jms,
- FistulaNeedleSet: fistula_needle_set,
- FistulaNeedleSet16: fistula_needle_set_16,
- Hemoperfusion: hemoperfusion,
- DialyserSterilised: dialyser_sterilised,
- Filtryzer: filtryzer,
- Dialyzers: dialyzers,
- Injector: injector,
- Bloodlines: bloodlines,
- TubingHemodialysis: tubing_hemodialysis,
- Package: safe_package,
- ALiquid: a_liquid,
- PreImpulse: preImpules,
- AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
- AnticoagulantStopTimeMin: anticoagulant_stop_time_min,
- Blood: blood,
- DialysisDialyszers: dialysis_dialyszers,
- DialysisIrrigation: dialysis_irrigation,
- AntioxidantCommodityName: antioxidant_commodity_name,
- DisplaceSpeed: displace_speed,
- Illness: illness,
- Amylaceum: amylaceum,
- SingleTime: single_time,
- SingleWater: single_water,
- ReplacementFlow: replacement_flow,
- PlasmaSeparator: plasma_separator,
- BilirubinAdsorptionColumn: bilirubin_adsorption_column,
- OxygenFlow: oxygen_flow,
- OxygenUptake: oxygen_uptake,
- OxygenTime: oxygen_time,
- HemodialysisPipelines: hemodialysis_pipelines,
- HemodialysisPipelinesCount: hemodialysis_pipelines_count,
- PunctureNeedle: puncture_needle,
- PunctureNeedleCount: puncture_needle_count,
- Epo: epo,
- EpoCount: epo_count,
- MaxUltrafiltrationRate: max_ultrafiltration_rate,
- AdminUserId: admin_user_id,
- IsWater: is_water,
- DrhyWater: drhy_water,
- DryWaterHour: dry_water_hour,
- WaterMachine: water_machine,
- AddAmount: add_amount,
- ReduceAmount: reduce_amount,
- DialysisRemark: dialysis_remark,
- PrescribingNumber: prescribing_number,
- TreatmentRemark: treatment_remark,
- PrescriptionSodium: prescription_sodium,
- StartSodium: start_sodium,
- SodiumCurve: sodium_curve,
- DialysisFluidFlow: dialysis_fluid_flow,
- SodiumBicarbonateFlow: sodium_bicarbonate_flow,
- PrescriptionWater: prescription_water,
- DialysisStrainer: dialysis_strainer,
- Chaptalization: chaptalization,
- WarshCount: warsh_count,
- WashingTime: washing_time,
- BloodAccessPartId: blood_access_part_id,
- AnticoagulantWeichiHour: anticoagulant_weichi_hour,
- Dialyzate: dialyzate,
- DialysisStrainerId: dialysis_strainer_id,
- DialysisIrrigationId: dialysis_irrigation_id,
- DialysisDialyszersId: dialysis_dialyszers_id,
- }
-
- if adminUserInfo.CurrentOrgId == 10721 {
- if prescription.ModeId == 2 {
- if prescription.ReplacementTotal == 0 {
- prescription.ReplacementTotal = 15
- }
-
- }
- }
-
- //长沙南雅医院,自动生成抗凝剂的临时处方
- if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 10340 {
- if prescribing_number == 0 {
- prescribing_number = 1
- }
- advice := models.DoctorAdvice{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- GroupNo: 0,
- AdviceType: 2,
- RecordDate: recordDate.Unix(),
- AdviceDate: recordDate.Unix(),
- StartTime: recordDate.Unix() + 6.5*60*60, // 根据排班班次,给默认时间
- AdviceName: "", // 根据抗凝剂转换为中文 + 首剂 + 维持 + 总量
- AdviceDesc: "",
- ReminderDate: 0,
- SingleDose: anticoagulant_zongliang,
- SingleDoseUnit: "iu",
- DrugSpec: 0,
- DrugSpecUnit: "",
- PrescribingNumber: prescribing_number, // 前端传过来的开药数量
- PrescribingNumberUnit: "支",
- DeliveryWay: "静脉注射",
- ExecutionFrequency: "上机前",
- AdviceDoctor: 0,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- IsPrescription: 1,
- ExecutionState: 2,
- StopState: 2,
- IsSettle: 2,
- }
- // 查询排班信息
- schedulePatient, _ := service.GetScheduleByPatient(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if schedulePatient.ID > 0 {
- if schedulePatient.ScheduleType == 1 {
- advice.StartTime = recordDate.Unix() + 6.5*60*60
- }
-
- if schedulePatient.ScheduleType == 2 {
- advice.StartTime = recordDate.Unix() + 9*60*60
- }
- }
- // 抗凝剂名称
- switch anticoagulant {
- case 1:
- advice.AdviceName = "无肝素"
- break
- case 2:
- advice.AdviceName = "普通肝素"
- break
- case 3:
- advice.AdviceName = "低分子肝素"
- break
- case 4:
- advice.AdviceName = "阿加曲班"
- break
- case 5:
- advice.AdviceName = "枸橼酸钠"
- break
- case 6:
- advice.AdviceName = "低分子肝素钙"
- break
- case 7:
- advice.AdviceName = "低分子肝素钠"
- break
- case 8:
- advice.AdviceName = "依诺肝素"
- break
- case 9:
- advice.AdviceName = "达肝素"
- break
- case 10:
- advice.AdviceName = "体外抗凝"
- break
- case 11:
- advice.AdviceName = "那曲肝素"
- break
- case 12:
- advice.AdviceName = "无抗凝剂"
- break
- }
- //advice.AdviceDesc = "首剂" + strconv.FormatFloat(anticoagulant_shouji, 'f', -1, 64) + "维持" + strconv.FormatFloat(anticoagulant_weichi, 'f', -1, 64) + "总量" + strconv.FormatFloat(anticoagulant_zongliang, 'f', -1, 64)
-
- if appRole.UserType == 2 || appRole.UserType == 1 || appRole.UserType == 3 {
- advice.AdviceDoctor = appRole.AdminUserId
- }
-
- // 患者的临时医嘱里查找是否有抗凝剂临时医嘱
- advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- if advicePrescription.ID > 0 && (anticoagulant == 3 || anticoagulant == 6 || anticoagulant == 7) {
- advice.AdviceName = "低分子肝素钠注射液"
- // 修改患者临时医嘱里的抗凝剂医嘱
- advice.ID = advicePrescription.ID
- service.UpdateDoctorAdviceById(advicePrescription.ID, prescribing_number, anticoagulant_zongliang)
- //service.UpdateDoctorAdvice(&advice)
- } else {
- if anticoagulant == 3 || anticoagulant == 6 || anticoagulant == 7 {
- advice.AdviceName = "低分子肝素钠注射液"
- // 新增患者临时医嘱里的抗凝剂医嘱
- service.CreateDoctorAdvice(&advice)
- }
-
- }
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
-
- }
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription.PrescriptionDoctor = appRole.AdminUserId
- }
-
- _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if dialysisPrescription.ID == 0 { //新增
- if mode_id > 0 {
- var str string
- //查找该机构用的是什么透析器
- filedConfig, _ := service.GetFiledConfig(adminUserInfo.CurrentOrgId)
- if filedConfig.ID > 0 {
- str = dialyzerPerfusionApparatus
- } else {
- str = dialysis_dialyszers + "/" + dialysis_irrigation + " " + dialysis_strainer
- }
-
- if adminUserInfo.CurrentOrgId == 10346 {
- service.ModifyScheduleModeOne(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
- } else {
- service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
- }
-
- }
-
- prescription.Creater = adminUserInfo.AdminUser.Id
-
- //针对河间咸得
- if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
-
- if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
-
- prescription.DisplaceLiquiPart = 0
- prescription.DisplaceLiquiValue = 0
- }
- }
- if adminUserInfo.CurrentOrgId == 10340 && prescription.AdminUserId == 0 {
- prescription.AdminUserId = adminUserInfo.AdminUser.Id
- }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 1)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- err := service.AddSigleRecord(&prescription)
-
- if adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10164 {
-
- monitorList, _ := service.GetMobilePatientMonitor(prescription.PatientId, prescription.RecordDate, prescription.UserOrgId)
-
- if len(monitorList) > 0 {
- var ultrafiltration_rate float64
- totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
-
- ultrafiltration_rate = (math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)) / 1000
- var replacement_rate float64
-
- //乘10 除10是为了保留一位小数
- replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*10) / 10
-
- var firstOpeateTime = monitorList[0].OperateTime
- for _, item := range monitorList {
- //超滤率
- service.ModifyDialysisPatientMonitor(item.ID, ultrafiltration_rate)
-
- //置换率
- service.ModifyDialysisPatientReplascementRate(item.ID, replacement_rate)
-
- //超滤量
- ultrafiltration_volume := math.Floor(float64(item.OperateTime-firstOpeateTime)/3600) * ultrafiltration_rate
- service.ModifyPatientUltrafiltrationVolume(item.ID, ultrafiltration_volume)
-
- //置换量
- displacement_quantity := (math.Floor(float64(item.OperateTime+3600-firstOpeateTime)/3600) * replacement_rate) * 60 / 1000
-
- service.ModifyPatientDisplacementQuantity(item.ID, displacement_quantity)
-
- }
- }
-
- }
- //记录日志
- byterequest, _ := json.Marshal(prescription)
- dialysisPrescriptionLog := models.XtDialysisPrescriptionLog{
-
- UserOrgId: adminUserInfo.CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: prescription.RecordDate,
- PatientId: prescription.PatientId,
- Source: "电脑端新建处方",
- Status: 1,
- }
- service.CreatePrescriptionLog(dialysisPrescriptionLog)
-
- //创建步骤表
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 1,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- if err == nil {
- updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
- if updateErr != nil {
- utils.ErrorLog("%v", updateErr)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "prescription": &prescription,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
-
- } else { //修改
- if mode_id > 0 {
-
- var str string
- //查找该机构用的是什么透析器
- filedConfig, _ := service.GetFiledConfig(adminUserInfo.CurrentOrgId)
- if filedConfig.ID > 0 {
- str = dialyzerPerfusionApparatus
- } else {
- str = dialysis_dialyszers + "/" + dialysis_irrigation
- }
- service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
- }
-
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
- //if template.TemplateId == 1 {
- // if dialysisPrescription.Creater > 0 && dialysisPrescription.Creater != adminUserInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription_doctor := adminUserInfo.AdminUser.Id
- prescription.PrescriptionDoctor = prescription_doctor
-
- }
-
- if dialysisPrescription.Creater == 0 { //体重称
- prescription.Creater = adminUserInfo.AdminUser.Id
-
- } else {
- prescription.Creater = dialysisPrescription.Creater
- if adminUserInfo.CurrentOrgId == 9882 {
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription_doctor := adminUserInfo.AdminUser.Id
- prescription.PrescriptionDoctor = prescription_doctor
- prescription.Creater = prescription_doctor
- }
- }
- }
-
- prescription.CreatedTime = dialysisPrescription.CreatedTime
- prescription.UpdatedTime = time.Now().Unix()
- prescription.Modifier = adminUserInfo.AdminUser.Id
- prescription.ID = dialysisPrescription.ID
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 1)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- if adminUserInfo.CurrentOrgId == 10721 {
- if prescription.ModeId == 2 {
- if prescription.ReplacementTotal == 0 {
- prescription.ReplacementTotal = 15
- }
-
- }
- }
-
- updateErr := service.UpDateDialysisPrescription(&prescription)
-
- if adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10164 {
-
- monitorList, _ := service.GetMobilePatientMonitor(prescription.PatientId, prescription.RecordDate, prescription.UserOrgId)
-
- if len(monitorList) > 0 {
- var ultrafiltration_rate float64
- totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
-
- ultrafiltration_rate = (math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)) / 1000
- var replacement_rate float64
-
- //乘10 除10是为了保留一位小数
- replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*10) / 10
-
- var firstOpeateTime = monitorList[0].OperateTime
- for _, item := range monitorList {
- //超滤率
- service.ModifyDialysisPatientMonitor(item.ID, ultrafiltration_rate)
-
- //置换率
- service.ModifyDialysisPatientReplascementRate(item.ID, replacement_rate)
-
- //超滤量
- ultrafiltration_volume := math.Floor(float64(item.OperateTime-firstOpeateTime)/3600) * ultrafiltration_rate
- service.ModifyPatientUltrafiltrationVolume(item.ID, ultrafiltration_volume)
-
- //置换量
- displacement_quantity := (math.Floor(float64(item.OperateTime+3600-firstOpeateTime)/3600) * replacement_rate) * 60 / 1000
-
- service.ModifyPatientDisplacementQuantity(item.ID, displacement_quantity)
-
- }
- }
-
- }
-
- //记录日志
- byterequest, _ := json.Marshal(prescription)
- dialysisPrescriptionLog := models.XtDialysisPrescriptionLog{
-
- UserOrgId: adminUserInfo.CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: prescription.RecordDate,
- PatientId: prescription.PatientId,
- Source: "电脑端修改处方",
- Status: 1,
- }
- service.CreatePrescriptionLog(dialysisPrescriptionLog)
-
- //创建步骤表
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 1,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
- //修改处方
- if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 10340 {
- // 患者的临时医嘱里查找是否有抗凝剂临时医嘱
- advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- if advicePrescription.ID > 0 {
-
- service.UpdateDoctorAdvieByIdOne(advicePrescription.ID, prescribing_number, anticoagulant_zongliang)
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
- redis := service.RedisClient()
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
- }
- }
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyThree, "", time.Second)
- if updateErr == nil {
- updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
- if updateErr != nil {
- utils.ErrorLog("%v", updateErr)
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "prescription": &prescription,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- }
-
- }
- func (c *DialysisApiController) PostSoulution() {
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- mode_id, _ := c.GetInt64("mode_id", 0)
- dialysis_duration, _ := c.GetFloat("dialysis_duration", 0)
- dialyzer, _ := c.GetInt64("dialyzer", 0)
- perfusion_apparatus, _ := c.GetInt64("perfusion_apparatus", 0)
- blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
- replacement_total, _ := c.GetFloat("replacement_total", 0)
- dialyzerPerfusionApparatus := c.GetString("dialyzer_perfusion_apparatus")
-
- dewater_amount, _ := c.GetFloat("dewater_amount", 0)
- displace_liqui, _ := c.GetFloat("displace_liqui", 0)
- replacement_way, _ := c.GetInt64("replacement_way", 0)
- anticoagulant, _ := c.GetInt64("anticoagulant", 0)
- anticoagulant_shouji, _ := c.GetFloat("anticoagulant_shouji", 0)
- anticoagulant_weichi, _ := c.GetFloat("anticoagulant_weichi", 0)
- anticoagulant_zongliang, _ := c.GetFloat("anticoagulant_zongliang", 0)
- anticoagulant_gaimingcheng := c.GetString("anticoagulant_gaimingcheng")
- anticoagulant_gaijiliang := c.GetString("anticoagulant_gaijiliang")
- kalium, _ := c.GetFloat("kalium", 0)
- sodium, _ := c.GetFloat("sodium", 0)
- calcium, _ := c.GetFloat("calcium", 0)
- bicarbonate, _ := c.GetFloat("bicarbonate", 0)
- glucose, _ := c.GetFloat("glucose", 0)
- // dry_weight, _ := c.GetFloat("dry_weight", 0)
- dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
- dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
- conductivity, _ := c.GetFloat("conductivity", 0)
- remark := c.GetString("remark")
- dialysisDurationHour, _ := c.GetInt64("dialysis_duration_hour", 0)
- dialysisDurationMinute, _ := c.GetInt64("dialysis_duration_minute", 0)
- targetUltrafiltration, _ := c.GetFloat("target_ultrafiltration", 0)
- dialysateFormulation, _ := c.GetInt64("dialysate_formulation", 0)
- body_fluid, _ := c.GetInt64("body_fluid", 0)
- special_medicine, _ := c.GetInt64("special_medicine", 0)
- special_medicine_other := c.GetString("special_medicine_other")
- displace_liqui_part, _ := c.GetInt64("displace_liqui_part", 0)
- displace_liqui_value, _ := c.GetFloat("displace_liqui_value", 0)
- blood_access, _ := c.GetInt64("blood_access", 0)
- ultrafiltration, _ := c.GetFloat("ultrafiltration", 0)
- body_fluid_other := c.GetString("body_fluid_other")
- target_ktv, _ := c.GetFloat("target_ktv", 0)
-
- niprocart, _ := c.GetInt64("niprocart", 0)
- jms, _ := c.GetInt64("jms", 0)
- fistula_needle_set, _ := c.GetInt64("fistula_needle_set", 0)
- fistula_needle_set_16, _ := c.GetInt64("fistula_needle_set_16", 0)
- hemoperfusion, _ := c.GetInt64("hemoperfusion", 0)
- dialyser_sterilised, _ := c.GetInt64("dialyser_sterilised", 0)
- filtryzer, _ := c.GetInt64("filtryzer", 0)
-
- dialyzers, _ := c.GetInt64("dialyzers", 0)
- injector, _ := c.GetInt64("injector", 0)
- bloodlines, _ := c.GetInt64("bloodlines", 0)
- tubing_hemodialysis, _ := c.GetInt64("tubing_hemodialysis", 0)
- safe_package, _ := c.GetInt64("package", 0)
- a_liquid, _ := c.GetInt64("a_liquid", 0)
-
- anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
- anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
- blood := c.GetString("blood")
- dialysis_dialyszers := c.GetString("dialysis_dialyszers")
- dialysis_irrigation := c.GetString("dialysis_irrigation")
- antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
- displace_speed := c.GetString("displace_speed")
- illness, _ := c.GetInt64("illness")
- amylaceum := c.GetString("amylaceum")
- single_time := c.GetString("single_time")
- single_water := c.GetString("single_water")
- replacement_flow := c.GetString("replacement_flow")
- plasma_separator := c.GetString("plasma_separator")
- bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
- oxygen_uptake, _ := c.GetInt64("oxygen_uptake")
- oxygen_flow := c.GetString("oxygen_flow")
- oxygen_time := c.GetString("oxygen_time")
-
- hemodialysis_pipelines := c.GetString("hemodialysis_pipelines")
- hemodialysis_pipelines_count, _ := c.GetFloat("hemodialysis_pipelines_count", 0)
-
- puncture_needle := c.GetString("puncture_needle")
- puncture_needle_count, _ := c.GetFloat("puncture_needle_count", 0)
-
- epo := c.GetString("epo")
- epo_count, _ := c.GetFloat("epo_count", 0)
- max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
- impulse := c.GetString("impulse")
- preImpules, parseDateErr := strconv.ParseFloat(impulse, 64)
- admin_user_id, _ := c.GetInt64("admin_user_id")
- fmt.Println("", preImpules)
- is_water, _ := c.GetInt64("is_water")
- dry_water_hour := c.GetString("dry_water_hour")
- drhy_water := c.GetString("drhy_water")
- water_machine := c.GetString("water_machine")
- add_amount, _ := c.GetFloat("add_amount")
- reduce_amount, _ := c.GetFloat("reduce_amount")
- dialysis_remark := c.GetString("dialysis_remark")
- prescribing_number, _ := c.GetFloat("prescribing_number")
- treatment_remark := c.GetString("treatment_remark")
- prescription_sodium := c.GetString("prescription_sodium")
- start_sodium := c.GetString("start_sodium")
- sodium_curve := c.GetString("sodium_curve")
- dialysis_fluid_flow := c.GetString("dialysis_fluid_flow")
- sodium_bicarbonate_flow := c.GetString("sodium_bicarbonate_flow")
- prescription_water, _ := c.GetFloat("prescription_water")
- dialysis_strainer := c.GetString("dialysis_strainer")
- chaptalization := c.GetString("chaptalization")
- warsh_count := c.GetString("warsh_count")
- washing_time := c.GetString("washing_time")
- blood_access_part_id := c.GetString("blood_access_part_id")
- anticoagulant_weichi_hour := c.GetString("anticoagulant_weichi_hour")
- dialyzate := c.GetString("dialyzate")
- var prescription_doctor int64
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription_doctor = appRole.AdminUserId
- }
-
- if mode_id > 0 {
- var str string
- //查找该机构用的是什么透析器
- filedConfig, _ := service.GetFiledConfig(adminUserInfo.CurrentOrgId)
- if filedConfig.ID > 0 {
- str = dialyzerPerfusionApparatus
- } else {
- str = dialysis_dialyszers + "/" + dialysis_irrigation + " " + dialysis_strainer
-
- }
- if adminUserInfo.CurrentOrgId == 10346 {
- service.ModifyScheduleModeOne(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
- } else {
- service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, str)
- }
-
- }
-
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
- //
- //if template.TemplateId == 2 || template.TemplateId == 6 {
- // if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 1)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- goodList, _ := service.GetMobileGoodList(adminUserInfo.CurrentOrgId)
-
- var dialysis_dialyszers_id int64
- var dialysis_strainer_id int64
- var dialysis_irrigation_id int64
- if len(goodList) > 0 {
- for _, item := range goodList {
- if item.SpecificationName == dialysis_dialyszers {
- dialysis_dialyszers_id = item.ID
- }
- if item.SpecificationName == dialysis_irrigation {
- dialysis_irrigation_id = item.ID
- }
- if item.SpecificationName == dialysis_strainer {
- dialysis_strainer_id = item.ID
- }
- }
- }
-
- prescription := models.DialysisPrescription{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- RecordDate: recordDate.Unix(),
- ModeId: mode_id,
- DialysisDuration: dialysis_duration,
- Dialyzer: dialyzer,
- PerfusionApparatus: perfusion_apparatus,
- BloodFlowVolume: blood_flow_volume,
- DewaterAmount: dewater_amount,
- DisplaceLiqui: displace_liqui,
- ReplacementWay: replacement_way,
- Anticoagulant: anticoagulant,
- AnticoagulantShouji: anticoagulant_shouji,
- AnticoagulantWeichi: anticoagulant_weichi,
- AnticoagulantZongliang: anticoagulant_zongliang,
- AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
- AnticoagulantGaijiliang: anticoagulant_gaijiliang,
- Kalium: kalium,
- Sodium: sodium,
- Calcium: calcium,
- Bicarbonate: bicarbonate,
- Glucose: glucose,
- // DryWeight: dry_weight,
- DialysateFlow: dialysate_flow,
- DialysateTemperature: dialysate_temperature,
- Conductivity: conductivity,
- Remark: remark,
- PrescriptionDoctor: prescription_doctor,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DialysisDurationMinute: dialysisDurationMinute,
- DialysisDurationHour: dialysisDurationHour,
- TargetUltrafiltration: targetUltrafiltration,
- DialysateFormulation: dialysateFormulation,
- ReplacementTotal: replacement_total,
- DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
- BodyFluid: body_fluid,
- SpecialMedicine: special_medicine,
- SpecialMedicineOther: special_medicine_other,
- DisplaceLiquiPart: displace_liqui_part,
- DisplaceLiquiValue: displace_liqui_value,
- BloodAccess: blood_access,
- Ultrafiltration: ultrafiltration,
- BodyFluidOther: body_fluid_other,
- TargetKtv: target_ktv,
- Niprocart: niprocart,
- Jms: jms,
- FistulaNeedleSet: fistula_needle_set,
- FistulaNeedleSet16: fistula_needle_set_16,
- Hemoperfusion: hemoperfusion,
- DialyserSterilised: dialyser_sterilised,
- Filtryzer: filtryzer,
- Dialyzers: dialyzers,
- Injector: injector,
- Bloodlines: bloodlines,
- TubingHemodialysis: tubing_hemodialysis,
- Package: safe_package,
- ALiquid: a_liquid,
-
- AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
- AnticoagulantStopTimeMin: anticoagulant_stop_time_min,
- Blood: blood,
- DialysisIrrigation: dialysis_irrigation,
- DialysisDialyszers: dialysis_dialyszers,
- AntioxidantCommodityName: antioxidant_commodity_name,
- DisplaceSpeed: displace_speed,
- Illness: illness,
- Amylaceum: amylaceum,
- SingleTime: single_time,
- SingleWater: single_water,
- ReplacementFlow: replacement_flow,
- PlasmaSeparator: plasma_separator,
- BilirubinAdsorptionColumn: bilirubin_adsorption_column,
- OxygenTime: oxygen_time,
- OxygenUptake: oxygen_uptake,
- OxygenFlow: oxygen_flow,
- HemodialysisPipelines: hemodialysis_pipelines,
- HemodialysisPipelinesCount: hemodialysis_pipelines_count,
- PunctureNeedle: puncture_needle,
- PunctureNeedleCount: puncture_needle_count,
- Epo: epo,
- EpoCount: epo_count,
- MaxUltrafiltrationRate: max_ultrafiltration_rate,
- PreImpulse: preImpules,
- AdminUserId: admin_user_id,
- IsWater: is_water,
- DryWaterHour: dry_water_hour,
- DrhyWater: drhy_water,
- WaterMachine: water_machine,
- AddAmount: add_amount,
- ReduceAmount: reduce_amount,
- DialysisRemark: dialysis_remark,
- PrescribingNumber: prescribing_number,
- StartSodium: start_sodium,
- PrescriptionSodium: prescription_sodium,
- SodiumCurve: sodium_curve,
- TreatmentRemark: treatment_remark,
- DialysisFluidFlow: dialysis_fluid_flow,
- SodiumBicarbonateFlow: sodium_bicarbonate_flow,
- PrescriptionWater: prescription_water,
- DialysisStrainer: dialysis_strainer,
- Chaptalization: chaptalization,
- WarshCount: warsh_count,
- WashingTime: washing_time,
- BloodAccessPartId: blood_access_part_id,
- AnticoagulantWeichiHour: anticoagulant_weichi_hour,
- Dialyzate: dialyzate,
- DialysisDialyszersId: dialysis_dialyszers_id,
- DialysisIrrigationId: dialysis_irrigation_id,
- DialysisStrainerId: dialysis_strainer_id,
- }
-
- if prescription.Anticoagulant == 0 {
- prescription.Anticoagulant = 3
- }
- //查询最近透析准备表里是否存在 透析器 灌流器
-
- //splitStr := strings.Split(dialysis_dialyszers, ",")
- //
- //splitIrrigation := strings.Split(dialysis_irrigation, ",")
- //
- //mation, _ := service.GetGoodInfoMation(adminUserInfo.CurrentOrgId)
- //if len(mation)>0{
- // for _, item := range splitStr {
- // for _,it := range mation{
- // if(item == it.SpecificationName){
- //
- // //查询最近一次的透析器
- // _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
- //
- // if errcode == gorm.ErrRecordNotFound{
- // //插入数据
- // prepare := models.DialysisBeforePrepare{
- // UserOrgId: adminUserInfo.CurrentOrgId,
- // PatientId: patient,
- // RecordDate: recordDate.Unix(),
- // GoodTypeId: it.GoodTypeId,
- // GoodId: it.ID,
- // Count: 1,
- // Ctime: time.Now().Unix(),
- // Creater: adminUserInfo.AdminUser.Id,
- // Status:1,
- //
- // }
- // errcode := service.CreateDialysisBeforePrepareOne(&prepare)
- // fmt.Println("",errcode)
- // }
- // }
- // }
- //
- // }
- //
- // for _, item := range splitIrrigation {
- // for _,it := range mation{
- // if(item == it.SpecificationName){
- // //查询最近一次的透析器
- // _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
- // if errcode == gorm.ErrRecordNotFound{
- // //插入数据
- // prepare := models.DialysisBeforePrepare{
- // UserOrgId: adminUserInfo.CurrentOrgId,
- // PatientId: patient,
- // RecordDate: recordDate.Unix(),
- // GoodTypeId: it.GoodTypeId,
- // GoodId: it.ID,
- // Count: 1,
- // Ctime: time.Now().Unix(),
- // Creater: adminUserInfo.AdminUser.Id,
- // Status:1,
- //
- // }
- // errcode := service.CreateDialysisBeforePrepareOne(&prepare)
- // fmt.Println(errcode)
- // }
- // }
- // }
- // }
- //}
-
- //创建步骤表
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 1,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
-
- _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if dialysisPrescription.ID == 0 { //新增
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- }
-
- prescription.Creater = adminUserInfo.AdminUser.Id
-
- } else { //修改
-
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
- //if template.TemplateId == 1 {
- // if dialysisPrescription.Creater != adminUserInfo.AdminUser.Id && dialysisPrescription.Creater != 0 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription_doctor := adminUserInfo.AdminUser.Id
- prescription.PrescriptionDoctor = prescription_doctor
- } else {
- prescription.PrescriptionDoctor = dialysisPrescription.PrescriptionDoctor
- }
-
- if dialysisPrescription.Creater == 0 {
- prescription.Creater = adminUserInfo.AdminUser.Id
- } else {
- prescription.Creater = dialysisPrescription.Creater
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- prescription.Creater = adminUserInfo.AdminUser.Id
- }
- }
-
- prescription.CreatedTime = dialysisPrescription.CreatedTime
- prescription.UpdatedTime = time.Now().Unix()
- prescription.Modifier = adminUserInfo.AdminUser.Id
-
- prescription.ID = dialysisPrescription.ID
-
- }
-
- solution := models.DialysisSolution{
- RegistrarsId: adminUserInfo.AdminUser.Id,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Doctor: prescription_doctor,
- PatientId: patient,
- ModeId: mode_id,
- DialysisDuration: dialysis_duration,
- PerfusionApparatus: perfusion_apparatus,
- BloodFlowVolume: blood_flow_volume,
- Dewater: dewater_amount,
- DisplaceLiqui: displace_liqui,
- ReplacementWay: replacement_way,
- Anticoagulant: anticoagulant,
- AnticoagulantShouji: anticoagulant_shouji,
- AnticoagulantWeichi: anticoagulant_weichi,
- AnticoagulantZongliang: anticoagulant_zongliang,
- AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
- AnticoagulantGaijiliang: anticoagulant_gaijiliang,
- Kalium: kalium,
- Sodium: sodium,
- Calcium: calcium,
- Bicarbonate: bicarbonate,
- Glucose: glucose,
- // DryWeight: dry_weight,
- DialysateFlow: dialysate_flow,
- DialysateTemperature: dialysate_temperature,
- Conductivity: conductivity,
- Remark: remark,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DialysisDurationMinute: dialysisDurationMinute,
- DialysisDurationHour: dialysisDurationHour,
- TargetUltrafiltration: targetUltrafiltration,
- DialysateFormulation: dialysateFormulation,
- DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
- BodyFluid: body_fluid,
- SpecialMedicine: special_medicine,
- SpecialMedicineOther: special_medicine_other,
- DisplaceLiquiPart: displace_liqui_part,
- DisplaceLiquiValue: displace_liqui_value,
- BloodAccess: blood_access,
- Ultrafiltration: ultrafiltration,
- BodyFluidOther: body_fluid_other,
- ReplacementTotal: replacement_total,
- TargetKtv: target_ktv,
- DialysisIrrigation: dialysis_irrigation,
- DialysisDialyszers: dialysis_dialyszers,
- HemodialysisPipelines: hemodialysis_pipelines,
- HemodialysisPipelinesCount: hemodialysis_pipelines_count,
- PunctureNeedle: puncture_needle,
- PunctureNeedleCount: puncture_needle_count,
- Epo: epo,
- EpoCount: epo_count,
- MaxUltrafiltrationRate: max_ultrafiltration_rate,
- OxygenUptake: oxygen_uptake,
- OxygenFlow: oxygen_flow,
- OxygenTime: oxygen_time,
- PreImpulse: preImpules,
- SolutionStatus: 1,
- DialysisRemark: dialysis_remark,
- PrescribingNumber: prescribing_number,
- StartSodium: start_sodium,
- PrescriptionSodium: prescription_sodium,
- SodiumCurve: sodium_curve,
- TreatmentRemark: treatment_remark,
- DialysisFluidFlow: dialysis_fluid_flow,
- SodiumBicarbonateFlow: sodium_bicarbonate_flow,
- PrescriptionWater: prescribing_number,
- DialysisStrainer: dialysis_strainer,
- Chaptalization: chaptalization,
- WarshCount: warsh_count,
- WashingTime: washing_time,
- BloodAccessPartId: blood_access_part_id,
- AnticoagulantWeichiHour: anticoagulant_weichi_hour,
- Dialyzate: dialyzate,
- DialysisDialyszersId: dialysis_dialyszers_id,
- DialysisIrrigationId: dialysis_irrigation_id,
- DialysisStrainerId: dialysis_strainer_id,
- }
-
- if solution.Anticoagulant == 0 {
- solution.Anticoagulant = 3
- }
- //针对河间咸得
- if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
-
- if prescription.ModeId != 2 && prescription.ModeId != 5 && prescription.ModeId != 12 {
-
- prescription.DisplaceLiquiPart = 0
- prescription.DisplaceLiquiValue = 0
- }
- }
-
- if adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10090 || adminUserInfo.CurrentOrgId == 3877 {
-
- if solution.ModeId != 2 && solution.ModeId != 5 && solution.ModeId != 12 {
-
- solution.DisplaceLiquiPart = 0
- solution.DisplaceLiquiValue = 0
- }
- }
-
- if adminUserInfo.CurrentOrgId == 10340 && prescription.AdminUserId == 0 {
- prescription.AdminUserId = adminUserInfo.AdminUser.Id
- }
-
- if adminUserInfo.CurrentOrgId == 10721 {
- if prescription.ModeId == 2 {
- if prescription.ReplacementTotal == 0 {
- prescription.ReplacementTotal = 15
- }
-
- }
- }
-
- err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
-
- if adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10164 {
-
- monitorList, _ := service.GetMobilePatientMonitor(prescription.PatientId, prescription.RecordDate, prescription.UserOrgId)
-
- if len(monitorList) > 0 {
- var ultrafiltration_rate float64
- totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
-
- ultrafiltration_rate = (math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)) / 1000
- var replacement_rate float64
-
- //乘10 除10是为了保留一位小数
- replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*10) / 10
-
- var firstOpeateTime = monitorList[0].OperateTime
- for _, item := range monitorList {
- //超滤率
- service.ModifyDialysisPatientMonitor(item.ID, ultrafiltration_rate)
-
- //置换率
- service.ModifyDialysisPatientReplascementRate(item.ID, replacement_rate)
-
- //超滤量
- ultrafiltration_volume := math.Floor(float64(item.OperateTime-firstOpeateTime)/3600) * ultrafiltration_rate
- service.ModifyPatientUltrafiltrationVolume(item.ID, ultrafiltration_volume)
-
- //置换量
- displacement_quantity := (math.Floor(float64(item.OperateTime+3600-firstOpeateTime)/3600) * replacement_rate) * 60 / 1000
-
- service.ModifyPatientDisplacementQuantity(item.ID, displacement_quantity)
-
- }
- }
-
- }
- //记录日志
- byterequest, _ := json.Marshal(prescription)
- dialysisPrescriptionLog := models.XtDialysisPrescriptionLog{
-
- UserOrgId: adminUserInfo.CurrentOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: prescription.RecordDate,
- PatientId: prescription.PatientId,
- Source: "电脑端新增长期处方",
- Status: 1,
- }
- service.CreatePrescriptionLog(dialysisPrescriptionLog)
-
- //创建步骤表
- finishOne := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 1,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinishOne, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 1, patient)
- if dialysisFinishOne.ID == 0 {
- service.CreateDialysisFinish(finishOne)
- }
- //获取最新1条
- dialysisSolution, _ := service.GetLastPatientDialysisSolution(patient, adminUserInfo.CurrentOrgId)
-
- //更新状态
- service.UpdateDialysisSolutionStatusTwo(dialysisSolution.ID, dialysisSolution.ModeId, dialysisSolution.UserOrgId, dialysisSolution.PatientId)
-
- //长沙南雅医院,自动生成抗凝剂的临时处方
- if adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 10340 {
- if prescribing_number == 0 {
- prescribing_number = 1
- }
- advice := models.DoctorAdvice{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- GroupNo: 0,
- AdviceType: 2,
- RecordDate: recordDate.Unix(),
- AdviceDate: recordDate.Unix(),
- StartTime: recordDate.Unix() + 6.5*60*60, // 根据排班班次,给默认时间
- AdviceName: "", // 根据抗凝剂转换为中文 + 首剂 + 维持 + 总量
- AdviceDesc: "",
- ReminderDate: 0,
- SingleDose: anticoagulant_zongliang,
- SingleDoseUnit: "iu",
- DrugSpec: 0,
- DrugSpecUnit: "",
- PrescribingNumber: prescribing_number, // 前端传过来的开药数量
- PrescribingNumberUnit: "支",
- DeliveryWay: "静脉注射",
- ExecutionFrequency: "上机前",
- AdviceDoctor: 0,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- IsPrescription: 1,
- ExecutionState: 2,
- StopState: 2,
- IsSettle: 2,
- }
- // 查询排班信息
- schedulePatient, _ := service.GetScheduleByPatient(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if schedulePatient.ID > 0 {
- if schedulePatient.ScheduleType == 1 {
- advice.StartTime = recordDate.Unix() + 6.5*60*60
- }
-
- if schedulePatient.ScheduleType == 2 {
- advice.StartTime = recordDate.Unix() + 9*60*60
- }
- }
- // 抗凝剂名称
- switch anticoagulant {
- case 1:
- advice.AdviceName = "无肝素"
- break
- case 2:
- advice.AdviceName = "普通肝素"
- break
- case 3:
- advice.AdviceName = "低分子肝素"
- break
- case 4:
- advice.AdviceName = "阿加曲班"
- break
- case 5:
- advice.AdviceName = "枸橼酸钠"
- break
- case 6:
- advice.AdviceName = "低分子肝素钙"
- break
- case 7:
- advice.AdviceName = "低分子肝素钠"
- break
- case 8:
- advice.AdviceName = "依诺肝素"
- break
- case 9:
- advice.AdviceName = "达肝素"
- break
- case 10:
- advice.AdviceName = "体外抗凝"
- break
- case 11:
- advice.AdviceName = "那曲肝素"
- break
- case 12:
- advice.AdviceName = "无抗凝剂"
- break
- }
- //advice.AdviceDesc = "首剂" + strconv.FormatFloat(anticoagulant_shouji, 'f', -1, 64) + "维持" + strconv.FormatFloat(anticoagulant_weichi, 'f', -1, 64) + "总量" + strconv.FormatFloat(anticoagulant_zongliang, 'f', -1, 64)
- if appRole.UserType == 2 || appRole.UserType == 1 || appRole.UserType == 3 {
- advice.AdviceDoctor = appRole.AdminUserId
- }
-
- // 患者的临时医嘱里查找是否有抗凝剂临时医嘱
- advicePrescription, _ := service.GetAdvicesByPrescription(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
-
- if advicePrescription.ID > 0 && (anticoagulant == 3 || anticoagulant == 6 || anticoagulant == 7) {
- advice.AdviceName = "低分子肝素钠注射液"
- // 修改患者临时医嘱里的抗凝剂医嘱
- advice.ID = advicePrescription.ID
- service.UpdateDoctorAdviceById(advicePrescription.ID, prescribing_number, anticoagulant_zongliang)
- } else {
- // 新增患者临时医嘱里的抗凝剂医嘱
- if anticoagulant == 3 || anticoagulant == 6 || anticoagulant == 7 {
- advice.AdviceName = "低分子肝素钠注射液"
- service.CreateDoctorAdvice(&advice)
- }
-
- }
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":advice_list_all"
- redis.Set(keyOne, "", time.Second)
-
- }
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_solution"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
- redis.Set(keyTwo, "", time.Second)
-
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "solution": &solution,
- "prescription": &prescription,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- }
- func (c *DialysisApiController) PostDouleCheck() {
-
- id, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
- checkTimeStr := c.GetString("check_time")
- firstCheckTimeStr := c.GetString("first_check_time")
- creater, _ := c.GetInt64("creater", 0)
- modifier, _ := c.GetInt64("modifier", 0)
-
- dialysis_item_check, _ := c.GetInt64("dialysis_item_check", 0)
- dialysis_parameter_check, _ := c.GetInt64("dialysis_parameter_check", 0)
- vascular_access_verification, _ := c.GetInt64("vascular_access_verification", 0)
- pipeline_connection_check, _ := c.GetInt64("pipeline_connection_check", 0)
- dialysis_item_desc := c.GetString("dialysis_item_desc")
- dialysis_parameter_desc := c.GetString("dialysis_parameter_desc")
- vascular_access_desc := c.GetString("vascular_access_desc")
- pipeline_connection_desc := c.GetString("pipeline_connection_desc")
- collator, _ := c.GetInt64("collator", 0)
- employee_number := c.GetString("employee_number")
- dialyzer_batch_number := c.GetString("dialyzer_batch_number")
- needle_batch_number := c.GetString("needle_batch_number")
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- var checkDate int64
-
- if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 9675 || adminUserInfo.CurrentOrgId == 10340 {
- list, _ := service.GetRoleList(adminUserInfo.CurrentOrgId, modifier)
-
- if employee_number != list.JobNumber {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorEmployeeNumber)
- return
- }
- }
-
- if len(checkTimeStr) == 0 {
- //checkTimeStr = time.Now().Format("2006-01-02 15:04")
- checkDate = 0
- } else {
- checkDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", checkTimeStr)
- checkDate = checkDateUnix.Unix()
- }
-
- var firstCheckTimeDate int64
-
- if len(firstCheckTimeStr) == 0 {
- //firstCheckTimeStr = time.Now().Format("2006-01-02 15:04")
- firstCheckTimeDate = 0
- } else {
- firstCheckTimeDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", firstCheckTimeStr)
-
- firstCheckTimeDate = firstCheckTimeDateUnix.Unix()
-
- }
-
- doubleCheck := models.DoubleCheck{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: id,
- DialysisItemCheck: dialysis_item_check,
- DialysisParameterCheck: dialysis_parameter_check,
- VascularAccessVerification: vascular_access_verification,
- PipelineConnectionCheck: pipeline_connection_check,
- DialysisItemDesc: dialysis_item_desc,
- DialysisParameterDesc: dialysis_parameter_desc,
- VascularAccessDesc: vascular_access_desc,
- PipelineConnectionDesc: pipeline_connection_desc,
- Collator: collator,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- CheckDate: recordDate.Unix(),
- EmployeeNumber: employee_number,
- DialyzerBatchNumber: dialyzer_batch_number,
- NeedleBatchNumber: needle_batch_number,
- }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId, 5)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- _, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if check.ID == 0 { //新增
- doubleCheck.FirstCheckTime = firstCheckTimeDate
- doubleCheck.CheckTime = checkDate
- doubleCheck.Creater = creater
- doubleCheck.Modifier = modifier
-
- err := service.AddSigleDoubleCheck(&doubleCheck)
- //创建步骤表
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 5,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: id,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 5, id)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId, 5)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- //针对溪康
- if adminUserInfo.CurrentOrgId == 10721 {
-
- adviceInfoList, _ := service.GetHisDoctorAdviceList(adminUserInfo.CurrentOrgId, id, recordDate.Unix())
- if len(adviceInfoList) > 0 {
- for _, item := range adviceInfoList {
-
- service.UpdateHisAdviceList(item.ID, creater)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- theTime := time.Now()
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyFour, "", time.Second)
- defer redis.Close()
- }
- }
-
- adviceList, _ := service.GetMobileDoctorAdviceList(adminUserInfo.CurrentOrgId, id, recordDate.Unix())
- if len(adviceList) > 0 {
- for _, item := range adviceList {
- service.UpdateAdviceList(item.ID, creater)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- theTime := time.Now()
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyFour, "", time.Second)
- defer redis.Close()
- }
- }
- }
-
- redis := service.RedisClient()
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
-
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
-
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "doubleCheck": doubleCheck,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
- } else { //修改
- doubleCheck.FirstCheckTime = firstCheckTimeDate
- doubleCheck.CheckTime = checkDate
- doubleCheck.Creater = creater
- doubleCheck.Modifier = modifier
- doubleCheck.CreatedTime = check.CreatedTime
- doubleCheck.UpdatedTime = time.Now().Unix()
- doubleCheck.ID = check.ID
-
- redis := service.RedisClient()
- err := service.UpdateDoubleCheck(&doubleCheck)
-
- //针对溪康
- if adminUserInfo.CurrentOrgId == 10721 {
-
- adviceInfoList, _ := service.GetHisDoctorAdviceList(adminUserInfo.CurrentOrgId, id, recordDate.Unix())
- if len(adviceInfoList) > 0 {
- for _, item := range adviceInfoList {
-
- service.UpdateHisAdviceList(item.ID, creater)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- theTime := time.Now()
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyFour, "", time.Second)
- defer redis.Close()
- }
- }
-
- adviceList, _ := service.GetMobileDoctorAdviceList(adminUserInfo.CurrentOrgId, id, recordDate.Unix())
- if len(adviceList) > 0 {
- for _, item := range adviceList {
- service.UpdateAdviceList(item.ID, creater)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- theTime := time.Now()
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyFour, "", time.Second)
- defer redis.Close()
- }
- }
- }
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":double_check"
-
- keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyTwo, "", time.Second)
-
- //清空key 值
- redis.Set(key, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + ":prescriptions_list_all"
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "doubleCheck": doubleCheck,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- }
-
- }
- func (c *DialysisApiController) PostReceiveTreatmentAsses() {
- id, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
- way, _ := c.GetInt64("way", 0)
- consciousness, _ := c.GetInt64("consciousness", 0)
- appetite, _ := c.GetInt64("appetite", 0)
- condition, _ := c.GetInt64("condition", 0)
- posture, _ := c.GetInt64("posture")
- score := c.GetString("score")
-
- sick_condition, _ := c.GetInt64("sick_condition", 0)
- danger_level, _ := c.GetInt64("danger_level", 0)
- intake, _ := c.GetInt64("intake", 0)
- nutrition, _ := c.GetInt64("nutrition", 0)
- psychological_assessment, _ := c.GetInt64("psychological_assessment", 0)
- psychological_assessment_other := c.GetString("psychological_assessment_other")
- sick_condition_other := c.GetString("sick_condition_other")
-
- //precaution, _ := c.GetInt64("precaution", 0)
- precaution := c.GetString("precaution")
- precaution_other := c.GetString("precaution_other")
- psychological_other := c.GetString("psychological_other")
- admission_number := c.GetString("admission_number")
- tumble, _ := c.GetInt64("tumble")
- his_department := c.GetString("his_department")
- his_bed := c.GetString("his_bed")
- diacrisis := c.GetString("diacrisis")
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- _, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- receiveTreatmentAsses := models.ReceiveTreatmentAsses{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: id,
- RecordDate: recordDate.Unix(),
- Way: way,
- Consciousness: consciousness,
- Appetite: appetite,
- Condition: condition,
- SickCondition: sick_condition,
- DangerLevel: danger_level,
- Intake: intake,
- Nutrition: nutrition,
- PsychologicalAssessment: psychological_assessment,
- PsychologicalAssessmentOther: psychological_assessment_other,
- SickConditionOther: sick_condition_other,
- Posture: posture,
- CreatedTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- Status: 1,
- Score: score,
- Precaution: precaution,
- PrecautionOther: precaution_other,
- PsychologicalOther: psychological_other,
- AdmissionNumber: admission_number,
- Tumble: tumble,
- HisDepartment: his_department,
- HisBed: his_bed,
- Diacrisis: diacrisis,
- }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId, 2)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- if receiveTreatment.ID == 0 { //新增
- receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
- err := service.AddSigleReceiveTreatmentAssesRecord(&receiveTreatmentAsses)
- //创建步骤表
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 2,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: id,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 2, id)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- defer redis.Close()
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "receiveTreatmentAsses": receiveTreatmentAsses,
- })
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
-
- } else { //修改
- //if receiveTreatment.Creater != adminUserInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
- var cha_time int64
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId, 2)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- receiveTreatmentAsses.Creater = receiveTreatment.Creater
- receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
- receiveTreatmentAsses.UpdateTime = time.Now().Unix()
- receiveTreatmentAsses.Modifier = adminUserInfo.AdminUser.Id
- receiveTreatmentAsses.ID = receiveTreatment.ID
- err := service.UpadateReceiveTreatmentAsses(&receiveTreatmentAsses)
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":receive_treatment_asses"
- redis := service.RedisClient()
- defer redis.Close()
- redis.Set(keyOne, "", time.Second*60*60*18)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "receiveTreatmentAsses": receiveTreatmentAsses,
- })
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
- }
-
- }
-
- func (c *DialysisApiController) PostAssessmentAfterDislysis() {
-
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
- fmt.Println(recordDateStr)
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
-
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- // data := make(map[string]interface{}, 0)
- var data models.AssessmentAfterDislysis
- var err error
- err = json.Unmarshal(c.Ctx.Input.RequestBody, &data)
- fmt.Println(err)
- if err != nil {
- c.ErrorLog("数据解析错误:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- assessment, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- assessment.DialysisOrderId = data.DialysisOrderId
- assessment.Evaluator = adminUserInfo.AdminUser.Id
- assessment.Status = 1
- assessment.WeightAfter = data.WeightAfter
- assessment.WeightLoss = data.WeightLoss
- assessment.Temperature = data.Temperature
- assessment.SystolicBloodPressure = data.SystolicBloodPressure
- assessment.DiastolicBloodPressure = data.DiastolicBloodPressure
- assessment.PulseFrequency = data.PulseFrequency
- assessment.ActualUltrafiltration = data.ActualUltrafiltration
- assessment.ActualDisplacement = data.ActualDisplacement
- assessment.ActualTreatmentHour = data.ActualTreatmentHour
- assessment.ActualTreatmentMinute = data.ActualTreatmentMinute
- assessment.Cruor = data.Cruor
- assessment.SymptomAfterDialysis = data.SymptomAfterDialysis
- assessment.DialysisIntakes = data.DialysisIntakes
- assessment.InternalFistula = data.InternalFistula
- assessment.BloodAccessPartId = data.BloodAccessPartId
- assessment.BloodAccessPartOperaId = data.BloodAccessPartOperaId
- assessment.Catheter = data.Catheter
- assessment.Complication = data.Complication
- assessment.PuncturePointOozingBlood = data.PuncturePointOozingBlood
- assessment.PuncturePointHaematoma = data.PuncturePointHaematoma
- assessment.InternalFistulaTremorAc = data.InternalFistulaTremorAc
- assessment.PatientGose = data.PatientGose
- assessment.InpatientDepartment = data.InpatientDepartment
- assessment.ObservationContent = data.ObservationContent
- assessment.ObservationContentOther = data.ObservationContentOther
- assessment.Remark = data.Remark
- assessment.BreathingRate = data.BreathingRate
- assessment.DialysisProcess = data.DialysisProcess
- assessment.InAdvanceMinute = data.InAdvanceMinute
- assessment.InAdvanceReasonOther = data.InAdvanceReasonOther
- assessment.InAdvanceReason = data.InAdvanceReason
- assessment.HemostasisOpera = data.HemostasisOpera
- assessment.HemostasisMinute = data.HemostasisMinute
- assessment.TremorNoise = data.TremorNoise
- assessment.DisequilibriumSyndrome = data.DisequilibriumSyndrome
- assessment.DisequilibriumSyndromeOption = data.DisequilibriumSyndromeOption
- assessment.ArterialTube = data.ArterialTube
- assessment.IntravenousTube = data.IntravenousTube
- assessment.DialysisIntakesUnit = data.DialysisIntakesUnit
- assessment.Dialyzer = data.Dialyzer
- assessment.IsEat = data.IsEat
- assessment.CvcA = data.CvcA
- assessment.CvcV = data.CvcV
- assessment.Channel = data.Channel
- assessment.ReturnBlood = data.ReturnBlood
- assessment.RehydrationVolume = data.RehydrationVolume
- assessment.DialysisDuring = data.DialysisDuring
- assessment.StrokeVolume = data.StrokeVolume
- assessment.BloodFlow = data.BloodFlow
- assessment.SealingFluidDispose = data.SealingFluidDispose
- assessment.SealingFluidSpecial = data.SealingFluidSpecial
- assessment.DosageOfAnticoagulants = data.DosageOfAnticoagulants
- assessment.SupineSystolicBloodPressure = data.SupineSystolicBloodPressure
- assessment.SettingPressure = data.SettingPressure
- assessment.SupineDiastolicBloodPressure = data.SupineDiastolicBloodPressure
- assessment.DiastolicPressure = data.DiastolicPressure
- assessment.AdditionalWeight = data.AdditionalWeight
- assessment.OtherComplication = data.OtherComplication
- assessment.Ktv = data.Ktv
- assessment.Urr = data.Urr
- assessment.Hypertenison = data.Hypertenison
- assessment.Hypopiesia = data.Hypopiesia
- assessment.LeaveOfficeMethod = data.LeaveOfficeMethod
- assessment.Lapse = data.Lapse
- assessment.Consciousness = data.Consciousness
- assessment.Fallrisk = data.Fallrisk
- assessment.MachineRun = data.MachineRun
- assessment.AfterUrea = data.AfterUrea
- assessment.PipCoagulation = data.PipCoagulation
- assessment.AccumulatedBloodVolume = data.AccumulatedBloodVolume
- assessment.TransfusionVolume = data.TransfusionVolume
- assessment.Condenser = data.Condenser
- assessment.LastAfterWeight = data.LastAfterWeight
- assessment.DisplaceLiquiValue = data.DisplaceLiquiValue
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
-
- if assessment.ID > 0 {
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
- assessment.AssessmentTime = time.Now().Unix()
- } else {
- if assessment.Creater == 0 {
- assessment.Modifier = adminUserInfo.AdminUser.Id
- assessment.Creater = adminUserInfo.AdminUser.Id
- } else {
- assessment.Modifier = adminUserInfo.AdminUser.Id
- }
- }
-
- assessment.UpdatedTime = time.Now().Unix()
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 9)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err = service.UpdateAssessmentAfterDislysisRecord(&assessment)
- //记录日志
- byterequest, _ := json.Marshal(assessment)
- afterDialysisLog := models.XtAssessmentAfterDialysisLog{
- UserOrgId: assessment.UserOrgId,
- PatientId: assessment.PatientId,
- RecordDate: assessment.AssessmentDate,
- Status: 1,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "电脑端保存透后评估",
- }
- service.CreateAfterDialysisLog(afterDialysisLog)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
- keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyTwo, "", time.Second)
- defer redis.Close()
- } else {
- if appRole.UserType == 2 || appRole.UserType == 1 {
- assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
- assessment.AssessmentTime = time.Now().Unix()
- } else {
- assessment.Creater = adminUserInfo.AdminUser.Id
- }
- assessment.CreatedTime = time.Now().Unix()
- assessment.UpdatedTime = time.Now().Unix()
- assessment.UserOrgId = adminUserInfo.CurrentOrgId
- assessment.PatientId = patient
- assessment.AssessmentDate = recordDate.Unix()
-
- err = service.AddSigleAssessmentAfterDislysisRecord(&assessment)
- //记录日志
- byterequest, _ := json.Marshal(assessment)
- afterDialysisLog := models.XtAssessmentAfterDialysisLog{
- UserOrgId: assessment.UserOrgId,
- PatientId: assessment.PatientId,
- RecordDate: assessment.AssessmentDate,
- Status: 1,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "电脑端修改保存透后评估",
- }
- service.CreateAfterDialysisLog(afterDialysisLog)
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 9,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 9, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyThree := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
- redis.Set(keyThree, "", time.Second)
- keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyTwo, "", time.Second)
- defer redis.Close()
- }
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "AssessmentAfterDislysis": &assessment,
- })
-
- }
-
- func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- weight_before, _ := c.GetFloat("weight_before", 0)
- dry_weight, _ := c.GetFloat("dry_weight", 0)
- additional_weight, _ := c.GetFloat("additional_weight", 0)
- temperature, _ := c.GetFloat("temperature", 0)
- pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
- systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
- diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
- last_post_dialysis := c.GetString("last_post_dialysis")
- dialysis_interphase := c.GetString("dialysis_interphase")
- symptom_before_dialysis := c.GetString("symptom_before_dialysis")
- bloodAccessPartOperaId, _ := c.GetInt64("blood_access_part_opera_id", 0)
- //bloodAccessPartId, _ := c.GetInt64("blood_access_part_id", 0)
- bloodAccessPartId := c.GetString("blood_access_part_id")
- internalFistula := c.GetString("internal_fistula")
- internal_fistula_skin := c.GetString("internal_fistula_skin")
- catheter := c.GetString("catheter")
- catheter_bend, _ := c.GetInt("catheter_bend")
- complication := c.GetString("complication")
- is_hemorrhage, _ := c.GetInt64("is_hemorrhage", 0)
- hemorrhage := c.GetString("hemorrhage")
- hemorrhage_other := c.GetString("hemorrhage_other")
- remark := c.GetString("remark")
- puncture_method := c.GetString("puncture_method")
-
- dialysis_count := c.GetString("dialysis_count")
-
- emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
- emergency_treatment_other := c.GetString("emergency_treatment_other")
- ductus_arantii := c.GetString("ductus_arantii")
- venous_catheterization_part_other := c.GetString("venous_catheterization_part_other")
- venous_catheterization_part, _ := c.GetInt64("venous_catheterization_part", 0)
- venous_catheterization, _ := c.GetInt64("venous_catheterization", 0)
- //puncture_way, _ := c.GetInt64("puncture_way", 0)
- puncture_way := c.GetString("puncture_way")
- blood_access_noise, _ := c.GetInt64("blood_access_noise", 0)
- internal_fistula_other := c.GetString("internal_fistula_other")
- blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
- breathing_rate := c.GetString("breathing_rate")
- is_infect, _ := c.GetInt64("is_infect", 0)
- exposed, _ := c.GetFloat("exposed", 0)
- skin := c.GetString("skin")
- skin_other := c.GetString("skin_other")
- infect_other := c.GetString("infect_other")
- ductus_arantii_other := c.GetString("ductus_arantii_other")
- machine_type := c.GetString("machine_type")
- puncture_needle := c.GetString("puncture_needle")
- //humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
-
- humor_excessive_symptom := c.GetString("humor_excessive_symptom")
- phinholing := c.GetString("pinholing")
-
- catheter_suture := c.GetString("catheter_suture")
- catheter_suture_other := c.GetString("catheter_suture_other")
- edema := c.GetString("edema")
- urine_volume, _ := c.GetFloat("urine_volume", 0)
- special_treatment := c.GetString("special_treatment")
- catheter_maintenance := c.GetString("catheter_maintenance")
- thrombusType := c.GetString("thromubus_type")
- thrombusInt, _ := strconv.ParseInt(thrombusType, 10, 64)
- thrombus_a := c.GetString("thromubus_a")
- thrombus_av := c.GetString("thrombus_av")
- thrombus_v := c.GetString("thromubus_v")
- dehydration := c.GetString("dehydration")
- pre_dialysis_drugs := c.GetString("pre_dialysis_drugs")
- period, _ := c.GetInt64("period")
- estimated_food_intake := c.GetString("estimated_food_intake")
- blood_pressure_during_dialysis := c.GetString("blood_pressure_during_dialysis")
- urea_befor := c.GetString("urea_befor")
- suction := c.GetString("suction")
- weight_befor_remake := c.GetString("weight_befor_remake")
- height := c.GetString("height")
- age := c.GetString("age")
- his_department := c.GetString("his_department")
- his_bed := c.GetString("his_bed")
- point_puncture := c.GetString("point_puncture")
-
- catheter_evaluation_program := c.GetString("catheter_evaluation_program")
- skin_site_catheterization := c.GetString("skin_site_catheterization")
- pathway_formation_time := c.GetString("pathway_formation_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(pathway_formation_time) > 0 {
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", pathway_formation_time+" 00:00:00", loc)
- startTime = theTime.Unix()
- }
- whether_unobstructed, _ := c.GetInt64("whether_unobstructed")
-
- lien_necessary, _ := c.GetInt64("lien_necessary")
-
- befor_symptoms := c.GetString("befor_symptoms")
-
- warsh_count := c.GetString("warsh_count")
-
- washing_time := c.GetString("washing_time")
-
- puncture_needle_direction := c.GetString("puncture_needle_direction")
-
- assessmentBeforeDislysis := models.PredialysisEvaluation{
- DialysisCount: dialysis_count,
- EmergencyTreatment: emergency_treatment,
- EmergencyTreatmentOther: emergency_treatment_other,
- DuctusArantii: ductus_arantii,
- VenousCatheterization: venous_catheterization,
- VenousCatheterizationPart: venous_catheterization_part,
- VenousCatheterizationPartOther: venous_catheterization_part_other,
- PunctureWay: puncture_way,
- BloodAccessInternalFistula: blood_access_internal_fistula,
- BloodAccessNoise: blood_access_noise,
- InternalFistulaOther: internal_fistula_other,
- Evaluator: adminUserInfo.AdminUser.Id,
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- AssessmentDate: recordDate.Unix(),
- Temperature: temperature,
- PulseFrequency: pulse_frequency,
- SystolicBloodPressure: systolic_blood_pressure,
- DiastolicBloodPressure: diastolic_blood_pressure,
- WeightBefore: weight_before,
- DryWeight: dry_weight,
- AdditionalWeight: additional_weight,
- DialysisInterphase: dialysis_interphase,
- LastPostDialysis: last_post_dialysis,
- SymptomBeforeDialysis: symptom_before_dialysis,
- InternalFistula: internalFistula,
- InternalFistulaSkin: internal_fistula_skin,
- Catheter: catheter,
- CatheterBend: catheter_bend,
- Complication: complication,
- CreatedTime: time.Now().Unix(),
- Status: 1,
- Remark: remark,
- IsHemorrhage: is_hemorrhage,
- Hemorrhage: hemorrhage,
- HemorrhageOther: hemorrhage_other,
- BloodAccessPartId: bloodAccessPartId,
- BloodAccessPartOperaId: bloodAccessPartOperaId,
- PunctureMethod: puncture_method,
- BreathingRate: breathing_rate,
- IsInfect: is_infect,
- Exposed: exposed,
- Skin: skin,
- SkinOther: skin_other,
- InfectOther: infect_other,
- DuctusArantiiOther: ductus_arantii_other,
- MachineType: machine_type,
- PunctureNeedle: puncture_needle,
- HumorExcessiveSymptom: humor_excessive_symptom,
- Phinholing: phinholing,
- CatheterSuture: catheter_suture,
- CatheterSutureOther: catheter_suture_other,
- Edema: edema,
- UrineVolume: urine_volume,
- SpecialTreatment: special_treatment,
- CatheterMaintenance: catheter_maintenance,
- ThromubusType: thrombusInt,
- ThrombusAv: thrombus_av,
- ThromubusA: thrombus_a,
- ThromubusV: thrombus_v,
- Dehydration: dehydration,
- PreDialysisDrugs: pre_dialysis_drugs,
- Period: period,
- EstimatedFoodIntake: estimated_food_intake,
- BloodPressureDuringDialysis: blood_pressure_during_dialysis,
- UreaBefor: urea_befor,
- Suction: suction,
- WeightBeforRemake: weight_befor_remake,
- Height: height,
- Age: age,
- HisDepartment: his_department,
- HisBed: his_bed,
- PointPuncture: point_puncture,
- CatheterEvaluationProgram: catheter_evaluation_program,
- SkinSiteCatheterization: skin_site_catheterization,
- PathwayFormationTime: startTime,
- WhetherUnobstructed: whether_unobstructed,
- LienNecessary: lien_necessary,
- BeforSymptoms: befor_symptoms,
- WarshCount: warsh_count,
- WashingTime: washing_time,
- PunctureNeedleDirection: puncture_needle_direction,
- }
-
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
-
- _, evaluation := service.FindPredialysisEvaluationByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if evaluation.ID == 0 { //新增
- if appRole.UserType == 2 || appRole.UserType == 1 {
- assessmentBeforeDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
- assessmentBeforeDislysis.AssessmentTime = time.Now().Unix()
- } else {
- assessmentBeforeDislysis.Creater = adminUserInfo.AdminUser.Id
-
- }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 3)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- if adminUserInfo.CurrentOrgId == 10644 {
- assessmentBeforeDislysis.PunctureNeedle = ""
- }
-
- err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
- //记录日志
- byterequest, _ := json.Marshal(assessmentBeforeDislysis)
- beforeDislysisLog := models.XtAssessmentBeforeDislysisLog{
- UserOrgId: assessmentBeforeDislysis.UserOrgId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- ErrLog: string(byterequest),
- PatientId: assessmentBeforeDislysis.PatientId,
- RecordDate: assessmentBeforeDislysis.AssessmentDate,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- Source: "电脑端保存透前评估",
- }
- service.CreateBeforLog(beforeDislysisLog)
- //创建步骤表
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 3,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 3, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
-
- if adminUserInfo.CurrentOrgId == 9671 || adminUserInfo.CurrentOrgId == 3877 || adminUserInfo.CurrentOrgId == 10469 || adminUserInfo.CurrentOrgId == 10551 || adminUserInfo.CurrentOrgId == 10579 || adminUserInfo.CurrentOrgId == 10580 || adminUserInfo.CurrentOrgId == 10585 || adminUserInfo.CurrentOrgId == 10344 || adminUserInfo.CurrentOrgId == 10622 || adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10727 || adminUserInfo.CurrentOrgId == 10726 || adminUserInfo.CurrentOrgId == 10731 || adminUserInfo.CurrentOrgId == 10727 {
- var dewater_amount float64
- dewater_amount = 0
- if dry_weight > 0 {
- dewater_amount = weight_before - dry_weight - additional_weight
-
- if adminUserInfo.CurrentOrgId != 10551 && adminUserInfo.CurrentOrgId != 10579 && adminUserInfo.CurrentOrgId != 10580 && adminUserInfo.CurrentOrgId != 10585 && adminUserInfo.CurrentOrgId != 10344 && adminUserInfo.CurrentOrgId != 10622 && adminUserInfo.CurrentOrgId != 10702 && adminUserInfo.CurrentOrgId != 10635 && adminUserInfo.CurrentOrgId != 10723 {
- dewater_amount = dewater_amount * 1000
- }
-
- if dewater_amount <= 0 {
- dewater_amount = 0
- }
- } else {
- dewater_amount = 0
- }
-
- // 计算透析处方的相关超滤量
- schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- var lastDialysisPrescribe *models.DialysisPrescription
- var dialysisSolution *models.DialysisSolution
- var dialysisPrescribe *models.DialysisPrescription
- var mode_id int64
- if schedual != nil {
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix(), schedual.ModeId)
- if dialysisPrescribe == nil {
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- }
- lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
- // 获取透析模版
- dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
- mode_id = schedual.ModeId
- } else {
- //lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribe(adminUserInfo.Org.Id, id,schedual.ModeId)
- // 获取透析模版
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- // 获取透析模版
- dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
-
- if dialysisPrescribe == nil && dialysisSolution != nil {
- mode_id = dialysisSolution.ModeId
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- mode_id = 0
- }
- }
-
- // 插入透析处方
- if dialysisPrescribe == nil && dialysisSolution != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
- newprescribe.PatientId = patient
- newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
- newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
- newprescribe.ModeId = dialysisSolution.ModeId
- newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
- newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
- newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
- newprescribe.BloodFilter = dialysisSolution.BloodFilter
- newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
- newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
- newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
- newprescribe.Glucose = dialysisSolution.Glucose
- newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
- newprescribe.Kalium = dialysisSolution.Kalium
- newprescribe.Sodium = dialysisSolution.Sodium
- newprescribe.Calcium = dialysisSolution.Calcium
- newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
- newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
- newprescribe.Conductivity = dialysisSolution.Conductivity
- newprescribe.BodyFluid = dialysisSolution.BodyFluid
- newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
- newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
- newprescribe.BloodAccess = dialysisSolution.BloodAccess
- newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
- newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
- newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
- newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
- newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
- newprescribe.Dialyzer = dialysisSolution.Dialyzer
- newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
- newprescribe.TargetKtv = dialysisSolution.TargetKtv
- newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
- newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
- newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
- newprescribe.Amylaceum = dialysisSolution.Amylaceum
- newprescribe.Status = 1
-
- if adminUserInfo.CurrentOrgId == 10579 {
- newprescribe.Modifier = 0
- newprescribe.PrescriptionDoctor = 0
- newprescribe.Creater = 0
- }
- err := service.AddSigleRecord(&newprescribe)
-
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: newprescribe.UserOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: newprescribe.PatientId,
- Source: "电脑端透前评估保存",
- Status: 1,
- }
- service.CreatePrescriptionLog(prescriptionLog)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- if lastDialysisPrescribe != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
- newprescribe.PatientId = patient
- newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
- newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
- newprescribe.ModeId = lastDialysisPrescribe.ModeId
- newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
- newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
- newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
- newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
- newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
- newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
- newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
- newprescribe.Glucose = lastDialysisPrescribe.Glucose
- newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
- newprescribe.Kalium = lastDialysisPrescribe.Kalium
- newprescribe.Sodium = lastDialysisPrescribe.Sodium
- newprescribe.Calcium = lastDialysisPrescribe.Calcium
- newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
- newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
- newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
- newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
- newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
- newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
- newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
- newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
- newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
- newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
- newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
- newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
- newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
- newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
- newprescribe.DialysisStrainer = lastDialysisPrescribe.DialysisStrainer
- newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
- newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
- newprescribe.Amylaceum = lastDialysisPrescribe.Amylaceum
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Status = 1
- newprescribe.Creater = adminUserInfo.AdminUser.Id
- newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
- if adminUserInfo.CurrentOrgId == 10579 {
- newprescribe.Modifier = 0
- newprescribe.PrescriptionDoctor = 0
- newprescribe.Creater = 0
- }
- err := service.AddSigleRecord(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: newprescribe.UserOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: newprescribe.PatientId,
- Source: "电脑端透前评估保存",
- Status: 1,
- }
- service.CreatePrescriptionLog(prescriptionLog)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyThree, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
- newprescribe.PatientId = patient
- newprescribe.ModeId = mode_id
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Status = 1
- newprescribe.Creater = adminUserInfo.AdminUser.Id
- newprescribe.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- newprescribe.Modifier = adminUserInfo.AdminUser.Id
- if adminUserInfo.CurrentOrgId == 10579 {
- newprescribe.Modifier = 0
- newprescribe.PrescriptionDoctor = 0
- newprescribe.Creater = 0
- }
- err := service.AddSigleRecord(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: newprescribe.UserOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: newprescribe.PatientId,
- Source: "电脑端透前评估保存",
- Status: 1,
- }
- service.CreatePrescriptionLog(prescriptionLog)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyThree, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
- }
-
- if adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10164 {
-
- prescription, _ := service.GetTodayPrescription(patient, adminUserInfo.CurrentOrgId, recordDate.Unix())
-
- monitorList, _ := service.GetMobilePatientMonitor(prescription.PatientId, prescription.RecordDate, prescription.UserOrgId)
-
- if len(monitorList) > 0 {
- var ultrafiltration_rate float64
- totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
-
- ultrafiltration_rate = (math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)) / 1000
- var replacement_rate float64
-
- //乘10 除10是为了保留一位小数
- replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*10) / 10
-
- var firstOpeateTime = monitorList[0].OperateTime
- for _, item := range monitorList {
- //超滤率
- service.ModifyDialysisPatientMonitor(item.ID, ultrafiltration_rate)
-
- //置换率
- service.ModifyDialysisPatientReplascementRate(item.ID, replacement_rate)
-
- //超滤量
- ultrafiltration_volume := math.Floor(float64(item.OperateTime-firstOpeateTime)/3600) * ultrafiltration_rate
- service.ModifyPatientUltrafiltrationVolume(item.ID, ultrafiltration_volume)
-
- //置换量
- displacement_quantity := (math.Floor(float64(item.OperateTime+3600-firstOpeateTime)/3600) * replacement_rate) * 60 / 1000
-
- service.ModifyPatientDisplacementQuantity(item.ID, displacement_quantity)
-
- }
- }
-
- }
-
- }
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyTwo, "", time.Second)
- defer redis.Close()
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "assessmentBeforeDislysis": &assessmentBeforeDislysis,
- })
- } else {
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
- } else { //修改
- //if appRole.UserType == 3 {
- // if evaluation.Creater != adminUserInfo.AdminUser.Id && evaluation.Creater != 0 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- assessmentBeforeDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
- assessmentBeforeDislysis.AssessmentTime = time.Now().Unix()
- } else {
- if evaluation.Creater == 0 {
- assessmentBeforeDislysis.Modifier = adminUserInfo.AdminUser.Id
- assessmentBeforeDislysis.Creater = adminUserInfo.AdminUser.Id
- } else {
- assessmentBeforeDislysis.Modifier = adminUserInfo.AdminUser.Id
- }
- }
-
- assessmentBeforeDislysis.UpdatedTime = time.Now().Unix()
- assessmentBeforeDislysis.ID = evaluation.ID
- assessmentBeforeDislysis.CreatedTime = evaluation.CreatedTime
- //
-
- //新增逻辑
- templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- var dewater_amount float64
- dewater_amount = 0
- if evaluation.DryWeight > 0 {
- dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
- if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 || adminUserInfo.CurrentOrgId == 10551 {
- if adminUserInfo.CurrentOrgId != 10551 {
- dewater_amount = dewater_amount * 1000
- }
-
- }
- if dewater_amount <= 0 {
- dewater_amount = 0
- }
- } else {
- dewater_amount = 0
- }
- // 计算透析处方的相关超滤量
- schedual, _ := service.MobileGetSchedualDetailSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- var lastDialysisPrescribe *models.DialysisPrescription
- var dialysisSolution *models.DialysisSolution
- var dialysisPrescribe *models.DialysisPrescription
- var mode_id int64
- if schedual != nil {
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, recordDate.Unix(), schedual.ModeId)
- if dialysisPrescribe == nil {
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- }
- lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
- // 获取透析模版
- dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
- mode_id = schedual.ModeId
- } else {
- //lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribe(adminUserInfo.Org.Id, id,schedual.ModeId)
- // 获取透析模版
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- dialysisSolution, _ = service.MobileGetDialysisSolution(adminUserInfo.CurrentOrgId, patient)
-
- if dialysisPrescribe == nil && dialysisSolution != nil {
- mode_id = dialysisSolution.ModeId
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- mode_id = 0
- }
- }
-
- // 插入透析处方
- if dialysisPrescribe == nil && dialysisSolution != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
- newprescribe.PatientId = patient
- newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
- newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
- newprescribe.ModeId = dialysisSolution.ModeId
- newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
- newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
- newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
- newprescribe.BloodFilter = dialysisSolution.BloodFilter
- newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
- newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
- newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
- newprescribe.Glucose = dialysisSolution.Glucose
- newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
- newprescribe.Kalium = dialysisSolution.Kalium
- newprescribe.Sodium = dialysisSolution.Sodium
- newprescribe.Calcium = dialysisSolution.Calcium
- newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
- newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
- newprescribe.Conductivity = dialysisSolution.Conductivity
- newprescribe.BodyFluid = dialysisSolution.BodyFluid
- newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
- newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
- newprescribe.BloodAccess = dialysisSolution.BloodAccess
- newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
- newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
- newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
- newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
- newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
- newprescribe.Dialyzer = dialysisSolution.Dialyzer
- newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
- newprescribe.TargetKtv = dialysisSolution.TargetKtv
- newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
- newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
- newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
- newprescribe.Amylaceum = dialysisSolution.Amylaceum
- newprescribe.Status = 1
- if adminUserInfo.CurrentOrgId == 10579 {
- newprescribe.Modifier = 0
- newprescribe.PrescriptionDoctor = 0
- newprescribe.Creater = 0
- }
- err := service.AddSigleRecord(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: newprescribe.UserOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: newprescribe.PatientId,
- Source: "电脑端透前评估保存",
- Status: 1,
- }
- service.CreatePrescriptionLog(prescriptionLog)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- if lastDialysisPrescribe != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
- newprescribe.PatientId = patient
- newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
- newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
- newprescribe.ModeId = lastDialysisPrescribe.ModeId
- newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
- newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
- newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
- newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
- newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
- newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
- newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
- newprescribe.Glucose = lastDialysisPrescribe.Glucose
- newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
- newprescribe.Kalium = lastDialysisPrescribe.Kalium
- newprescribe.Sodium = lastDialysisPrescribe.Sodium
- newprescribe.Calcium = lastDialysisPrescribe.Calcium
- newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
- newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
- newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
- newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
- newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
- newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
- newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
- newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
- newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
- newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
- newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
- newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
- newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
- newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.PrescriptionWater = dewater_amount
- newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
- newprescribe.DialysisStrainer = lastDialysisPrescribe.DialysisStrainer
- newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
- newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
- newprescribe.Amylaceum = lastDialysisPrescribe.Amylaceum
- newprescribe.Status = 1
- if adminUserInfo.CurrentOrgId == 10579 {
- newprescribe.Modifier = 0
- newprescribe.PrescriptionDoctor = 0
- newprescribe.Creater = 0
- }
- err := service.AddSigleRecord(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: newprescribe.UserOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: newprescribe.PatientId,
- Source: "电脑端透前评估保存",
- Status: 1,
- }
- service.CreatePrescriptionLog(prescriptionLog)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyThree, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
- newprescribe.PatientId = patient
- newprescribe.ModeId = mode_id
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Status = 1
-
- err := service.AddSigleRecord(&newprescribe)
- //记录日志
- byterequest, _ := json.Marshal(newprescribe)
- prescriptionLog := models.XtDialysisPrescriptionLog{
- UserOrgId: newprescribe.UserOrgId,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- ErrLog: string(byterequest),
- AdminUserId: adminUserInfo.AdminUser.Id,
- RecordDate: newprescribe.RecordDate,
- PatientId: newprescribe.PatientId,
- Source: "电脑端透前评估保存",
- Status: 1,
- }
- service.CreatePrescriptionLog(prescriptionLog)
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":prescriptions_list_all"
- redis.Set(keyOne, "", time.Second)
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyThree, "", time.Second)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
- }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 3)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- //针对孝昌康桥超滤率计算问题
- if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10635 || adminUserInfo.CurrentOrgId == 10723 || adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10726 {
- if assessmentBeforeDislysis.ID == 0 {
- dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
- dewater_amount = assessmentBeforeDislysis.WeightBefore - assessmentBeforeDislysis.DryWeight - assessmentBeforeDislysis.AdditionalWeight
-
- service.UpdateMobileGetDialysisPrescribe(dialysisPrescribeOne.ID, dewater_amount)
- }
- }
-
- if assessmentBeforeDislysis.ID > 0 {
- dialysisPrescribeOne, _ := service.MobileGetDialysisPrescribeOne(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- if dialysisPrescribeOne.ID > 0 && assessmentBeforeDislysis.ID > 0 {
- dewater_amount = assessmentBeforeDislysis.WeightBefore - assessmentBeforeDislysis.DryWeight - assessmentBeforeDislysis.AdditionalWeight
-
- service.UpdateMobileGetDialysisPrescribeOne(dialysisPrescribeOne.ID, dewater_amount)
- }
- }
-
- }
-
- if adminUserInfo.CurrentOrgId == 10721 || adminUserInfo.CurrentOrgId == 10164 {
-
- prescription, _ := service.GetTodayPrescription(patient, adminUserInfo.CurrentOrgId, recordDate.Unix())
-
- monitorList, _ := service.GetMobilePatientMonitor(prescription.PatientId, prescription.RecordDate, prescription.UserOrgId)
-
- if len(monitorList) > 0 {
- var ultrafiltration_rate float64
- totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
-
- ultrafiltration_rate = (math.Floor(prescription.PrescriptionWater * 1000 / float64(totalMin) * 60 * 1000)) / 1000
- var replacement_rate float64
-
- //乘10 除10是为了保留一位小数
- replacement_rate = math.Floor(prescription.ReplacementTotal*1000/float64(totalMin)*10) / 10
-
- var firstOpeateTime = monitorList[0].OperateTime
- for _, item := range monitorList {
- //超滤率
- service.ModifyDialysisPatientMonitor(item.ID, ultrafiltration_rate)
-
- //置换率
- service.ModifyDialysisPatientReplascementRate(item.ID, replacement_rate)
-
- //超滤量
- ultrafiltration_volume := math.Floor(float64(item.OperateTime-firstOpeateTime)/3600) * ultrafiltration_rate
- service.ModifyPatientUltrafiltrationVolume(item.ID, ultrafiltration_volume)
-
- //置换量
- displacement_quantity := (math.Floor(float64(item.OperateTime+3600-firstOpeateTime)/3600) * replacement_rate) * 60 / 1000
-
- service.ModifyPatientDisplacementQuantity(item.ID, displacement_quantity)
-
- }
- }
-
- }
-
- err := service.UpadatePredialysisEvaluation(&assessmentBeforeDislysis)
-
- //创建步骤表
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 3,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 3, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_before_dislysis"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":assessment_befores_list_all"
- redis.Set(keyOne, "", time.Second)
- defer redis.Close()
- keyTwo := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyTwo, "", time.Second)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "assessmentBeforeDislysis": &assessmentBeforeDislysis,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
-
- }
-
- }
- func (c *DialysisApiController) PostTreatmentSummary() {
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- mission := c.GetString("mission")
- dialysis_summary := c.GetString("dialysis_summary")
- nursingRecord := c.GetString("nursing_record")
- specialRecord := c.GetString("special_record")
- sj_nurse := adminUserInfo.AdminUser.Id
- zl_nurse := adminUserInfo.AdminUser.Id
- hd_nurse := adminUserInfo.AdminUser.Id
- xj_nurse := adminUserInfo.AdminUser.Id
- zl_doctor := adminUserInfo.AdminUser.Id
-
- treatmentSummary := models.TreatmentSummary{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- AssessmentDate: recordDate.Unix(),
- Mission: mission,
- DialysisSummary: dialysis_summary,
- SjNurse: sj_nurse,
- ZlNurse: zl_nurse,
- HdNurse: hd_nurse,
- XjNurse: xj_nurse,
- ZlDoctor: zl_doctor,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- NursingRecord: nursingRecord,
- SpecialRecord: specialRecord,
- }
-
- _, tempTreatmentSummary := service.FindTreatmentSummaryByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if tempTreatmentSummary.ID == 0 { //新增
- treatmentSummary.Creater = adminUserInfo.AdminUser.Id
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 10)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
- err := service.AddSigleSummaryRecord(&treatmentSummary)
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 10,
- RecordDate: recordDate.Unix(),
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, recordDate.Unix(), 10, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
- redis := service.RedisClient()
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
- redis.Set(keyOne, "", time.Second)
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- //清空key 值
- redis.Set(key, "", time.Second)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "summary": treatmentSummary,
- })
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
-
- } else { //修改
- //if tempTreatmentSummary.Creater != adminUserInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
- var cha_time int64
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= recordDate.Unix() {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId, 10)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
- }
- }
-
- treatmentSummary.Creater = tempTreatmentSummary.Creater
- treatmentSummary.CreatedTime = tempTreatmentSummary.CreatedTime
- treatmentSummary.UpdatedTime = time.Now().Unix()
- treatmentSummary.Modifier = adminUserInfo.AdminUser.Id
- treatmentSummary.ID = tempTreatmentSummary.ID
- err := service.UpdateSummeRecord(&treatmentSummary)
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summary"
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(recordDate.Unix(), 10) + ":treatment_summarys_list_all"
- keyThree := "scheduals_" + recordDateStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- //清空key 值
- redis := service.RedisClient()
- redis.Set(key, "", time.Second)
- redis.Set(keyOne, "", time.Second)
- redis.Set(keyThree, "", time.Second)
- defer redis.Close()
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "summary": treatmentSummary,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- }
-
- }
-
- func (c *DialysisApiController) GetDeviceList() {
- adminUserInfo := c.GetAdminUserInfo()
- device, _ := service.FindAllDeviceInfo(adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "device": device,
- })
- }
-
- func (c *DialysisApiController) GetAllDeviceZone() {
- adminUserInfo := c.GetAdminUserInfo()
- err, zone := service.GetAllDeviceZone(adminUserInfo.CurrentOrgId)
- dics, _, err := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
- efs, _, _ := service.GetExecutionFrequencyDics(adminUserInfo.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- "dics": dics,
- "efs": efs,
- })
- }
-
- }
-
- func (c *DialysisApiController) GetDialysisWatch() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- schedulType, _ := c.GetInt64("schedul_type", 0)
- startTime, _ := c.GetInt64("schedul_time", 0)
- partitionType, _ := c.GetInt64("partition_type", 0)
- keywords := c.GetString("keywords")
- start_time, _ := c.GetInt64("start_time")
- end_time, _ := c.GetInt64("end_time")
- adminUserInfo := c.GetAdminUserInfo()
- if len(keywords) > 0 {
-
- dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "schedule": dialysisSchedule,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- }
-
- } else {
- dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
-
- for _, item := range dialysisSchedule {
- patients, _ := service.GetMonitorPatients(item.PatientId)
- item.MonitorPatients = patients
-
- orderObj, _ := service.GetMonitorDialysisOrderObj(item.PatientId, item.ScheduleDate)
-
- item.DialysisOrder = orderObj
-
- prescription, _ := service.GetMonitorDialysisPrescription(item.PatientId, item.ScheduleDate)
-
- item.Prescription = prescription
-
- evaluation, _ := service.GetMonitorPredialysisEvaluation(item.PatientId, item.ScheduleDate)
-
- item.AssessmentBeforeDislysis = evaluation
-
- afterdislysis, _ := service.GetMonitorAssessmentAfterDislysis(item.PatientId, item.ScheduleDate)
-
- item.AssessmentAfterDislysis = afterdislysis
-
- monitorRecord, _ := service.GetMonitoringRecordList(item.PatientId, item.ScheduleDate)
-
- item.MonitoringRecord = monitorRecord
-
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "schedule": dialysisSchedule,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- }
- }
- }
-
- //func (c *DialysisApiController) GetDialysisWatch() {
- // page, _ := c.GetInt64("page", 1)
- // limit, _ := c.GetInt64("limit", 10)
- // schedulType, _ := c.GetInt64("schedul_type", 0)
- // startTime, _ := c.GetInt64("schedul_time", 0)
- // partitionType, _ := c.GetInt64("partition_type", 0)
- // keywords := c.GetString("keywords")
- //
- // adminUserInfo := c.GetAdminUserInfo()
- // if len(keywords) > 0 {
- // dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit)
- //
- // //获取所有床位号
- // numberList, _ := service.GetAllDeviceNumberByListSix(adminUserInfo.CurrentOrgId)
- //
- // //获取透析处方
- // prescriptions, _ := service.GetAllPrescriptionByListTwo(adminUserInfo.CurrentOrgId, startTime)
- // //获取透前评估
- // assessmentBefores, _ := service.GetAllAssessmentBeforesByListThree(adminUserInfo.CurrentOrgId, startTime)
- // //获取上机
- // dialysisOrders, _ := service.GetAllDialysisOrdersByListThree(adminUserInfo.CurrentOrgId, startTime)
- // //获取透后
- // AssessmentAfterDislysis, _ := service.GetAllAssessmentAfterDislysisByListThree(adminUserInfo.CurrentOrgId, startTime)
- //
- // //获取透后监测
- // monitorlist, _ := service.GetAllMonitorListThree(adminUserInfo.CurrentOrgId, startTime)
- //
- // //获取所有的患者
- // patients, _ := service.GetAllPatientListByListSix(adminUserInfo.CurrentOrgId,keywords)
- //
- // //获取所有透析模式
- // treatments, _ := service.GetAllTreatModeByList(adminUserInfo.CurrentOrgId)
- //
- // for key, scheduals := range dialysisSchedule {
- // // 获取患者信息
- // for _, patient := range patients {
- // if scheduals.PatientId == patient.ID {
- // dialysisSchedule[key].MonitorPatients = patient
- // break
- // }
- // }
- // // 床位信息
- // for _, device := range numberList {
- // if scheduals.BedId == device.ID {
- // dialysisSchedule[key].DeviceNumber = device
- // break
- // }
- // }
- //
- // // 医嘱信息
- // for _, prescription := range prescriptions {
- // if scheduals.PatientId == prescription.PatientId {
- // dialysisSchedule[key].Prescription = prescription
- // break
- // }
- // }
- //
- // // 透前评估
- // for _, assessmentBefore := range assessmentBefores {
- // if scheduals.PatientId == assessmentBefore.PatientId {
- // dialysisSchedule[key].AssessmentBeforeDislysis = assessmentBefore
- // break
- // }
- // }
- //
- // // 透析上下机
- // for _, dialysisOrder := range dialysisOrders {
- // if scheduals.PatientId == dialysisOrder.PatientId {
- // dialysisSchedule[key].DialysisOrder = dialysisOrder
- // break
- // }
- // }
- //
- // records := make([]*models.MonitoringRecord, 0)
- // // 透析监测
- // for _, it := range monitorlist {
- // records := append(records, it)
- // if scheduals.PatientId == it.PatientId {
- // dialysisSchedule[key].MonitoringRecord = records
- // }
- // }
- //
- // // 透后评估
- // for _, afterDislysis := range AssessmentAfterDislysis {
- // if scheduals.PatientId == afterDislysis.PatientId {
- // dialysisSchedule[key].AssessmentAfterDislysis = afterDislysis
- // break
- // }
- // }
- //
- // //透析模式
- // for _, treatment := range treatments {
- // if scheduals.ModeId == treatment.ID {
- // dialysisSchedule[key].TreatmentMode = treatment
- // break
- // }
- // }
- // }
- // //获取所有床位号
- // if err == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "schedule": dialysisSchedule,
- // "total": total,
- // })
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // }
- //
- // } else {
- // dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit)
- // if err == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "schedule": dialysisSchedule,
- // "total": total,
- // })
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // }
- // }
- //}
-
- func (c *DialysisApiController) GetSchedualPatientsInfo() {
- patientId, _ := c.GetInt64("id", 0)
- record_date, _ := c.GetInt64("record_date", 0)
- adminUserInfo := c.GetAdminUserInfo()
- _, dialysisOrder := service.FindDialysisRecordById(adminUserInfo.CurrentOrgId, patientId, record_date)
- var dialysisStatus int64
- if dialysisOrder == nil { //没有透析记录
- dialysisStatus = 0 //未透析
- } else {
- dialysisStatus = dialysisOrder.Stage
- }
- //用户基本信息
- schedualPatientInfo, _ := service.FindPatientInfoById(adminUserInfo.CurrentOrgId, patientId, record_date)
-
- //接诊评估
- receiverTreatmentAccess, _ := service.FindReceiverTreatmentAccessRecordById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //透前评估
- PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //临时医嘱
- DoctorAdvice, _ := service.FindDoctorAdviceById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //双人核对
- DoubleCheck, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //透析监测
- Record, _ := service.FindAllMonitorRecord(adminUserInfo.CurrentOrgId, patientId, record_date)
-
- //透后评估
- AssessmentAfterDislysis, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //透析小结
- TreatmentSummary, _ := service.FindTreatmentSummaryById(adminUserInfo.CurrentOrgId, patientId, record_date)
-
- //透析处方
- dialysisPrescription, _ := service.FindPatientPrescribeById(adminUserInfo.CurrentOrgId, patientId, record_date)
- if dialysisPrescription.ID == 0 {
- solution, _ := service.FindDialysisSolution(adminUserInfo.CurrentOrgId, patientId)
- c.ServeSuccessJSON(map[string]interface{}{
- "patientInfo": schedualPatientInfo,
- "dialysisPrescription": solution,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "predialysisEvaluation": PredialysisEvaluation,
- "doctorAdvice": DoctorAdvice,
- "doubleCheck": DoubleCheck,
- "assessmentAfterDislysis": AssessmentAfterDislysis,
- "treatmentSummary": TreatmentSummary,
- "monitorRecord": Record,
- "dialysisStatus": dialysisStatus,
- "dialysisOrder": dialysisOrder,
- "isSolution": 1,
- })
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "patientInfo": schedualPatientInfo,
- "dialysisPrescription": dialysisPrescription,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "predialysisEvaluation": PredialysisEvaluation,
- "doctorAdvice": DoctorAdvice,
- "doubleCheck": DoubleCheck,
- "assessmentAfterDislysis": AssessmentAfterDislysis,
- "treatmentSummary": TreatmentSummary,
- "monitorRecord": Record,
- "dialysisStatus": dialysisStatus,
- "dialysisOrder": dialysisOrder,
- "isSolution": 2,
- })
-
- }
-
- }
-
- func (c *DialysisApiController) CreateDoctorAdvice() {
- patient, _ := c.GetInt64("id", 0)
- dialysis_id, _ := c.GetInt64("dialysis_id", 0)
- record_date, _ := c.GetInt64("record_date", 0)
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- var advice models.DoctorAdvice
- code, subAdivice := adviceFormDatas(&advice, c.Ctx.Input.RequestBody, "create")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- if advice.ParentId > 0 {
- old, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, advice.ParentId)
- if old.ID == 0 || old.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
- return
- }
-
- if old.StopState == 1 || old.ExecutionState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
- return
- }
-
- if old.ParentId > 0 {
- advice.ParentId = old.ParentId
- }
- advice.StartTime = old.StartTime
- advice.AdviceDoctor = old.AdviceDoctor
- advice.DeliveryWay = old.DeliveryWay
- advice.ExecutionFrequency = old.ExecutionFrequency
- }
- advice.RecordDate = record_date
- advice.DialysisOrderId = dialysis_id
- advice.Status = 1
- advice.CreatedTime = time.Now().Unix()
- advice.UpdatedTime = time.Now().Unix()
- advice.StopState = 2
- advice.ExecutionState = 2
- advice.AdviceType = 2
- advice.UserOrgId = adminUserInfo.CurrentOrgId
- advice.PatientId = patient
- advice.AdviceDoctor = adminUserInfo.AdminUser.Id
-
- err := service.CreateDoctorAdvice(&advice)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
- return
- }
-
- for _, subAdvice := range subAdivice {
- subAdvice.ParentId = advice.ID
- subAdvice.PatientId = patient
- subAdvice.RecordDate = record_date
- subAdvice.CreatedTime = time.Now().Unix()
- subAdvice.UpdatedTime = time.Now().Unix()
- subAdvice.UserOrgId = adminUserInfo.CurrentOrgId
-
- }
- service.CreateSubDoctorAdvice(subAdivice)
- _, subAdivices := service.FindAllSubDoctorAdvice(patient, advice.ID)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- "subAdvice": subAdivices,
- })
- return
-
- }
- func (c *DialysisApiController) EditDoctorAdvice() {
- patient, _ := c.GetInt64("patient", 0)
- id, _ := c.GetInt64("id", 0)
- parent_id, _ := c.GetInt64("parent_id", 0)
- execution_time := c.GetString("execution_time")
- // execution_staff, _ := c.GetInt64("execution_staff", 0)
- // checker, _ := c.GetInt64("checker", 0)
-
- if id <= 0 || patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- advice, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
- if advice.ID == 0 || advice.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
- if len(execution_time) <= 0 {
- utils.ErrorLog("execution_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
-
- }
-
- execution_staff := adminUserInfo.AdminUser.Id
- checker := adminUserInfo.AdminUser.Id
-
- timeLayout2 := "2006-01-02 15:04"
- loc, _ := time.LoadLocation("Local")
-
- theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
-
- return
- }
-
- advices := models.DoctorAdvice{
- ExecutionStaff: execution_staff,
- ExecutionTime: theTime.Unix(),
- Checker: checker,
- UpdatedTime: time.Now().Unix(),
- }
- var err error
- if parent_id > 0 {
- err = service.ExceDoctorAdviceById(&advices, parent_id, patient)
- } else {
- err = service.ExceDoctorAdviceById(&advices, id, patient)
- }
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- })
- return
-
- }
- func (c *DialysisApiController) GetDoctorAdvice() {
- patient, _ := c.GetInt64("patient_id", 0)
- parent_id, _ := c.GetInt64("parent_id", 0)
- adviceId, _ := c.GetInt64("id", 0)
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(dminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- var subAdvice []*models.DoctorAdvice
- var advice models.DoctorAdvice
-
- if parent_id > 0 {
- _, advice = service.FindAdivceById(dminUserInfo.CurrentOrgId, patient, parent_id)
- if advice.ID == 0 || advice.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
- return
- }
- subAdvice = service.FindSubAdivceById(patient, parent_id)
-
- } else {
- _, advice = service.FindAdivceById(dminUserInfo.CurrentOrgId, patient, adviceId)
- if advice.ID == 0 || advice.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
- return
- }
- subAdvice = service.FindSubAdivceById(patient, adviceId)
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- "subAdvice": subAdvice,
- })
- }
- func (this *DialysisApiController) DelMonitor() {
- recordID, _ := this.GetInt64("record_id")
- patientID, _ := this.GetInt64("patient_id")
- if recordID <= 0 || patientID <= 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.MobileGetPatientById(adminInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- monitor, getMonitorErr := service.GetMonitor(adminInfo.CurrentOrgId, patientID, recordID)
- if getMonitorErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- //if monitor != nil {
- // if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.CurrentOrgId, adminInfo.CurrentAppId, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= monitor.MonitoringDate {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patientID, monitor.MonitoringDate, adminInfo.CurrentOrgId, 7)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
-
- //记录日志
- byterequest, _ := json.Marshal(monitor)
- monitorRecordLog := models.XtMonitorRecordLog{
- RecordDate: monitor.MonitoringDate,
- PatientId: monitor.PatientId,
- Module: 3,
- AdminUserId: adminInfo.AdminUser.Id,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Status: 1,
- UserOrgId: monitor.UserOrgId,
- ErrLog: string(byterequest),
- Source: "电脑端删除监测",
- }
- service.CreateMonitorRecordLog(monitorRecordLog)
-
- key := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := strconv.FormatInt(adminInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_record_list_all"
- redis.Set(keyOne, "", time.Second)
- defer redis.Close()
-
- if err != nil {
- this.ErrorLog("删除透析监测记录失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "record_id": monitor.ID,
- })
-
- }
- func (c *DialysisApiController) CreateMonitor() {
- patient, _ := c.GetInt64("id", 0)
- dialysis_order_id, _ := c.GetInt64("dialysis_order_id", 0)
- monitoring_date, _ := c.GetInt64("monitoring_date", 0)
- operate_time, _ := c.GetInt64("operate_time", 0)
- // monitoring_time := c.GetString("monitoring_time")
- pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
- breathing_rated := c.GetString("breathing_rated")
- systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
- diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
- blood_pressure_type, _ := c.GetInt64("blood_pressure_type", 0)
- blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
- venous_pressure, _ := c.GetFloat("venous_pressure", 0)
- venous_pressure_type, _ := c.GetInt64("venous_pressure_type", 1)
- transmembrane_pressure, _ := c.GetFloat("transmembrane_pressure", 0)
- transmembrane_pressure_type, _ := c.GetInt64("transmembrane_pressure_type", 1)
- ultrafiltration_rate, _ := c.GetFloat("ultrafiltration_rate", 0)
- ultrafiltration_volume, _ := c.GetFloat("ultrafiltration_volume", 0)
- sodium_concentration, _ := c.GetFloat("sodium_concentration", 0)
- arterial_pressure, _ := c.GetFloat("arterial_pressure", 0)
- arterial_pressure_type, _ := c.GetInt64("arterial_pressure_type", 1)
- dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
- temperature, _ := c.GetFloat("temperature", 0)
- replacement_rate, _ := c.GetFloat("replacement_rate", 0)
- displacement_quantity, _ := c.GetFloat("displacement_quantity", 0)
- conductivity, _ := c.GetFloat("conductivity", 0)
-
- displacement_flow_quantity, _ := c.GetFloat("displacement_flow_quantity", 0)
-
- heparin, _ := c.GetFloat("heparin", 0)
- dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
-
- ktv, _ := c.GetFloat("ktv", 0)
- symptom := c.GetString("symptom")
- dispose := c.GetString("dispose")
- result := c.GetString("results")
-
- monitoring_nurse, _ := c.GetInt64("monitoring_nurse", 0)
-
- monitor_anticoagulant, _ := c.GetInt64("monitor_anticoagulant")
- monitor_anticoagulant_value := c.GetString("monitor_anticoagulant_value")
- replacement_speed, _ := c.GetFloat("replacement_speed")
- dicarbonate, _ := c.GetFloat("dicarbonate")
- monitoring_date = monitoring_date / 1000
- // operate_time = operate_time / 1000
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- monitorRecord := models.MonitoringRecord{
- PatientId: patient,
- MonitoringDate: monitoring_date,
- DialysisOrderId: dialysis_order_id,
- OperateTime: operate_time,
- // MonitoringTime: monitoring_time,
- PulseFrequency: pulse_frequency,
- BreathingRate: breathing_rated,
- SystolicBloodPressure: systolic_blood_pressure,
- DiastolicBloodPressure: diastolic_blood_pressure,
- BloodPressureType: blood_pressure_type,
- BloodFlowVolume: blood_flow_volume,
- VenousPressure: venous_pressure,
- VenousPressureType: venous_pressure_type,
- TransmembranePressure: transmembrane_pressure,
- TransmembranePressureType: transmembrane_pressure_type,
- UltrafiltrationRate: ultrafiltration_rate,
- UltrafiltrationVolume: ultrafiltration_volume,
- SodiumConcentration: sodium_concentration,
- ArterialPressure: arterial_pressure,
- ArterialPressureType: arterial_pressure_type,
- DialysateTemperature: dialysate_temperature,
- Temperature: temperature,
- ReplacementRate: replacement_rate,
- DisplacementQuantity: displacement_quantity,
- Ktv: ktv,
- Symptom: symptom,
- Dispose: dispose,
- Result: result,
- MonitoringNurse: monitoring_nurse,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- UserOrgId: adminUserInfo.CurrentOrgId,
- Conductivity: conductivity,
- DisplacementFlowQuantity: displacement_flow_quantity,
- Heparin: heparin,
- DialysateFlow: dialysate_flow,
- MonitorAnticoagulant: monitor_anticoagulant,
- MonitorAnticoagulantValue: monitor_anticoagulant_value,
- ReplacementSpeed: replacement_speed,
- Dicarbonate: dicarbonate,
- }
-
- // 查询信息规挡的设置天数
-
- infor, _ := service.GetDialysisInformationSetting(adminUserInfo.CurrentOrgId)
- if infor.ID > 0 && infor.WeekDay > 0 {
-
- var cha_time int64
-
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- //今日的日期减去设置的日期
- cha_time = timeNewDate.Unix() - infor.WeekDay*86400
-
- if cha_time >= monitoring_date {
- //查询审核是否允许
- infor, _ := service.GetDialysisInformationByRecordDate(patient, monitoring_date, adminUserInfo.CurrentOrgId, 7)
- //申请状态不允许的情况 拒绝修改
- if infor.ApplicationStatus != 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
- return
- }
-
- }
- }
-
- err := service.CreateMonitor(&monitorRecord)
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 7,
- RecordDate: monitoring_date,
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, monitoring_date, 7, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
-
- redis := service.RedisClient()
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(monitoring_date, 10) + ":monitor_record_list_all"
-
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(monitoring_date, 10) + ":monitor_records"
- redis.Set(keyOne, "", time.Second)
- redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "monitor": monitorRecord,
- })
- return
-
- }
-
- // 已弃用
- // func (c *DialysisApiController) CreateRecordData() {
- // patient, _ := c.GetInt64("id", 0)
- // status, _ := c.GetInt64("status", 0)
-
- // now := time.Now()
- // year, month, day := now.Date()
- // today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
- // todayTimeStamp := today_time.Unix()
-
- // if patient <= 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- // }
-
- // adminUserInfo := c.GetAdminUserInfo()
- // patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- // if patientInfo.ID == 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- // return
- // }
-
- // record := &models.DialysisOrder{
- // DialysisDate: todayTimeStamp,
- // UserOrgId: adminUserInfo.CurrentOrgId,
- // PatientId: patient,
- // Stage: status,
- // Status: 1,
- // CreatedTime: time.Now().Unix(),
- // UpdatedTime: time.Now().Unix(),
- // }
-
- // if status == 1 {
- // //创建透析记录
- // err := service.CreateDialysisRecord(patient, adminUserInfo.CurrentOrgId, record)
- // if err == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "dialysisOrder": record,
- // })
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- // }
-
- // } else {
-
- // record_id, _ := c.GetInt64("record_id", 0)
- // //修改透析记录状态
- // errs := service.ModifyDialysisRecord(record_id)
- // //结束时候透析次数加1
- // service.UpdateSolutionByPatientId(patient)
-
- // if errs == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "dialysisOrder": record,
- // })
-
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
-
- // }
-
- // }
-
- // }
-
- func adviceFormDatas(advice *models.DoctorAdvice, data []byte, action string) (code int, subAdvice []*models.DoctorAdvice) {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- timeLayout := "2006-01-02 "
- timeLayout2 := "2006-01-02 15:04"
-
- loc, _ := time.LoadLocation("Local")
-
- if action == "create" {
- if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
- utils.ErrorLog("advice_type")
- code = enums.ErrorCodeParamWrong
- return
- }
-
- adviceType := int64(dataBody["advice_type"].(float64))
- if adviceType != 1 && adviceType != 2 {
- utils.ErrorLog("advice_type != 1&&2")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceType = adviceType
-
- if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
- utils.ErrorLog("advice_date")
- code = enums.ErrorCodeParamWrong
- return
- }
- adviceDate, _ := dataBody["advice_date"].(string)
- if len(adviceDate) == 0 {
- utils.ErrorLog("len(adviceDate) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceDate = theTime.Unix()
-
- }
-
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- code = enums.ErrorCodeParamWrong
- return
- }
- startDate, _ := dataBody["start_time"].(string)
- if len(startDate) == 0 {
- utils.ErrorLog("len(startDate) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- theTime, err := time.ParseInLocation(timeLayout2, startDate, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.StartTime = theTime.Unix()
-
- if dataBody["advice_name"] == nil || reflect.TypeOf(dataBody["advice_name"]).String() != "string" {
- utils.ErrorLog("advice_name")
- code = enums.ErrorCodeParamWrong
- return
- }
- adviceName, _ := dataBody["advice_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceName = adviceName
-
- if dataBody["delivery_way"] == nil || reflect.TypeOf(dataBody["delivery_way"]).String() != "string" {
- utils.ErrorLog("delivery_way")
- code = enums.ErrorCodeParamWrong
- return
- }
- deliveryWay, _ := dataBody["delivery_way"].(string)
- if len(deliveryWay) == 0 {
- utils.ErrorLog("len(deliveryWay) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.DeliveryWay = deliveryWay
-
- if dataBody["execution_frequency"] == nil || reflect.TypeOf(dataBody["execution_frequency"]).String() != "string" {
- utils.ErrorLog("execution_frequency")
- code = enums.ErrorCodeParamWrong
- return
- }
- execution_frequency, _ := dataBody["execution_frequency"].(string)
- if len(execution_frequency) == 0 {
- utils.ErrorLog("len(execution_frequency) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.ExecutionFrequency = execution_frequency
-
- if dataBody["advice_desc"] != nil && reflect.TypeOf(dataBody["advice_desc"]).String() == "string" {
- adviceDsc, _ := dataBody["advice_desc"].(string)
- advice.AdviceDesc = adviceDsc
- }
-
- if dataBody["drug_spec_unit"] != nil && reflect.TypeOf(dataBody["drug_spec_unit"]).String() == "string" {
- drugSpecUnit, _ := dataBody["drug_spec_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
-
- if dataBody["single_dose"] != nil && reflect.TypeOf(dataBody["single_dose"]).String() == "string" {
- singleDose, _ := strconv.ParseFloat(dataBody["single_dose"].(string), 64)
- advice.SingleDose = singleDose
- }
-
- if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := dataBody["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
-
- if dataBody["prescribing_number"] != nil && reflect.TypeOf(dataBody["prescribing_number"]).String() == "string" {
- prescribingNumber, _ := strconv.ParseFloat(dataBody["prescribing_number"].(string), 64)
- advice.PrescribingNumber = prescribingNumber
- }
-
- if dataBody["prescribing_number_unit"] != nil && reflect.TypeOf(dataBody["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := dataBody["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
-
- if dataBody["subAdviceForm"] != nil && reflect.TypeOf(dataBody["subAdviceForm"]).String() == "[]interface {}" {
- thisContagions, _ := dataBody["subAdviceForm"].([]interface{})
- if len(thisContagions) > 0 {
- for _, item := range thisContagions {
- items := item.(map[string]interface{})
- advice_name, _ := items["advice_name"].(string)
- advice_desc, _ := items["advice_desc"].(string)
- drug_spec_unit, _ := items["drug_spec_unit"].(string)
-
- prescribing_number_unit, _ := items["prescribing_number_unit"].(string)
- single_dose_unit, _ := items["single_dose_unit"].(string)
- prescribing_number, _ := strconv.ParseFloat(items["prescribing_number"].(string), 64)
- single_dose, _ := strconv.ParseFloat(items["single_dose"].(string), 64)
-
- advice := &models.DoctorAdvice{
- AdviceName: advice_name,
- AdviceDesc: advice_desc,
- SingleDose: single_dose,
- SingleDoseUnit: single_dose_unit,
- DrugSpecUnit: drug_spec_unit,
- PrescribingNumber: prescribing_number,
- PrescribingNumberUnit: prescribing_number_unit,
- }
- subAdvice = append(subAdvice, advice)
-
- }
- }
- }
-
- return
-
- }
-
- func (c *DialysisApiController) GetDialysisOrder() {
- //xtno := c.GetString("xtno")
- xtdate := c.GetString("xtdate")
- patient_id, _ := c.GetInt64("patient_id")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", xtdate+" 00:00:00", loc)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- xttime := theTime.Unix()
-
- operatorIDs := make([]int64, 0)
-
- adminUserInfo := c.GetAdminUserInfo()
-
- adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
-
- patientInfo, _ := service.FindPatientWithDeviceByPatientId(adminUserInfo.CurrentOrgId, patient_id, xttime)
-
- //透析单
- dialysisOrder, _ := service.MobileGetSchedualDialysisRecordTen(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- if dialysisOrder != nil {
- if dialysisOrder.FinishNurse > 0 {
- operatorIDs = append(operatorIDs, dialysisOrder.FinishNurse)
- }
- if dialysisOrder.StartNurse > 0 {
- operatorIDs = append(operatorIDs, dialysisOrder.StartNurse)
- }
- }
-
- //透前评估
- PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- predialysName, err := service.FindPredialysisName(PredialysisEvaluation.BloodAccessPartOperaId, adminUserInfo.CurrentOrgId)
- //透后评估
- AssessmentAfterDislysis, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- if AssessmentAfterDislysis.Modifier > 0 {
- operatorIDs = append(operatorIDs, AssessmentAfterDislysis.Modifier)
- }
- //上次透前评估
- lastPredialysisEvaluation, _ := service.GetLastTimePredialysisEvaluation(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- lastOrder, _ := service.GetLastTimeOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- //透析处方
- dialysisPrescription, _ := service.FindPatientPrescribeWidyDevideById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- if dialysisPrescription.PrescriptionDoctor > 0 {
- operatorIDs = append(operatorIDs, dialysisPrescription.PrescriptionDoctor)
- }
-
- //获取病人的透析模式
- schedule, err := service.FindDialysisMode(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- order, err := service.FindDialysisMacher(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- nurse, err := service.FindPunctureNurse(order.PunctureNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
-
- startNuse, err := service.FindeStartNuse(order.StartNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
-
- FinishNuse, err := service.FindeStartNuse(order.FinishNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
- //获取透析处方
- dialysisway, err := service.FindDialysisWay(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //获取临时医嘱
- doctorAdvice, _ := service.FindDoctorOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //config, err := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
-
- //获取医嘱内容
- doctor, err := service.FindDoctor(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
- DoctorName, err := service.FindDoctorName(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
-
- DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- doctorAdevieInfo, err := service.FindDoctorAdviceByInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- //获取上次的透后体重
- // assessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- assessmentAfterDislysis, _ := service.MobileGetLast(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- //获取透析次数
- _, total, err := service.GetTotalDialysisCout(adminUserInfo.CurrentOrgId, patientInfo.ID)
-
- if len(DoctorAdvice) > 0 {
- for _, item := range DoctorAdvice {
- if item.AdviceDoctor > 0 {
- operatorIDs = append(operatorIDs, item.AdviceDoctor)
- }
- if item.ExecutionStaff > 0 {
- operatorIDs = append(operatorIDs, item.ExecutionStaff)
- }
- if item.Checker > 0 {
- operatorIDs = append(operatorIDs, item.Checker)
- }
- }
- }
-
- //透析监测
- Record, _ := service.FindAllMonitorRecord(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //透析检测
- //monitor, err := service.FindAllMonitor(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //透析小结
- TreatmentSummary, _ := service.FindTreatmentSummaryById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- //接诊评估
- receiverTreatmentAccess, _ := service.FindReceiverTreatmentAccessRecordById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- if receiverTreatmentAccess.Condition == 1 {
- if len(receiverTreatmentAccess.AdmissionNumber) == 0 || receiverTreatmentAccess.AdmissionNumber == "" {
- lastAcceptTreatment, _ := service.GetLastAcceptTreatment(adminUserInfo.CurrentOrgId, patientInfo.ID)
- receiverTreatmentAccess.AdmissionNumber = lastAcceptTreatment.AdmissionNumber
- receiverTreatmentAccess.HisDepartment = lastAcceptTreatment.HisDepartment
- receiverTreatmentAccess.HisBed = lastAcceptTreatment.HisBed
- }
- }
-
- check, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- if adminUserInfo.CurrentOrgId != 10101 && adminUserInfo.CurrentOrgId != 10445 && adminUserInfo.CurrentOrgId != 10345 {
- dialysis_count, _ := service.GetDialysisOrderCount(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- patientInfo.TotalDialysis = dialysis_count
- }
- if adminUserInfo.CurrentOrgId == 10101 || adminUserInfo.CurrentOrgId == 10445 || adminUserInfo.CurrentOrgId == 10345 {
-
- if xttime <= 1703952000 {
- dialysis_count, _ := service.GetDialysisOrderCountOne(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- patientInfo.TotalDialysis = dialysis_count
- }
-
- if xttime >= 1704038400 {
- dialysis_count, _ := service.GetDialysisOrderCountTwo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- patientInfo.TotalDialysis = dialysis_count
- }
-
- }
-
- //相关操作对应的操作人
- //operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
- operators, err := service.GetAdminUserEsTwo(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
-
- //fmt.Println("operators------------------------------------", operators)
- templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- //获取当前日期月份的第一天
- firstmonth := service.GetFirstDateOfMonth(theTime)
- firstMonthDate := firstmonth.Unix()
- //获取当前月份的病人透析次数
- dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.CurrentOrgId)
-
- var hisAdvice []*models.HisDoctorAdviceInfo
-
- var his_advices_one []*models.HisDoctorAdviceInfo
- //获取his数据
- hisAdvice, _ = service.GetHisDoctorPatientById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- //针对茂名舒和
- if adminUserInfo.CurrentOrgId == 10666 || adminUserInfo.CurrentOrgId == 10644 {
- if len(hisAdvice) > 0 {
- for _, item := range hisAdvice {
- drug, _ := service.GetDrugIsShow(item.DrugId, adminUserInfo.CurrentOrgId)
- if drug.IsShow == 1 {
- his_advices_one = append(his_advices_one, item)
- }
- }
- }
- } else {
- if len(hisAdvice) > 0 {
- for _, item := range hisAdvice {
- his_advices_one = append(his_advices_one, item)
- }
- }
- }
-
- //hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- config, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
-
- project_config, _ := service.GetHisProjectConfig(adminUserInfo.CurrentOrgId)
-
- var projects []*models.HisPrescriptionProject
- projects, _ = service.FindAllHisProjectById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- var projectsOne []*models.HisPrescriptionProject
-
- //针对茂名舒和
- if adminUserInfo.CurrentOrgId == 10666 || adminUserInfo.CurrentOrgId == 10644 {
- if len(projects) > 0 {
- for _, item := range projects {
- if item.Type == 2 {
- if item.HisProject.IsShow == 1 {
- projectsOne = append(projectsOne, item)
- }
- }
-
- if item.Type == 3 {
- if item.GoodInfo.IsShow == 1 {
- projectsOne = append(projectsOne, item)
- }
- }
- }
- }
- } else {
- for _, item := range projects {
- projectsOne = append(projectsOne, item)
- }
- }
-
- //获取诊断
- prescriptionInfo, _ := service.GetPrescriptionInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- patientDiagnose, _ := service.FindPatientDianose(adminUserInfo.CurrentOrgId)
-
- lastSchedule, _ := service.FindLastSchedule(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- numberList, _ := service.GetAllBedNumberList(adminUserInfo.CurrentOrgId)
- //if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
- // for _, item := range projects {
- // var advice *models.HisDoctorAdviceInfo
- // advice.ID = item.ID
- // advice.Checker = item.Checker
- // advice.CheckTime = item.CheckTime
- // advice.CheckState = item.CheckState
- // advice.ExecutionState = item.ExecutionState
- // advice.ExecutionStaff = item.ExecutionStaff
- // advice.PrescribingNumber = float64(item.Count)
- // advice.PrescribingNumberUnit = item.Unit
- // advice.AdviceDoctor = item.Doctor
- // if item.Type == 3 {
- // advice.AdviceName = item.GoodInfo.GoodName
- // } else if item.Type == 2 {
- // advice.AdviceName = item.HisProject.ProjectName
- // }
- // advice.StartTime = item.StartTime
- // hisAdvice = append(hisAdvice, advice)
- // }
- //}
- if config.IsOpen == 1 {
- c.ServeSuccessJSON(map[string]interface{}{
- "xtdate": xtdate,
- "users": adminUser,
- "patientInfo": patientInfo,
- "PredialysisEvaluation": PredialysisEvaluation,
- "AssessmentAfterDislysis": AssessmentAfterDislysis,
- "dialysisPrescription": dialysisPrescription,
- "advices": his_advices_one,
- "monitors": Record,
- "summary": TreatmentSummary,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "dialysisOrder": dialysisOrder,
- "operators": operators,
- "org_template_info": templateInfo,
- "check": check,
- "schedule": schedule,
- "dialysisway": dialysisway,
- "order": order,
- "doctorAdvice": doctorAdvice,
- "doctor": doctor,
- "nurse": nurse,
- "doctorAdevieInfo": doctorAdevieInfo,
- "total": total,
- "startNuse": startNuse,
- "DoctorName": DoctorName,
- "assessmentAfterDislysis": assessmentAfterDislysis,
- "predialysName": predialysName,
- "FinishNuse": FinishNuse,
- "lastPredialysisEvaluation": lastPredialysisEvaluation,
- "dialysiscount": dialysiscount,
- "last_order": lastOrder,
- "project_config": project_config,
- "projects": projectsOne,
- "prescriptionInfo": prescriptionInfo,
- "patientDiagnose": patientDiagnose,
- "lastSchedule": lastSchedule,
- "numberList": numberList,
- })
-
- }
- if config.IsOpen == 0 || config.IsOpen == 2 {
- c.ServeSuccessJSON(map[string]interface{}{
- "xtdate": xtdate,
- "users": adminUser,
- "patientInfo": patientInfo,
- "PredialysisEvaluation": PredialysisEvaluation,
- "AssessmentAfterDislysis": AssessmentAfterDislysis,
- "dialysisPrescription": dialysisPrescription,
- "advices": DoctorAdvice,
- "monitors": Record,
- "summary": TreatmentSummary,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "dialysisOrder": dialysisOrder,
- "operators": operators,
- "org_template_info": templateInfo,
- "check": check,
- "schedule": schedule,
- "dialysisway": dialysisway,
- "order": order,
- "doctorAdvice": doctorAdvice,
- "doctor": doctor,
- "nurse": nurse,
- "doctorAdevieInfo": doctorAdevieInfo,
- "total": total,
- "startNuse": startNuse,
- "DoctorName": DoctorName,
- "assessmentAfterDislysis": assessmentAfterDislysis,
- "predialysName": predialysName,
- "FinishNuse": FinishNuse,
- "lastPredialysisEvaluation": lastPredialysisEvaluation,
- "dialysiscount": dialysiscount,
- "last_order": lastOrder,
- "project_config": project_config,
- "projects": projects,
- "prescriptionInfo": prescriptionInfo,
- "patientDiagnose": patientDiagnose,
- "lastSchedule": lastSchedule,
- "numberList": numberList,
- })
- }
-
- }
-
- func (c *DialysisApiController) GetLongAdvice() {
- patient_id, _ := c.GetInt64("patient_id")
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
-
- //patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
- if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有 不开启推送功能,不做任何处理
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "1",
- })
- return
- } else { //开启推送提醒
- //开启推送提醒逻辑 提交长期处方的时候,弹起长期医嘱推送
- var advice_three []*models.DoctorAdvice
- //groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
- recordDateStr := time.Now().Format("2006-01-02")
- recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
-
- nowtime := recordDate.Unix()
-
- advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, nowtime)
- advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, nowtime)
-
- for _, advice := range advices {
- if advice.FrequencyType == 3 {
- t := time.Now()
- week := int(t.Weekday())
-
- switch week {
- case 1:
- if strings.Index(advice.WeekDay, "周一") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 2:
- if strings.Index(advice.WeekDay, "周二") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 3:
- if strings.Index(advice.WeekDay, "周三") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 4:
- if strings.Index(advice.WeekDay, "周四") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- case 5:
- if strings.Index(advice.WeekDay, "周五") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- case 6:
- if strings.Index(advice.WeekDay, "周六") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 0:
- if strings.Index(advice.WeekDay, "周日") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- }
- }
- }
-
- for _, advice := range advices_two {
- p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
- now := p.Unix()
- dayStr := strconv.FormatInt(advice.DayCount, 10)
- dayStr2 := "-" + dayStr
- count, _ := strconv.ParseInt(dayStr2, 10, 64)
- oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
- advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
-
- for _, ad := range advices {
- advice_three = append(advice_three, ad)
- }
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "2",
- "advices": advices,
- "advices_two": RemoveRepeatedElement(advice_three),
- "is_open_remind": config.IsOpenRemind,
- })
- }
- }
-
- }
-
- func (c *DialysisApiController) GetLongAdviceOne() {
- patient_id, _ := c.GetInt64("patient_id")
- schedule_date := c.GetString("schedule_date")
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
- //patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
- if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有 不开启推送功能,不做任何处理
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "1",
- })
- return
- } else { //开启推送提醒
- //开启推送提醒逻辑 提交长期处方的时候,弹起长期医嘱推送
- var advice_three []*models.DoctorAdvice
- //groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
- //recordDateStr := time.Now().Format("2006-01-02")
- //recordDate, _ := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- //
- //nowtime := recordDate.Unix()
-
- advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, theTime.Unix())
- advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, theTime.Unix())
-
- for _, advice := range advices {
- if advice.FrequencyType == 3 {
- t := time.Now()
- week := int(t.Weekday())
-
- switch week {
- case 1:
- if strings.Index(advice.WeekDay, "周一") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 2:
- if strings.Index(advice.WeekDay, "周二") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 3:
- if strings.Index(advice.WeekDay, "周三") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 4:
- if strings.Index(advice.WeekDay, "周四") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- case 5:
- if strings.Index(advice.WeekDay, "周五") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- case 6:
- if strings.Index(advice.WeekDay, "周六") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 0:
- if strings.Index(advice.WeekDay, "周日") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- }
- }
- }
-
- for _, advice := range advices_two {
- p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
- now := p.Unix()
-
- dayStr := strconv.FormatInt(advice.DayCount, 10)
- dayStr2 := "-" + dayStr
- count, _ := strconv.ParseInt(dayStr2, 10, 64)
- oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
- fmt.Println("oldTime--------------------------", oldTime)
- advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
- fmt.Println("advices-------------------------", advices)
- for _, ad := range advices {
- advice_three = append(advice_three, ad)
- }
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "2",
- "advices": advices,
- "advices_two": RemoveRepeatedElement(advice_three),
- "is_open_remind": config.IsOpenRemind,
- })
- }
- }
-
- }
-
- func (c *DialysisApiController) GetLongAdviceTwo() {
- patient_id, _ := c.GetInt64("patient_id")
- schedule_date, _ := c.GetInt64("schedule_date")
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
-
- //patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
- if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有 不开启推送功能,不做任何处理
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "1",
- })
- return
- } else { //开启推送提醒
- //开启推送提醒逻辑 提交长期处方的时候,弹起长期医嘱推送
- var advice_three []*models.DoctorAdvice
- //groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
- advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id, schedule_date)
- advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id, schedule_date)
-
- for _, advice := range advices {
- if advice.FrequencyType == 3 {
- t := time.Now()
- week := int(t.Weekday())
-
- switch week {
- case 1:
- if strings.Index(advice.WeekDay, "周一") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 2:
- if strings.Index(advice.WeekDay, "周二") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 3:
- if strings.Index(advice.WeekDay, "周三") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 4:
- if strings.Index(advice.WeekDay, "周四") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- case 5:
- if strings.Index(advice.WeekDay, "周五") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- case 6:
- if strings.Index(advice.WeekDay, "周六") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 0:
- if strings.Index(advice.WeekDay, "周日") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- }
- }
- }
-
- for _, advice := range advices_two {
- p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
- now := p.Unix()
- fmt.Println("now-------------------------", now)
- dayStr := strconv.FormatInt(advice.DayCount, 10)
- dayStr2 := "-" + dayStr
- count, _ := strconv.ParseInt(dayStr2, 10, 64)
- oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
- fmt.Println("oldTime--------------------------", oldTime)
- advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
-
- for _, ad := range advices {
- advice_three = append(advice_three, ad)
- }
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "2",
- "advices": advices,
- "advices_two": RemoveRepeatedElement(advice_three),
- "is_open_remind": config.IsOpenRemind,
- })
- }
- }
-
- }
-
- func RemoveRepeatedElement(arr []*models.DoctorAdvice) (newArr []*models.DoctorAdvice) {
- newArr = make([]*models.DoctorAdvice, 0)
- for i := 0; i < len(arr); i++ {
- repeat := false
- for j := i + 1; j < len(arr); j++ {
- if arr[i].ID == arr[j].ID {
- repeat = true
- break
- }
- }
- if !repeat {
- newArr = append(newArr, arr[i])
- }
- }
- return
- }
-
- func (c *DialysisApiController) CreateRemindDoctorAdvice() {
-
- patient, _ := c.GetInt64("id", 0)
- groupNo, _ := c.GetInt64("groupno", 0)
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- return
- }
- utils.ErrorLog("%v", dataBody)
-
- timeLayout := "2006-01-02 15:04"
- loc, _ := time.LoadLocation("Local")
-
- timeLayout2 := "2006-01-02"
- loc2, _ := time.LoadLocation("Local")
-
- if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
- utils.ErrorLog("advice_type")
- return
- }
- adviceType := int64(2)
-
- if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
- utils.ErrorLog("advice_date")
- return
- }
- adviceDate, _ := dataBody["advice_date"].(string)
- theTime, err := time.ParseInLocation(timeLayout2, adviceDate, loc2)
-
- AdviceDate := theTime.Unix()
- RecordDate := theTime.Unix()
-
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- return
- }
- startTime, _ := dataBody["start_time"].(string)
- if len(startTime) == 0 {
- utils.ErrorLog("len(start_time) == 0")
- return
- }
- theTimeUnix, err := time.ParseInLocation(timeLayout, startTime, loc)
-
- fmt.Println("theTimeUnix", theTimeUnix.Unix())
- //if err != nil {
- // utils.ErrorLog(err.Error())
- // return
- //}
- StartTime := theTimeUnix.Unix()
- fmt.Println("startTIME", StartTime)
- Remark := ""
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark, _ := dataBody["remark"].(string)
- Remark = remark
- }
-
- var advices []*models.GroupAdvice
- if dataBody["advices"] == nil || reflect.TypeOf(dataBody["advices"]).String() != "[]interface {}" {
- utils.ErrorLog("advices")
- return
- }
- adviceNames := dataBody["advices"].([]interface{})
- for _, adviceNameMap := range adviceNames {
- adviceNameM := adviceNameMap.(map[string]interface{})
- var advice models.GroupAdvice
- advice.Remark = Remark
- advice.AdviceType = adviceType
-
- advice.StartTime = StartTime
- if advice.StartTime < 0 {
- advice.StartTime = time.Now().Unix()
- }
- advice.AdviceDate = AdviceDate
-
- advice.RecordDate = RecordDate
- advice.Status = 1
- advice.CreatedTime = time.Now().Unix()
- advice.UpdatedTime = time.Now().Unix()
- advice.StopState = 2
- advice.ExecutionState = 2
- advice.UserOrgId = adminUserInfo.CurrentOrgId
- advice.PatientId = patient
- advice.AdviceDoctor = adminUserInfo.AdminUser.Id
- advice.IsSettle = 2
- if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
- utils.ErrorLog("advice_name")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adviceName, _ := adviceNameM["advice_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advice.AdviceName = adviceName
-
- if adviceNameM["drug_spec"] != nil && reflect.TypeOf(adviceNameM["drug_spec"]).String() == "string" {
- drugSpec, _ := strconv.ParseFloat(adviceNameM["drug_spec"].(string), 64)
- advice.DrugSpec = drugSpec
- }
-
- if adviceNameM["advice_desc"] != nil && reflect.TypeOf(adviceNameM["advice_desc"]).String() == "string" {
- adviceDesc, _ := adviceNameM["advice_desc"].(string)
- advice.AdviceDesc = adviceDesc
- }
-
- if adviceNameM["drug_spec_unit"] != nil && reflect.TypeOf(adviceNameM["drug_spec_unit"]).String() == "string" {
- drugSpecUnit, _ := adviceNameM["drug_spec_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
-
- //if adviceNameM["single_dose"] != nil && reflect.TypeOf(adviceNameM["single_dose"]).String() == "string" {
- // singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
- // advice.SingleDose = singleDose
- //}
-
- if adviceNameM["single_dose"] != nil || reflect.TypeOf(adviceNameM["single_dose"]).String() == "float64" {
- //single_dose := int64(adviceNameM["single_dose"].(float64))
- advice.SingleDose = adviceNameM["single_dose"].(float64)
- }
-
- if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := adviceNameM["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
-
- //if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
- // prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
- // advice.PrescribingNumber = prescribingNumber
- //}
-
- if adviceNameM["prescribing_number"] != nil || reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "float64" {
-
- advice.PrescribingNumber = adviceNameM["prescribing_number"].(float64)
- }
-
- if adviceNameM["prescribing_number_unit"] != nil && reflect.TypeOf(adviceNameM["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := adviceNameM["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
- if adviceNameM["delivery_way"] != nil && reflect.TypeOf(adviceNameM["delivery_way"]).String() == "string" {
- deliveryWay, _ := adviceNameM["delivery_way"].(string)
- advice.DeliveryWay = deliveryWay
- }
-
- if adviceNameM["execution_frequency"] != nil && reflect.TypeOf(adviceNameM["execution_frequency"]).String() == "string" {
- executionFrequency, _ := adviceNameM["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
-
- if adviceNameM["frequency_type"] != nil || reflect.TypeOf(adviceNameM["frequency_type"]).String() == "float64" {
- frequency_type := int64(adviceNameM["frequency_type"].(float64))
- advice.FrequencyType = frequency_type
- }
-
- if adviceNameM["day_count"] != nil || reflect.TypeOf(adviceNameM["day_count"]).String() == "float64" {
- day_count := int64(adviceNameM["day_count"].(float64))
- advice.DayCount = day_count
- }
-
- if adviceNameM["way"] != nil || reflect.TypeOf(adviceNameM["way"]).String() == "float64" {
- way := int64(adviceNameM["way"].(float64))
- advice.Way = way
- }
-
- if adviceNameM["drug_id"] != nil || reflect.TypeOf(adviceNameM["drug_id"]).String() == "float64" {
- drug_id := int64(adviceNameM["drug_id"].(float64))
- advice.DrugId = drug_id
- }
-
- if adviceNameM["drug_name_id"] != nil || reflect.TypeOf(adviceNameM["drug_name_id"]).String() == "float64" {
- drug_name_id := int64(adviceNameM["drug_name_id"].(float64))
- advice.DrugNameId = drug_name_id
- }
-
- if adviceNameM["week_day"] != nil && reflect.TypeOf(adviceNameM["week_day"]).String() == "string" {
- week_day, _ := adviceNameM["week_day"].(string)
- advice.WeekDay = week_day
- }
-
- if adviceNameM["template_id"] != nil && reflect.TypeOf(adviceNameM["template_id"]).String() == "string" {
- template_id, _ := adviceNameM["template_id"].(string)
- advice.TemplateId = template_id
- }
-
- if adviceNameM["execution_frequency"] != nil && reflect.TypeOf(adviceNameM["execution_frequency"]).String() == "string" {
- executionFrequency, _ := adviceNameM["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
-
- if adviceNameM["child"] != nil && reflect.TypeOf(adviceNameM["child"]).String() == "[]interface {}" {
- children := adviceNameM["child"].([]interface{})
- if len(children) > 0 {
- for _, childrenMap := range children {
- childMap := childrenMap.(map[string]interface{})
- var child models.GroupAdvice
- child.Remark = Remark
- child.AdviceType = adviceType
- child.StartTime = StartTime
- if child.StartTime < 0 {
- child.StartTime = time.Now().Unix()
- }
- child.AdviceDate = AdviceDate
- child.RecordDate = RecordDate
- child.Status = 1
- child.CreatedTime = time.Now().Unix()
- child.UpdatedTime = time.Now().Unix()
- child.StopState = 2
- child.ExecutionState = 2
- child.UserOrgId = adminUserInfo.CurrentOrgId
- child.PatientId = patient
- child.AdviceDoctor = adminUserInfo.AdminUser.Id
- child.IsSettle = 2
- if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
- utils.ErrorLog("child advice_name")
- return
- }
- childAdviceName, _ := childMap["advice_name"].(string)
- if len(childAdviceName) == 0 {
- utils.ErrorLog("len(child advice_name) == 0")
- return
- }
- child.AdviceName = childAdviceName
-
- if childMap["advice_desc"] != nil && reflect.TypeOf(childMap["advice_desc"]).String() == "string" {
- childAdviceDesc, _ := childMap["advice_desc"].(string)
- child.AdviceDesc = childAdviceDesc
- }
-
- if childMap["drug_spec"] != nil && reflect.TypeOf(childMap["drug_spec"]).String() == "string" {
- childDrugSpec, _ := strconv.ParseFloat(childMap["drug_spec"].(string), 64)
- child.DrugSpec = childDrugSpec
- }
-
- if childMap["drug_spec_unit"] != nil && reflect.TypeOf(childMap["drug_spec_unit"]).String() == "string" {
- childDrugSpecUnit, _ := childMap["drug_spec_unit"].(string)
- child.DrugSpecUnit = childDrugSpecUnit
- }
-
- if childMap["single_dose"] != nil && reflect.TypeOf(childMap["single_dose"]).String() == "string" {
- childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
- child.SingleDose = childSingleDose
- }
- if childMap["single_dose"] != nil && reflect.TypeOf(childMap["single_dose"]).String() == "float64" {
- //childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
- child.SingleDose = childMap["single_dose"].(float64)
- }
- if childMap["remark"] != nil && reflect.TypeOf(childMap["remark"]).String() == "string" {
- //childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
- child.Remark = childMap["remark"].(string)
- }
- if childMap["drug_id"] != nil && reflect.TypeOf(childMap["drug_id"]).String() == "float64" {
- //childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
- child.DrugId = int64(childMap["drug_id"].(float64))
- }
-
- if childMap["single_dose_unit"] != nil && reflect.TypeOf(childMap["single_dose_unit"]).String() == "string" {
- childSingleDoseUnit, _ := childMap["single_dose_unit"].(string)
- child.SingleDoseUnit = childSingleDoseUnit
- }
-
- if childMap["prescribing_number"] != nil && reflect.TypeOf(childMap["prescribing_number"]).String() == "string" {
- childPrescribingNumber, _ := strconv.ParseFloat(childMap["prescribing_number"].(string), 64)
- child.PrescribingNumber = childPrescribingNumber
- }
- if childMap["prescribing_number"] != nil && reflect.TypeOf(childMap["prescribing_number"]).String() == "float64" {
- //childPrescribingNumber, _ := strconv.ParseFloat(childMap["prescribing_number"].(string), 64)
- child.PrescribingNumber = childMap["prescribing_number"].(float64)
- }
-
- if childMap["prescribing_number_unit"] != nil && reflect.TypeOf(childMap["prescribing_number_unit"]).String() == "string" {
- childPrescribingNumberUnit, _ := childMap["prescribing_number_unit"].(string)
- child.PrescribingNumberUnit = childPrescribingNumberUnit
- }
-
- child.DeliveryWay = advice.DeliveryWay
- child.ExecutionFrequency = advice.ExecutionFrequency
- advice.Children = append(advice.Children, &child)
- }
- }
- }
-
- advices = append(advices, &advice)
- }
-
- list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
-
- for _, item := range advices {
- //记录日志
- byterequest, _ := json.Marshal(item)
- adviceLog := models.XtDoctorAdviceLog{
- UserOrgId: item.UserOrgId,
- PatientId: item.PatientId,
- AdminUserId: adminUserInfo.AdminUser.Id,
- Module: 1,
- ErrLog: string(byterequest),
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Source: "电脑端医嘱推送",
- RecordDate: item.AdviceDate,
- }
- service.CreateDoctorAdviceLog(adviceLog)
- }
-
- //创建步骤表
- finish := models.XtDialysisFinish{
- IsFinish: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- Module: 4,
- RecordDate: AdviceDate,
- Sourse: 1,
- PatientId: patient,
- }
-
- dialysisFinish, _ := service.GetDialysisFinish(adminUserInfo.CurrentOrgId, AdviceDate, 4, patient)
- if dialysisFinish.ID == 0 {
- service.CreateDialysisFinish(finish)
- }
- redis := service.RedisClient()
- formatAdviceDate := theTime.Format("2006-01-02")
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":advice_list_all"
- redis.Set(key, "", time.Second)
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient, 10) + ":" + strconv.FormatInt(AdviceDate, 10) + ":doctor_advices"
- redis.Set(keyOne, "", time.Second)
- keyFour := "scheduals_" + formatAdviceDate + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- redis.Set(keyFour, "", time.Second)
- defer redis.Close()
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advices": list,
- })
-
- return
-
- }
-
- func (c *DialysisApiController) GetSolution() {
- patient_id, _ := c.GetInt64("patient_id")
- mode_id, _ := c.GetInt64("mode_id")
-
- adminUserInfo := c.GetAdminUserInfo()
-
- solution, err := service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.CurrentOrgId, patient_id, mode_id)
- prescription, err := service.MobileGetLastDialysisPrescribeByModeIdTen(adminUserInfo.CurrentOrgId, patient_id, mode_id)
- system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.CurrentOrgId, mode_id)
- dialysisPrescription, _ := service.MobileGetLastDialysisPrescription(patient_id, adminUserInfo.CurrentOrgId)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "solution": solution,
- "prescription": prescription,
- "system_prescription": system_prescription,
- "dialysisPrescription": dialysisPrescription,
- })
-
- }
-
- func (c *DialysisApiController) GetSchedule() {
- schedual_type, _ := c.GetInt64("schedual_type")
- adminUserInfo := c.GetAdminUserInfo()
-
- //timeLayout := "2006-01-02 15:04:05"
- //
- //date := time.Now().Format("2006-01-02") + " 00:00:00"
- //loc, _ := time.LoadLocation("Local")
- //theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
- //scheduleTime := theStartTime.Unix()
- scheduleTime, _ := c.GetInt64("record_date")
-
- deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.CurrentOrgId, scheduleTime, schedual_type)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "number": deviceNumber,
- })
-
- }
-
- func (this *DialysisApiController) GetTodayMonitor() {
- thisTime := time.Now()
- scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- theAssessmentDateTime := theStartTime.Unix()
-
- patientID, _ := this.GetInt64("patient_id")
- monitorDate, _ := this.GetInt64("monitoring_date", theAssessmentDateTime)
- adminInfo := this.GetAdminUserInfo()
- record, _ := service.FindLastMonitorRecordToday(patientID, adminInfo.CurrentOrgId, monitorDate)
- fristrecord, _ := service.FindFirstMonitorRecordToday(patientID, adminInfo.CurrentOrgId, monitorDate)
-
- template, _ := service.GetOrgInfoTemplate(adminInfo.CurrentOrgId)
-
- var ultrafiltration_rate float64
- _, prescription := service.FindDialysisPrescriptionByReordDate(patientID, theAssessmentDateTime, adminInfo.CurrentOrgId)
- //针对福建医师汇 获取透前评估预增脱水量
-
- _, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, theAssessmentDateTime, adminInfo.CurrentOrgId)
- fmt.Println("透前评估数据", evaluation)
-
- if prescription.ID > 0 {
- if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
-
- totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
- if template.TemplateId == 6 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
- if template.TemplateId == 6 && adminInfo.CurrentOrgId == 10121 {
-
- dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
- ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
-
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if template.TemplateId == 6 && adminInfo.CurrentOrgId == 10234 {
-
- dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
- ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
-
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if template.TemplateId == 41 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if template.TemplateId == 43 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if template.TemplateId == 46 || template.TemplateId == 54 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if template.TemplateId == 47 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- // 只针对方济医院
- if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
- value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
- ultrafiltration_rate = value
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- //长沙南雅
- if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10340 || adminInfo.CurrentOrgId == 10432 || adminInfo.CurrentOrgId == 10441 || adminInfo.CurrentOrgId == 10445 || adminInfo.CurrentOrgId == 9829 || adminInfo.CurrentOrgId == 10440 || adminInfo.CurrentOrgId == 10469 || adminInfo.CurrentOrgId == 10471 {
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration * 60 / 1000 / float64(totalMin) * 1000)
-
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if adminInfo.CurrentOrgId == 10694 || adminInfo.CurrentOrgId == 10697 {
-
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
- ultrafiltration_rate = ultrafiltration_rate
- }
-
- }
- }
- // record.UltrafiltrationRate = ultrafiltration_rate
-
- record.UltrafiltrationVolume = 0
-
- if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
- if ultrafiltration_rate > 0 {
- value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", float64(record.OperateTime+3600-fristrecord.OperateTime)/3600*ultrafiltration_rate), 6)
- record.UltrafiltrationVolume = value
- }
- }
-
- 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 {
- if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
- ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
-
- record.UltrafiltrationVolume = ultrafiltration_volume
- }
-
- }
-
- //长沙南雅
- if adminInfo.CurrentOrgId == 10395 || adminInfo.CurrentOrgId == 10138 || adminInfo.CurrentOrgId == 10278 || adminInfo.CurrentOrgId == 10432 || adminInfo.CurrentOrgId == 10441 || adminInfo.CurrentOrgId == 10445 || adminInfo.CurrentOrgId == 10469 || adminInfo.CurrentOrgId == 10471 {
-
- if ultrafiltration_rate > 0 {
- ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
-
- record.UltrafiltrationVolume = ultrafiltration_volume
- }
- }
-
- if template.TemplateId == 47 || template.TemplateId == 54 {
- record.DisplacementQuantity = record.DisplacementQuantity + record.DisplacementQuantity
- }
-
- if adminInfo.CurrentOrgId == 10697 || adminInfo.CurrentOrgId == 10694 {
- ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate * 1000)
- record.UltrafiltrationVolume = ultrafiltration_volume / 1000
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "monitor": record,
- })
-
- }
-
- func (c *DialysisApiController) UploadDryWeight() {
- patient_id, _ := c.GetInt64("id")
- dry_weight, _ := c.GetFloat("dry_weight")
- doctor_id, _ := c.GetInt64("doctor_id")
- remark := c.GetString("remark")
- adminUserInfo := c.GetAdminUserInfo()
- weightAdjust, err := service.FindLastDryWeightAdjust(adminUserInfo.CurrentOrgId, patient_id)
- fmt.Println(err)
- if err == gorm.ErrRecordNotFound {
- dryWeight := &models.SgjPatientDryweight{
- PatientId: patient_id,
- DryWeight: dry_weight,
- Remakes: remark,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Creator: doctor_id,
- Status: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- AdjustedValue: "/",
- UserId: adminUserInfo.AdminUser.Id,
- }
- createErr := service.CreatePatientWeightAdjust(dryWeight)
- loc, _ := time.LoadLocation("Local")
- nowTime := time.Now()
- nowDay := nowTime.Format("2006-01-02")
- dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
- redis := service.RedisClient()
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
- redis.Set(keyOne, "", time.Second)
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
-
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
- redis.Set(keyTwo, "", time.Second)
- redis.Close()
- if createErr == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "提交成功",
- "weight": dryWeight,
- })
- }
-
- } else {
- dryWeight := &models.SgjPatientDryweight{
- PatientId: patient_id,
- DryWeight: dry_weight,
- Remakes: remark,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Creator: doctor_id,
- Status: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- AdjustedValue: "/",
- UserId: adminUserInfo.AdminUser.Id,
- }
- var value float64
- value = dry_weight - weightAdjust.DryWeight
- fmt.Println(value)
-
- if value < 0 {
- dryWeight.AdjustedValue = strconv.FormatFloat(math.Abs(value), 'f', 1, 64) + "(下调)"
- } else if value == 0 {
- dryWeight.AdjustedValue = "/"
- } else if value > 0 {
- dryWeight.AdjustedValue = strconv.FormatFloat(value, 'f', 1, 64) + "(上调)"
- }
- fmt.Println(value)
-
- createErr := service.CreatePatientWeightAdjust(dryWeight)
-
- //康桥
- if adminUserInfo.CurrentOrgId == 10702 || adminUserInfo.CurrentOrgId == 10164 || adminUserInfo.CurrentOrgId == 10721 {
- timeNowStr := time.Now().Format("2006-01-02")
- timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
-
- beforAssesment, _ := service.GetPatientAssesmentBefor(patient_id, timeNewDate.Unix(), adminUserInfo.CurrentOrgId)
-
- dialysisPrescription, _ := service.GetPatientDialysisPrescription(patient_id, timeNewDate.Unix(), adminUserInfo.CurrentOrgId)
-
- if beforAssesment.ID > 0 {
-
- service.UpdatePatientAssesmentBefor(beforAssesment.ID, dry_weight)
-
- var dewater_amount float64
-
- dewater_amount = beforAssesment.WeightBefore - dry_weight - beforAssesment.AdditionalWeight
-
- service.UpdatePatientDialysisPrscription(dialysisPrescription.ID, dewater_amount)
- //获取key,清空redis
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_prescribe"
- redis := service.RedisClient()
-
- //清空key 值
- redis.Set(key, "", time.Second)
-
- keyOne := "scheduals_" + timeNowStr + "_" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10)
- //清空key 值
- redis.Set(keyOne, "", time.Second)
-
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dialysisPrescription.ModeId, 10) + ":dialysis_solution"
- //清空key 值
- redis.Set(keyTwo, "", time.Second)
-
- keySix := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":prescriptions_list_all"
- redis.Set(keySix, "", time.Second)
-
- keySeven := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(timeNewDate.Unix(), 10) + ":dialysis_prescribe_by_mode"
- redis.Set(keySeven, "", time.Second)
- }
-
- }
-
- loc, _ := time.LoadLocation("Local")
- nowTime := time.Now()
- nowDay := nowTime.Format("2006-01-02")
- dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
- redis := service.RedisClient()
- keyOne := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
- redis.Set(keyOne, "", time.Second)
-
- key := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + ":" + strconv.FormatInt(patient_id, 10) + ":last_dry_weight"
- redis.Set(keyTwo, "", time.Second)
- redis.Close()
- if createErr == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "提交成功",
- "weight": dryWeight,
- })
- }
- }
-
- }
-
- func (this *DialysisApiController) GetFuncPurview() {
- adminUserInfo := this.GetAdminUserInfo()
- user_id := adminUserInfo.AdminUser.Id
- app_id := adminUserInfo.CurrentAppId
- org_id := adminUserInfo.CurrentOrgId
- create_url := this.GetString("create_url")
- modify_url := this.GetString("modify_url")
- modify_other_url := this.GetString("modify_other_url")
- del_url := this.GetString("del_url")
- del_other_url := this.GetString("del_other_url")
- exce_url := this.GetString("exce_url")
- check_url := this.GetString("check_url")
- modify_exce_url := this.GetString("modify_exce_url")
- module, _ := this.GetInt64("module", 0)
-
- app_role, _ := service.GetAppRole(org_id, app_id, user_id)
- var is_has_create bool
- var is_has_modify bool
- var is_has_modify_other bool
- var is_has_del bool
- var is_has_del_other bool
- var is_has_exce bool
- var is_has_check bool
- var is_has_modify_exce bool
-
- org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
-
- if adminUserInfo.AdminUser.Id != org.Creator {
-
- if app_role != nil {
- if len(app_role.RoleIds) > 0 {
- roles := strings.Split(app_role.RoleIds, ",")
- var userRolePurviews string
- for _, item := range roles {
- role_id, _ := strconv.ParseInt(item, 10, 64)
- purviews, _ := service.GetRoleFuncPurviewIds(role_id)
- if len(userRolePurviews) == 0 {
- userRolePurviews = purviews
- } else {
- userRolePurviews = userRolePurviews + "," + purviews
- }
- }
- userRolePurviewsArr := RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
- funcPurviews, _ := service.FindAllFuncPurview(userRolePurviewsArr)
- for _, item := range funcPurviews {
- //for _, url := range strings.Split(item.Urlfor,","){
- if strings.Split(item.Urlfor, ",")[1] == create_url {
- is_has_create = true
- }
- if strings.Split(item.Urlfor, ",")[1] == modify_url {
- is_has_modify = true
- }
- if strings.Split(item.Urlfor, ",")[1] == modify_other_url {
- is_has_modify_other = true
- }
- if strings.Split(item.Urlfor, ",")[1] == del_url {
- is_has_del = true
- }
- if strings.Split(item.Urlfor, ",")[1] == del_other_url {
- is_has_del_other = true
- }
- if strings.Split(item.Urlfor, ",")[1] == exce_url {
- is_has_exce = true
- }
- if strings.Split(item.Urlfor, ",")[1] == check_url {
- is_has_check = true
- }
- if strings.Split(item.Urlfor, ",")[1] == modify_exce_url {
- is_has_modify_exce = true
- }
-
- }
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRole)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "is_has_create": is_has_create,
- "is_has_modify": is_has_modify,
- "is_has_modify_other": is_has_modify_other,
- "is_has_del": is_has_del,
- "is_has_del_other": is_has_del_other,
- "is_has_exce": is_has_exce,
- "is_has_check": is_has_check,
- "is_has_modify_exce": is_has_modify_exce,
- "module": module,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
- return
- }
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_has_create": true,
- "is_has_modify": true,
- "is_has_modify_other": true,
- "is_has_del": true,
- "is_has_del_other": true,
- "is_has_exce": true,
- "is_has_check": true,
- "is_has_modify_exce": true,
- "module": true,
- })
- }
- }
-
- func (this *DialysisApiController) GetOrderDoctorAdvice() {
- patient_id, _ := this.GetInt64("patient_id", 0)
- advice_date, _ := this.GetInt64("advice_date")
- adminUserInfo := this.GetAdminUserInfo()
- doctorAdvice, _ := service.GetBloodDoctorAdvice(advice_date, adminUserInfo.CurrentOrgId, patient_id)
- hisDoctorAdvice, _ := service.GetHisDoctorAdvice(advice_date, adminUserInfo.CurrentOrgId, patient_id)
-
- this.ServeSuccessJSON(map[string]interface{}{
-
- "doctorAdvice": doctorAdvice,
- "hisDoctorAdvice": hisDoctorAdvice,
- })
-
- }
-
- func (this *DialysisApiController) GetLastOrNextDoctorAdvice() {
- change_type, _ := this.GetInt64("type", 0)
- record_date := this.GetString("record_time")
- patient_id, _ := this.GetInt64("patient_id", 0)
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
- record_time := theAdviceRecordTime.Unix()
- adminUserInfo := this.GetAdminUserInfo()
- advices, sch, err := service.GetDoctorAdviceByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
-
- if err == nil {
- if len(advices) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
- return
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "advices": advices,
- "schedule": sch,
- })
- return
- }
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *DialysisApiController) GetDialysisGoods() {
- schedualDate := c.GetString("schedule_date")
- schedule_type, _ := c.GetInt64("schedule_type")
- partition_id, _ := c.GetInt64("partition_id")
- page, _ := c.GetInt("page")
- limit, _ := c.GetInt("limit")
- keywords := c.GetString("keywords")
-
- patient_id, _ := c.GetInt64("patient_id")
-
- good_type, _ := c.GetInt64("good_type")
-
- date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
- if parseDateErr != nil && len(schedualDate) != 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- schedualEndDate := int64(0)
-
- endDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", schedualDate+" 23:59:59")
- if parseDateErr != nil && len(schedualDate) != 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedualEndDate = endDate.Unix()
-
- adminUser := c.GetAdminUserInfo()
-
- _, err := service.FindStockOutByIsSys(adminUser.CurrentOrgId, 1, date.Unix())
-
- goodTypes, _ := service.FindAllGoodType(adminUser.CurrentOrgId)
-
- if err == gorm.ErrRecordNotFound {
- list, _ := service.GetDialysisGood(adminUser.CurrentOrgId, date.Unix())
- var ids []int64
- for _, item := range list {
- ids = append(ids, item.PatientId)
- }
-
- dialysisGoods, _, total := service.PCGetDialysisGoods(adminUser.CurrentOrgId, date.Unix(), schedule_type, partition_id, page, limit, patient_id, keywords, schedualEndDate, good_type, ids)
- for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
- goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.CurrentOrgId, date.Unix())
- lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.CurrentOrgId, date.Unix())
- item.LastAutomaticReduceDetail = goodUser
- item.LastDialysisBeforePrepare = lastGoodUserDetial
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "dialysis_goods": dialysisGoods,
- "good_type": goodTypes,
- "total": total,
- })
- return
-
- } else if err == nil {
- //获取当天排班的每个患者的库存使用情况
- list, _ := service.GetDialysisGood(adminUser.CurrentOrgId, date.Unix())
- var ids []int64
- for _, item := range list {
- ids = append(ids, item.PatientId)
- }
-
- dialysisGoods, err, total := service.PCGetDialysisGoods(adminUser.CurrentOrgId, date.Unix(), schedule_type, partition_id, page, limit, patient_id, keywords, schedualEndDate, good_type, ids)
- for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
- goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.CurrentOrgId, date.Unix())
- lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.CurrentOrgId, date.Unix())
-
- fmt.Println(goodUser)
- fmt.Println(lastGoodUserDetial)
-
- item.LastAutomaticReduceDetail = goodUser
- item.LastDialysisBeforePrepare = lastGoodUserDetial
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "dialysis_goods": dialysisGoods,
- "good_type": goodTypes,
- "total": total,
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
- func (c *DialysisApiController) GetDialysisGoodsStatistics() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var theStartTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theStartTime = theTime.Unix()
- }
- var theEndtTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theEndtTime = theTime.Unix()
- }
-
- adminUser := c.GetAdminUserInfo()
- outInfo, err := service.MobileGetGoodsStatistics(adminUser.CurrentOrgId, theStartTime, theEndtTime)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "stock_out": outInfo,
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
-
- func (c *DialysisApiController) GetRoleList() {
-
- orgId := c.GetAdminUserInfo().CurrentOrgId
- admin_user_id, _ := c.GetInt64("admin_user_id")
- list, err := service.GetRoleList(orgId, admin_user_id)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "adminRole": list,
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *DialysisApiController) GetInitPrintData() {
-
- patient_id, _ := c.GetInt64("patient_id")
- record_date, _ := c.GetInt64("record_date")
- orgId := c.GetAdminUserInfo().CurrentOrgId
- list, err := service.GetInitPrintData(patient_id, record_date, orgId)
- assessmentAfterDislysis, _ := service.GetLastWeightAfter(patient_id, record_date, orgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "assessmentAfterDislysis": assessmentAfterDislysis,
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *DialysisApiController) GetInitPrintDataOne() {
-
- patient_id, _ := c.GetInt64("patient_id")
- start_time := c.GetString("record_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var theStartTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theStartTime = theTime.Unix()
- }
- orgId := c.GetAdminUserInfo().CurrentOrgId
- list, err := service.GetInitPrintData(patient_id, theStartTime, orgId)
- assessmentAfterDislysis, _ := service.GetLastWeightAfter(patient_id, theStartTime, orgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "assessmentAfterDislysis": assessmentAfterDislysis,
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- // 新接口
- func (this *DialysisApiController) GetPatientDialysisSolutionGroupList() {
-
- keyword := this.GetString("keywords")
-
- limit, _ := this.GetInt64("limit")
-
- page, _ := this.GetInt64("page")
-
- partition_id, _ := this.GetInt64("partition_id")
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- start_time := this.GetString("schedule_date")
-
- advice_ids := this.GetString("ids")
- var ids []string
- if advice_ids != "" {
- ids = strings.Split(advice_ids, ",")
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- _, config := service.FindXTHisRecordByOrgId(orgId)
-
- goodType, _ := service.GetAllGoodType(orgId)
- if config.IsOpen != 1 {
- list, total, err := service.GetPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "config": config,
- "goodType": goodType,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
- if config.IsOpen == 1 {
- list, total, err := service.GetHisPatientDialysisSolutionGroupList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, ids)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "config": config,
- "goodType": goodType,
- })
- return
- }
-
- }
-
- }
-
- func (this *DialysisApiController) GetDialysisAdviceTemplateList() {
-
- keyword := this.GetString("keywords")
-
- limit, _ := this.GetInt64("limit")
-
- page, _ := this.GetInt64("page")
-
- partition_id, _ := this.GetInt64("partition_id")
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- start_time := this.GetString("schedule_date")
-
- ids := this.GetString("ids")
-
- var idArray []string
- if ids != "" {
- idArray = strings.Split(ids, ",")
- }
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- list, total, err := service.GetDialysisAdviceTemplateList(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
-
- tablelist, _, err := service.GetDialysisAdviceSchedulistSix(keyword, limit, page, partition_id, schedule_type, startTime.Unix(), orgId, idArray)
- //获取长期医嘱
- adviceList, _ := service.GetAllLongAdviceList(orgId)
-
- _, config := service.FindXTHisRecordByOrgId(orgId)
-
- drugList, _ := service.GetAllBaseDrugListTwenty(orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "adviceList": adviceList,
- "config": config,
- "drugList": drugList,
- "tablelist": tablelist,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) SaveDialysisSetting() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- device_number_set, _ := this.GetInt64("device_number_set")
- device_type_set, _ := this.GetInt64("device_type_set")
- name_set, _ := this.GetInt64("name_set")
- admission_number_set, _ := this.GetInt64("admission_number_set")
- dialysis_no_set, _ := this.GetInt64("dialysis_no_set")
- weight_befor_set, _ := this.GetInt64("weight_befor_set")
- dry_weight_set, _ := this.GetInt64("dry_weight_set")
- blood_pressure_set, _ := this.GetInt64("blood_pressure_set")
- ultrafiltration_volume_set, _ := this.GetInt64("ultrafiltration_volume_set")
- internal_fistula_set, _ := this.GetInt64("internal_fistula_set")
- blood_flow_volume_set, _ := this.GetInt64("blood_flow_volume_set")
- anticoagulant_set, _ := this.GetInt64("anticoagulant_set")
- sealing_fluid_dispose_set, _ := this.GetInt64("sealing_fluid_dispose_set")
- mode_id_set, _ := this.GetInt64("mode_id_set")
- dialysis_time_set, _ := this.GetInt64("dialysis_time_set")
- dialysis_dialyszers_set, _ := this.GetInt64("dialysis_dialyszers_set")
- dialysis_irrigation_set, _ := this.GetInt64("dialysis_irrigation_set")
- gaijiliang_set, _ := this.GetInt64("gaijiliang_set")
- kalium_set, _ := this.GetInt64("kalium_set")
- displace_liqui_value_set, _ := this.GetInt64("displace_liqui_value_set")
- bicarbonate_set, _ := this.GetInt64("bicarbonate_set")
- glucose_set, _ := this.GetInt64("glucose_set")
-
- sodium_set, _ := this.GetInt64("sodium_set")
- calcium_set, _ := this.GetInt64("calcium_set")
- blood_access_set, _ := this.GetInt64("blood_access_set")
- dialyzer_perfusion_apparatus_set, _ := this.GetInt64("dialyzer_perfusion_apparatus_set")
- displace_liqui_part_set, _ := this.GetInt64("displace_liqui_part_set")
-
- cuhong_set, _ := this.GetInt64("cuhong_set")
- zuoka_set, _ := this.GetInt64("zuoka_set")
- difenzi_set, _ := this.GetInt64("difenzi_set")
- gansuna_set, _ := this.GetInt64("gansuna_set")
- zhetangtie_set, _ := this.GetInt64("zhetangtie_set")
- niaojimei_set, _ := this.GetInt64("niaojimei_set")
- dialysis_strainer_set, _ := this.GetInt64("dialysis_strainer_set")
- dialysisSetting := models.XtDialysisSetting{
- Sodium: sodium_set,
- Calcium: calcium_set,
- BloodAccess: blood_access_set,
- DialyzerPerfusionApparatus: dialyzer_perfusion_apparatus_set,
- DisplaceLiquiPart: displace_liqui_part_set,
- UserOrgId: orgId,
- Status: 1,
- DeviceNumber: device_number_set,
- DeviceType: device_type_set,
- Name: name_set,
- AdmissionNumber: admission_number_set,
- DialysisNo: dialysis_no_set,
- WeightBefor: weight_befor_set,
- DryWeight: dry_weight_set,
- BloodPressure: blood_pressure_set,
- UltrafiltrationVolume: ultrafiltration_volume_set,
- InternalFistula: internal_fistula_set,
- BloodFlowVolume: blood_flow_volume_set,
- Anticoagulant: anticoagulant_set,
- SealingFluidDispose: sealing_fluid_dispose_set,
- ModeId: mode_id_set,
- DialysisTime: dialysis_time_set,
- DialysisDialyszers: dialysis_dialyszers_set,
- DialysisIrrigation: dialysis_irrigation_set,
- Gaijiliang: gaijiliang_set,
- Kalium: kalium_set,
- DisplaceLiquiValue: displace_liqui_value_set,
- Bicarbonate: bicarbonate_set,
- Glucose: glucose_set,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- CuhongSet: cuhong_set,
- ZuokaSet: zuoka_set,
- DifenziSet: difenzi_set,
- GansunaSet: gansuna_set,
- ZhetangtieSet: zhetangtie_set,
- NiaojimeiSet: niaojimei_set,
- DialysisStrainerSet: dialysis_strainer_set,
- }
- err := service.SaveDialysisSetting(dialysisSetting)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "dialysisSetting": dialysisSetting,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetDialysisSetting() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- dialysisSett, _ := service.GetDialysisSetting(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "dialysisSett": dialysisSett,
- })
- return
- }
-
- func (this *DialysisApiController) GetDialysisParameterList() {
-
- keyword := this.GetString("keywords")
-
- limit, _ := this.GetInt64("limit")
-
- page, _ := this.GetInt64("page")
-
- //partition_id, _ := this.GetInt64("partition_id")
-
- partion_type := this.GetString("partition_id")
- idSplit := strings.Split(partion_type, ",")
- schedule_type, _ := this.GetInt64("schedule_type")
-
- start_time := this.GetString("schedule_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- scheduids := this.GetString("ids")
- var ids []string
- if scheduids != "" {
- ids = strings.Split(scheduids, ",")
- }
- list, total, err := service.GetDialysisParameterList(keyword, limit, page, idSplit, schedule_type, startTime.Unix(), orgId, ids)
-
- dialysisSett, _ := service.GetDialysisSetting(orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "dialysisSett": dialysisSett,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetDialysisGoodTotalCount() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- //partion_type, _ := this.GetInt64("partion_type")
-
- start_time := this.GetString("selected_date")
-
- partion_type := this.GetString("partion_type")
- var ids []string
-
- ids = strings.Split(partion_type, ",")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- list, err := service.GetDialysisGoodTotalCount(orgId, schedule_type, ids, startTime.Unix())
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetDialysisAdviceSchedulist() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- //partion_type, _ := this.GetInt64("partion_type")
-
- partion_type := this.GetString("partion_type")
- var ids []string
- ids = strings.Split(partion_type, ",")
- start_time := this.GetString("selected_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- list, err := service.GetDialysisAdviceSchedulist(orgId, schedule_type, ids, startTime.Unix())
-
- tablelist, _ := service.GetDialysisAdviceSchedulistTwo(orgId, schedule_type, ids, startTime.Unix())
-
- //获取长期医嘱
- adviceList, _ := service.GetAllLongAdviceList(orgId)
-
- drug, _ := service.GetAllBaseDrugListTwenty(orgId)
- _, config := service.FindXTHisRecordByOrgId(orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "drug": drug,
- "adviceList": adviceList,
- "config": config,
- "tablelist": tablelist,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetDialysisParameterGoodList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- partion_type, _ := this.GetInt64("partion_type")
-
- start_time := this.GetString("selected_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- list, err := service.GetDialysisParameterGoodList(orgId, schedule_type, partion_type, startTime.Unix())
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) SaveHisDialysis() {
-
- var ids []string
- advice_ids := this.GetString("ids")
- ids = strings.Split(advice_ids, ",")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- service.SaveHisDialysis(orgId, ids)
-
- returnData := make(map[string]interface{}, 0)
- returnData["msg"] = "ok"
- this.ServeSuccessJSON(returnData)
- return
- }
-
- func (this *DialysisApiController) GetHisDialysisGoodCount() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- //partion_type, _ := this.GetInt64("partion_type")
- partion_type := this.GetString("partion_type")
- var ids []string
- ids = strings.Split(partion_type, ",")
- start_time := this.GetString("selected_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- list, _ := service.GetHisDialysisGoodCountTwo(orgId, schedule_type, ids, startTime.Unix())
-
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- return
- }
-
- func (this *DialysisApiController) GetPatientSchedule() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- patient_id, _ := this.GetInt64("patient_id")
- schedule_date, _ := this.GetInt64("schedule_date")
-
- schedulePatient, _ := service.GetScheduleByPatient(patient_id, schedule_date, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "schedulePatient": schedulePatient,
- })
- }
-
- func (c *DialysisApiController) GetSchedulePrintList() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- schedulType, _ := c.GetInt64("schedule_type", 0)
- partitionType, _ := c.GetInt64("partition_type", 0)
- keywords := c.GetString("keywords")
- schedule_date := c.GetString("schedule_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var theStartTime int64
- if len(schedule_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", schedule_date+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theStartTime = theTime.Unix()
- }
- adminUserInfo := c.GetAdminUserInfo()
-
- list, total, _ := service.GetSchedulePrintList(page, limit, schedulType, partitionType, keywords, theStartTime, adminUserInfo.CurrentOrgId)
- for _, item := range list {
- order, _ := service.GetLastOrder(item.UserOrgId, item.PatientId, item.ScheduleDate)
- item.DialysisOrderTwenty = order
- }
- listOne, _ := service.GetSchedulePrintListOne(page, limit, schedulType, partitionType, keywords, theStartTime, adminUserInfo.CurrentOrgId)
- numberList, _ := service.GetAllBedNumberSix(adminUserInfo.CurrentOrgId)
- c.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "numberList": numberList,
- "listOne": listOne,
- })
-
- }
-
- func (this *DialysisApiController) GetSolutionListByOrgId() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- list, _ := service.GetSolutionListByOrgId(orgId)
- for _, item := range list {
- //获取该模式最新的1条数据
- solution, _ := service.GetNewPatientSolutionByModeId(item.PatientId, item.ModeId, orgId)
-
- //更新状态值
- service.UpdateDialysisSolutionStatus(solution.ID, item.ModeId, orgId, item.PatientId)
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
-
- }
-
- func (this *DialysisApiController) ExcutionDoctorAdvice() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- is_open, _ := this.GetInt64("is_open")
- idsStr := this.GetString("str")
- recordIDStrs := strings.Split(idsStr, ",")
- start_time := this.GetString("advice_date")
- exec_time, _ := this.GetInt64("exec_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- //fmt.Println(err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
- config, _ := service.GetDrugOpenConfigOne(orgId)
- pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
- //his医嘱
- if is_open == 1 {
-
- groupList, _ := service.GetHisExcutionDoctorAdviceListGroupList(recordIDStrs, startTime, orgId)
- //查找未执行医嘱
- list, _ := service.GetHisExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
- for _, item := range list {
- if item.Checker == this.GetAdminUserInfo().AdminUser.Id {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- })
- return
- }
- }
- for _, item := range groupList {
- for _, it := range list {
- if item.DrugId == it.DrugId {
- item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
- }
- }
- }
-
- for _, item := range groupList {
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
- var sum_out_count int64
- for _, it := range item.ChildDoctorAdvice {
- var prescribing_number int64
- stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
- parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
- if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber * medical.MinNumber
- }
- if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber
- }
- if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber
- }
- sum_out_count += prescribing_number
- houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
- drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId, houseConfig.DrugStorehouseOut)
- //库存不足
- if sum_out_count > drugStockOut.FlushCount {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "drug": medical,
- })
- return
- }
- }
- }
- creater := this.GetAdminUserInfo().AdminUser.Id
- //执行出库逻辑
- for _, item := range list {
- hisadvice := &models.HisDoctorAdviceInfo{
- ID: item.ID,
- UserOrgId: item.UserOrgId,
- PatientId: item.PatientId,
- AdviceType: item.AdviceType,
- AdviceDate: item.AdviceDate,
- StartTime: item.StartTime,
- AdviceName: item.AdviceName,
- AdviceDesc: item.AdviceDesc,
- ReminderDate: item.ReminderDate,
- SingleDose: item.SingleDose,
- SingleDoseUnit: item.SingleDoseUnit,
- DrugSpec: item.DrugSpec,
- DrugSpecUnit: item.DrugSpecUnit,
- PrescribingNumber: item.PrescribingNumber,
- PrescribingNumberUnit: item.PrescribingNumberUnit,
- DeliveryWay: item.DeliveryWay,
- ExecutionFrequency: item.ExecutionFrequency,
- AdviceDoctor: item.AdviceDoctor,
- Status: 1,
- CreatedTime: item.CreatedTime,
- UpdatedTime: item.UpdatedTime,
- AdviceAffirm: item.AdviceAffirm,
- Remark: item.Remark,
- StopTime: item.StopTime,
- StopReason: item.StopReason,
- StopDoctor: item.StopDoctor,
- StopState: item.StopState,
- ParentId: item.ParentId,
- ExecutionTime: item.ExecutionTime,
- ExecutionStaff: creater,
- ExecutionState: item.ExecutionState,
- Checker: item.Checker,
- RecordDate: item.RecordDate,
- DialysisOrderId: item.DialysisOrderId,
- CheckTime: item.CheckTime,
- CheckState: item.CheckState,
- RemindType: item.RemindType,
- FrequencyType: item.FrequencyType,
- DayCount: item.DayCount,
- WeekDay: item.WeekDay,
- TemplateId: item.TemplateId,
- Modifier: item.Modifier,
- Way: item.Way,
- DrugId: item.DrugId,
- ExecutionFrequencyId: item.ExecutionFrequencyId,
- }
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
- if medical.IsUse == 2 {
- if config.IsOpen != 1 {
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
- service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
-
- }
- //不通过药房发药
- if pharmacyConfig.IsOpen != 1 {
- service.HisDrugsDelivery(item.UserOrgId, item.ExecutionStaff, hisadvice)
- }
- //查询默认仓库
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(item.UserOrgId)
- //查询默认仓库剩余多少库存
- var sum_count int64
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
- service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
- }
- }
-
- info := models.HisDoctorAdviceInfo{
- ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
- ExecutionTime: exec_time,
- ExecutionState: 1,
- UpdatedTime: time.Now().Unix(),
- }
- //执行医嘱
- service.UpdateHisDoctorAdviceExecution(info, item.ID)
-
- key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
-
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
- theTime := toTime.Format("2006-01-02")
-
- fmt.Println("theTIME", theTime)
- keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
- }
-
- } else {
-
- groupList, _ := service.GetExcutionDoctorAdviceGroupList(recordIDStrs, startTime, orgId)
- //查找未执行医嘱
- list, _ := service.GetExcutionDoctorAdviceList(recordIDStrs, startTime, orgId)
- for _, item := range groupList {
- for _, it := range list {
- if item.DrugId == it.DrugId {
- item.ChildDoctorAdvice = append(item.ChildDoctorAdvice, it)
- }
- }
- }
-
- for _, item := range groupList {
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
- var sum_out_count int64
- for _, it := range item.ChildDoctorAdvice {
- var prescribing_number int64
- stringPrescribingNumber := strconv.FormatFloat(it.PrescribingNumber, 'f', -1, 64)
- parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
- if it.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber * medical.MinNumber
- }
- if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber
- }
- if it.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber
- }
- sum_out_count += prescribing_number
- houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
- drugStockOut, _ := service.GetDrugSumOutCountByDrugId(it.DrugId, orgId, houseConfig.DrugStorehouseOut)
- //库存不足
- if sum_out_count > drugStockOut.FlushCount {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "drug": medical,
- })
- return
- }
- }
- }
-
- for _, item := range list {
- medical, _ := service.GetBaseDrugMedical(item.DrugId)
- dadvice := &models.DoctorAdvice{
- ID: item.ID,
- UserOrgId: item.UserOrgId,
- PatientId: item.PatientId,
- AdviceType: item.AdviceType,
- AdviceDate: item.AdviceDate,
- StartTime: item.StartTime,
- AdviceName: item.AdviceName,
- AdviceDesc: item.AdviceDesc,
- ReminderDate: item.ReminderDate,
- SingleDose: item.SingleDose,
- SingleDoseUnit: item.SingleDoseUnit,
- DrugSpec: item.DrugSpec,
- DrugSpecUnit: item.DrugSpecUnit,
- PrescribingNumber: item.PrescribingNumber,
- PrescribingNumberUnit: item.PrescribingNumberUnit,
- DeliveryWay: item.DeliveryWay,
- ExecutionFrequency: item.ExecutionFrequency,
- AdviceDoctor: item.AdviceDoctor,
- Status: 1,
- CreatedTime: item.CreatedTime,
- UpdatedTime: item.UpdatedTime,
- AdviceAffirm: item.AdviceAffirm,
- Remark: item.Remark,
- StopTime: item.StopTime,
- StopReason: item.StopReason,
- StopDoctor: item.StopDoctor,
- StopState: item.StopState,
- ParentId: item.ParentId,
- ExecutionTime: item.ExecutionTime,
- ExecutionStaff: item.ExecutionStaff,
- ExecutionState: item.ExecutionState,
- Checker: item.Checker,
- RecordDate: item.ReminderDate,
- DialysisOrderId: item.DialysisOrderId,
- CheckTime: item.CheckTime,
- CheckState: item.CheckState,
- RemindType: item.RemindType,
- FrequencyType: item.FrequencyType,
- DayCount: item.DayCount,
- WeekDay: item.WeekDay,
- TemplateId: item.TemplateId,
- Modifier: item.Modifier,
- Way: item.Way,
- DrugId: item.DrugId,
- }
- if medical.IsUse == 2 {
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
- }
- if pharmacyConfig.IsOpen != 1 {
- service.DrugsDelivery(item.UserOrgId, item.ExecutionStaff, dadvice)
- }
-
- //更新字典里面的库存
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, item.UserOrgId, item.DrugId)
- var sum_count int64
- for _, its := range stockInfo {
- baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
- if its.MaxUnit == baseDrug.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateBaseDrugSumTwo(item.DrugId, sum_count, item.UserOrgId)
- //剩余库存
- service.UpdateDrugStockCount(item.DrugId, item.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
- }
-
- info := models.DoctorAdvice{
- ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
- ExecutionTime: exec_time,
- ExecutionState: 1,
- UpdatedTime: time.Now().Unix(),
- }
- //执行医嘱
- service.UpdateDoctorAdviceExecution(info, item.ID)
- }
-
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- return
- }
-
- func (this *DialysisApiController) CheckNewDoctorAdvice() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- idsStr := this.GetString("str")
- recordIDStrs := strings.Split(idsStr, ",")
- start_time := this.GetString("advice_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- //fmt.Println(err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
-
- if config.IsOpen == 1 {
-
- creater := this.GetAdminUserInfo().AdminUser.Id
- //查询未核对的医嘱
- advicelist, _ := service.GetHisCheckDoctorAdvice(orgId, recordIDStrs, startTime)
- for _, item := range advicelist {
- if item.ExecutionStaff == creater {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": item,
- })
- return
- }
-
- service.CheckHisDoctorAdvice(item.ID, creater)
-
- key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- theTime := time.Now()
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
-
- }
- } else {
-
- //查询未核对的医嘱
- advicelist, _ := service.GetCheckDoctorAdvice(orgId, recordIDStrs, startTime)
- creater := this.GetAdminUserInfo().AdminUser.Id
- for _, item := range advicelist {
- if item.ExecutionStaff == creater {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "advice": item,
- })
- return
- }
-
- service.CheckDoctorAdvice(item.ID, creater)
- key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":advice_list_all"
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.PatientId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- theTime := time.Now()
- recordDate := theTime.Format("2006-01-02")
- keyFour := "scheduals_" + recordDate + "_" + strconv.FormatInt(orgId, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(item.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
- }
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- return
-
- }
-
- func (this *DialysisApiController) SettleNewDoctorAdvice() {
- orgId := this.GetAdminUserInfo().CurrentOrgId
- is_open, _ := this.GetInt64("is_open")
- idsStr := this.GetString("str")
- recordIDStrs := strings.Split(idsStr, ",")
- start_time := this.GetString("advice_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var startTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startTime = theTime.Unix()
- }
-
- if is_open == 1 {
- service.SettleHisNewDoctorAdvice(recordIDStrs, startTime, orgId)
- } else {
- service.SettleNewDoctorAdvice(recordIDStrs, startTime, orgId)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- return
- }
-
- func (this *DialysisApiController) ExcutionDoctorAdviceById() {
-
- advice_id, _ := this.GetInt64("advice_id")
- start_time := this.GetString("advice_date")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- config, _ := service.FindXTHisRecordByOrgIdSix(orgId)
- exec_time, _ := this.GetInt64("exec_time")
-
- //his医嘱
- if config.IsOpen == 1 {
-
- //查询医嘱
- advice, _ := service.GetHisDocById(advice_id, orgId)
- if advice.Checker == this.GetAdminUserInfo().AdminUser.Id {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "3",
- })
- return
- }
- medical, _ := service.GetBaseDrugMedical(orgId)
- var prescribing_number int64
- stringPrescribingNumber := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 64)
- parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
- if advice.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber * medical.MinNumber
- }
- if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber
- }
- if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber
- }
- houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
- drugStockOut, _ := service.GetDrugSumOutCountByDrugId(advice.DrugId, orgId, houseConfig.DrugStorehouseOut)
- //库存不足
- if prescribing_number > drugStockOut.FlushCount {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "drug": medical,
- })
- return
- }
- info := models.HisDoctorAdviceInfo{
- ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
- ExecutionTime: exec_time,
- ExecutionState: 1,
- UpdatedTime: time.Now().Unix(),
- }
- //执行医嘱
- service.UpdateHisDoctorAdviceExecution(info, advice.ID)
-
- key := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":doctor_advices"
- redis := service.RedisClient()
- //清空key 值
- redis.Set(key, "", time.Second)
- keyTwo := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":advice_list_all"
-
- redis.Set(keyTwo, "", time.Second)
- keyThree := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.PatientId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_doctor_advice"
- redis.Set(keyThree, "", time.Second)
- toTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", start_time)
- theTime := toTime.Format("2006-01-02")
-
- fmt.Println("theTIME", theTime)
- keyFour := "scheduals_" + theTime + "_" + strconv.FormatInt(orgId, 10)
-
- redis.Set(keyFour, "", time.Second)
- keyFive := strconv.FormatInt(orgId, 10) + ":" + strconv.FormatInt(advice.AdviceDate, 10) + ":his_advices_list_all"
- redis.Set(keyFive, "", time.Second)
-
- //出库
- if prescribing_number <= drugStockOut.FlushCount {
- pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
- //执行出库逻辑
- hisadvice := &models.HisDoctorAdviceInfo{
- ID: advice.ID,
- UserOrgId: advice.UserOrgId,
- PatientId: advice.PatientId,
- AdviceType: advice.AdviceType,
- AdviceDate: advice.AdviceDate,
- StartTime: advice.StartTime,
- AdviceName: advice.AdviceName,
- AdviceDesc: advice.AdviceDesc,
- ReminderDate: advice.ReminderDate,
- SingleDose: advice.SingleDose,
- SingleDoseUnit: advice.SingleDoseUnit,
- DrugSpec: advice.DrugSpec,
- DrugSpecUnit: advice.DrugSpecUnit,
- PrescribingNumber: advice.PrescribingNumber,
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
- DeliveryWay: advice.DeliveryWay,
- ExecutionFrequency: advice.ExecutionFrequency,
- AdviceDoctor: advice.AdviceDoctor,
- Status: 1,
- CreatedTime: advice.CreatedTime,
- UpdatedTime: advice.UpdatedTime,
- AdviceAffirm: advice.AdviceAffirm,
- Remark: advice.Remark,
- StopTime: advice.StopTime,
- StopReason: advice.StopReason,
- StopDoctor: advice.StopDoctor,
- StopState: advice.StopState,
- ParentId: advice.ParentId,
- ExecutionTime: advice.ExecutionTime,
- ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
- ExecutionState: advice.ExecutionState,
- Checker: advice.Checker,
- RecordDate: advice.RecordDate,
- DialysisOrderId: advice.DialysisOrderId,
- CheckTime: advice.CheckTime,
- CheckState: advice.CheckState,
- RemindType: advice.RemindType,
- FrequencyType: advice.FrequencyType,
- DayCount: advice.DayCount,
- WeekDay: advice.WeekDay,
- TemplateId: advice.TemplateId,
- Modifier: advice.Modifier,
- Way: advice.Way,
- DrugId: advice.DrugId,
- ExecutionFrequencyId: advice.ExecutionFrequencyId,
- }
- if medical.IsUse == 2 {
- if config.IsOpen != 1 {
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
- service.HisDrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, hisadvice)
-
- }
- //不通过药房发药
- if pharmacyConfig.IsOpen != 1 {
- service.HisDrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, hisadvice)
- }
- //查询默认仓库
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(advice.UserOrgId)
- //查询默认仓库剩余多少库存
- var sum_count int64
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
- for _, its := range stockInfo {
- if its.MaxUnit == medical.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * medical.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateBaseDrugSumTwo(advice.DrugId, sum_count, advice.UserOrgId)
- service.UpdateDrugStockCount(advice.DrugId, advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
- }
- }
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- return
- }
-
- if config.IsOpen == 2 || config.IsOpen == 0 {
-
- advice, _ := service.GetBloodDocById(advice_id, orgId)
- medical, _ := service.GetBaseDrugMedical(orgId)
- pharmacyConfig, _ := service.FindPharmacyConfig(orgId)
- storeHouseConfig, _ := service.GetAllStoreHouseConfig(orgId)
- var prescribing_number int64
- stringPrescribingNumber := strconv.FormatFloat(advice.PrescribingNumber, 'f', -1, 64)
- parseIntPrescribingNumber, _ := strconv.ParseInt(stringPrescribingNumber, 10, 64)
- if advice.PrescribingNumberUnit == medical.MaxUnit && medical.MaxUnit != medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber * medical.MinNumber
- }
- if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit != medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber
- }
- if advice.PrescribingNumberUnit == medical.MinUnit && medical.MaxUnit == medical.MinUnit {
- prescribing_number = parseIntPrescribingNumber
- }
- houseConfig, _ := service.GetAllStoreHouseConfig(orgId)
- drugStockOut, _ := service.GetDrugSumOutCountByDrugId(advice.DrugId, orgId, houseConfig.DrugStorehouseOut)
- //库存不足
- if prescribing_number > drugStockOut.FlushCount {
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "2",
- "drug": medical,
- })
- return
- }
- info := models.DoctorAdvice{
- ExecutionStaff: this.GetAdminUserInfo().AdminUser.Id,
- ExecutionTime: exec_time,
- ExecutionState: 1,
- UpdatedTime: time.Now().Unix(),
- }
- //执行医嘱
- service.UpdateDoctorAdviceExecution(info, advice.ID)
-
- dadvice := &models.DoctorAdvice{
- ID: advice.ID,
- UserOrgId: advice.UserOrgId,
- PatientId: advice.PatientId,
- AdviceType: advice.AdviceType,
- AdviceDate: advice.AdviceDate,
- StartTime: advice.StartTime,
- AdviceName: advice.AdviceName,
- AdviceDesc: advice.AdviceDesc,
- ReminderDate: advice.ReminderDate,
- SingleDose: advice.SingleDose,
- SingleDoseUnit: advice.SingleDoseUnit,
- DrugSpec: advice.DrugSpec,
- DrugSpecUnit: advice.DrugSpecUnit,
- PrescribingNumber: advice.PrescribingNumber,
- PrescribingNumberUnit: advice.PrescribingNumberUnit,
- DeliveryWay: advice.DeliveryWay,
- ExecutionFrequency: advice.ExecutionFrequency,
- AdviceDoctor: advice.AdviceDoctor,
- Status: 1,
- CreatedTime: advice.CreatedTime,
- UpdatedTime: advice.UpdatedTime,
- AdviceAffirm: advice.AdviceAffirm,
- Remark: advice.Remark,
- StopTime: advice.StopTime,
- StopReason: advice.StopReason,
- StopDoctor: advice.StopDoctor,
- StopState: advice.StopState,
- ParentId: advice.ParentId,
- ExecutionTime: advice.ExecutionTime,
- ExecutionStaff: advice.ExecutionStaff,
- ExecutionState: advice.ExecutionState,
- Checker: advice.Checker,
- RecordDate: advice.ReminderDate,
- DialysisOrderId: advice.DialysisOrderId,
- CheckTime: advice.CheckTime,
- CheckState: advice.CheckState,
- RemindType: advice.RemindType,
- FrequencyType: advice.FrequencyType,
- DayCount: advice.DayCount,
- WeekDay: advice.WeekDay,
- TemplateId: advice.TemplateId,
- Modifier: advice.Modifier,
- Way: advice.Way,
- DrugId: advice.DrugId,
- }
- if medical.IsUse == 2 {
- if pharmacyConfig.IsOpen == 1 && medical.IsPharmacy == 0 {
- service.DrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, dadvice)
- }
- if pharmacyConfig.IsOpen != 1 {
- service.DrugsDelivery(advice.UserOrgId, advice.ExecutionStaff, dadvice)
- }
-
- //更新字典里面的库存
- stockInfo, _ := service.GetDrugAllStockInfo(storeHouseConfig.DrugStorehouseOut, advice.UserOrgId, advice.DrugId)
- var sum_count int64
- for _, its := range stockInfo {
- baseDrug, _ := service.GetBaseDrugMedical(its.DrugId)
- if its.MaxUnit == baseDrug.MaxUnit {
- its.StockMaxNumber = its.StockMaxNumber * baseDrug.MinNumber
- }
- sum_count += its.StockMaxNumber + its.StockMinNumber
- }
- service.UpdateBaseDrugSumTwo(advice.DrugId, sum_count, advice.UserOrgId)
- //剩余库存
- service.UpdateDrugStockCount(advice.DrugId, advice.UserOrgId, storeHouseConfig.DrugStorehouseOut, sum_count)
- }
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "msg": "1",
- })
- return
-
- }
-
- func (this *DialysisApiController) GetDialysisAdviceToday() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- //partion_type, _ := this.GetInt64("partion_type")
-
- partion_type := this.GetString("partion_type")
- var ids []string
- ids = strings.Split(partion_type, ",")
- start_time := this.GetString("selected_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- list, err := service.GetDialysisAdviceSchedulistTen(orgId, schedule_type, ids, startTime.Unix())
-
- drug, _ := service.GetAllBaseDrugListTwenty(orgId)
- _, config := service.FindXTHisRecordByOrgId(orgId)
- appId := this.GetAdminUserInfo().CurrentAppId
- doctorList, _ := service.GetAllAdminUsers(orgId, appId)
-
- manufacturerList, _ := service.GetAllManufacturerList(orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "drug": drug,
- "config": config,
- "doctorList": doctorList,
- "manufacturerList": manufacturerList,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetDialysisProject() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- partion_type := this.GetString("partion_type")
- var ids []string
- ids = strings.Split(partion_type, ",")
- start_time := this.GetString("selected_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- list, err := service.GetDialysisProjectSchedulistTen(orgId, schedule_type, ids, startTime.Unix())
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetMobileScheduleList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- schedule, _ := service.GetMobileScheduleList(orgId)
-
- if len(schedule) > 0 {
- for _, its := range schedule {
- //prescription, _ := service.GetPrescriptionList(its.PatientId, its.ScheduleDate, its.UserOrgId)
- //its.DialysisPrescription = prescription
- //monitor, _ := service.GetLastMonitorRecordList(its.PatientId, its.ScheduleDate, its.UserOrgId)
- //its.MonitoringRecord = monitor
- //after, _ := service.GetLastAfter(its.PatientId, its.ScheduleDate, its.UserOrgId)
- //its.XtAssessmentAfterDislysis = after
-
- order, _ := service.GetLastOrder(its.UserOrgId, its.PatientId, its.ScheduleDate)
- service.UpdateDoctorSix(order.StartTime, order.PatientId, order.DialysisDate, order.UserOrgId)
- }
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": schedule,
- })
- return
-
- }
-
- func (this *DialysisApiController) SaveDialysisInformationSetting() {
-
- week_day, _ := this.GetInt64("week_day")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- informaitonSetting := models.XtDialysisInformaitonSetting{
- WeekDay: week_day,
- UserOrgId: orgId,
- Status: 1,
- Ctime: time.Now().Unix(),
- Mtime: 0,
- }
- information, _ := service.GetInformationSettingByOrgId(orgId)
- if information.ID == 0 {
- service.CreateInformationSetting(informaitonSetting)
- }
- if information.ID > 0 {
- service.UpdateInformationSettingById(orgId, week_day)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "informaitonSetting": informaitonSetting,
- })
- return
- }
-
- func (this *DialysisApiController) GetDialysisInformationSetting() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- limit, _ := this.GetInt64("limit")
- page, _ := this.GetInt64("page")
- informationSetting, _ := service.GetDialysisInformationSettingList(orgId)
-
- //未审核
- infor, total, _ := service.GetDialysisInformationIsNoCheck(orgId, limit, page, 2)
-
- //全部
- inforList, totalOne, _ := service.GetDialysisInformationIsNoCheckOne(orgId, limit, page, 1)
-
- patients, _ := service.GetAllpatientThirty(orgId)
-
- appId := this.GetAdminUserInfo().CurrentAppId
- role, _ := service.GetAllDoctorListSix(orgId, appId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "informaitonSetting": informationSetting,
- "infor": infor,
- "total": total,
- "totalOne": totalOne,
- "inforList": inforList,
- "patients": patients,
- "adminList": role,
- })
- return
- }
-
- func (this *DialysisApiController) CheckDialysisInformation() {
-
- id, _ := this.GetInt64("id")
- application_status, _ := this.GetInt64("application_status")
- timeNow := time.Now().Unix()
- checker := this.GetAdminUserInfo().AdminUser.Id
- information, _ := service.CheckDialysisInformation(id, application_status, timeNow, checker)
- this.ServeSuccessJSON(map[string]interface{}{
- "information": information,
- })
- return
- }
-
- func (this *DialysisApiController) GetDialysisPatientsFlow() {
-
- page, _ := this.GetInt64("page", 1)
- limit, _ := this.GetInt64("limit", 10)
- schedulType, _ := this.GetInt64("schedul_type", 0)
- startTime, _ := this.GetInt64("schedul_time", 0)
- partitionType, _ := this.GetInt64("partition_type", 0)
- keywords := this.GetString("keywords")
- start_time, _ := this.GetInt64("start_time")
- end_time, _ := this.GetInt64("end_time")
- adminUserInfo := this.GetAdminUserInfo()
- if len(keywords) > 0 {
-
- dialysisSchedule, err, total := service.GetDialysisWatchByKeywordFlow(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": dialysisSchedule,
- "total": total,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- }
-
- } else {
- dialysisSchedule, err, total := service.GetDialysisWatchFlow(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit, start_time/1000, end_time/1000)
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "schedule": dialysisSchedule,
- "total": total,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- }
- }
- }
-
- func (this *DialysisApiController) SaveInformation() {
-
- patient_id, _ := this.GetInt64("patient_id")
- record_date, _ := this.GetInt64("record_date")
- startTime := this.GetString("selected_date")
-
- timeLayout := "2006-01-02 15:04"
- loc, _ := time.LoadLocation("Local")
-
- if len(startTime) == 0 {
- utils.ErrorLog("len(start_time) == 0")
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- theTime, err := time.ParseInLocation(timeLayout, startTime, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- StartTime := theTime.Unix()
- fmt.Println("startime-------------", StartTime)
-
- module, _ := this.GetInt64("module")
-
- remark := this.GetString("remark")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- creater := this.GetAdminUserInfo().AdminUser.Id
-
- information := models.XtDialysisInformation{
- Module: module,
- PatientId: patient_id,
- RecordDate: record_date,
- ApplicationDate: StartTime,
- Creater: creater,
- ApplicationStatus: 2,
- Checker: 0,
- CheckTime: 0,
- Remark: remark,
- UserOrgId: orgId,
- Ctime: time.Now().Unix(),
- Status: 1,
- Mtime: 0,
- }
-
- infor, _ := service.GetDialysisInoformationById(patient_id, record_date, orgId, module)
- if infor.ID == 0 {
- err := service.CreatedDialysisInformation(information)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "information": information,
- })
- return
- }
- }
- if infor.ID > 0 {
- err := service.UpdateDialysisInformationById(patient_id, record_date, orgId, module, StartTime, remark)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "information": information,
- })
- return
- }
- }
-
- }
-
- func (this *DialysisApiController) GetLongDialysisAdviceToday() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- schedule_type, _ := this.GetInt64("schedule_type")
-
- partion_type := this.GetString("partion_type")
- var ids []string
- ids = strings.Split(partion_type, ",")
- start_time := this.GetString("selected_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- list, err := service.GetLongDialysisAdviceToday(orgId, schedule_type, ids, startTime.Unix())
-
- drug, _ := service.GetAllBaseDrugListTwenty(orgId)
- _, config := service.FindXTHisRecordByOrgId(orgId)
- appId := this.GetAdminUserInfo().CurrentAppId
- doctorList, _ := service.GetAllAdminUsers(orgId, appId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "drug": drug,
- "config": config,
- "doctorList": doctorList,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetPatientList() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- keyWord := this.GetString("keyword")
- patientList, err := service.GetPrescriptionPatientList(orgId, keyWord)
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "patientList": patientList,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetPrescriptionLogList() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- record_date := this.GetString("record_date")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var recordDateTime int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime = theTime.Unix()
- }
-
- prescriptionlogList, total, err := service.GetPrescriptionLogList(patient_id, page, limit, recordDateTime, orgId)
-
- patients, _ := service.GetAllPatientLog(orgId)
-
- role, _ := service.GetAllDoctorLog(orgId)
-
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "prescriptionlogList": prescriptionlogList,
- "total": total,
- "patients": patients,
- "role": role,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetBeforLogList() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- record_date := this.GetString("record_date")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var recordDateTime int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime = theTime.Unix()
- }
- beforLogList, total, err := service.GetBeforLogList(patient_id, page, limit, recordDateTime, orgId)
-
- patients, _ := service.GetAllPatientLog(orgId)
-
- role, _ := service.GetAllDoctorLog(orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "beforLogList": beforLogList,
- "total": total,
- "patients": patients,
- "role": role,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetDocLogList() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- record_date := this.GetString("record_date")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var recordDateTime int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime = theTime.Unix()
- }
- adviceLogList, total, err := service.GetDocLogList(patient_id, page, limit, recordDateTime, orgId)
-
- patients, _ := service.GetAllPatientLog(orgId)
-
- role, _ := service.GetAllDoctorLog(orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "adviceLogList": adviceLogList,
- "total": total,
- "patients": patients,
- "role": role,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetMonitorLogList() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- record_date := this.GetString("record_date")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var recordDateTime int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime = theTime.Unix()
- }
- monitorLogList, total, err := service.GetMonitorLogList(patient_id, page, limit, recordDateTime, orgId)
-
- patients, _ := service.GetAllPatientLog(orgId)
-
- role, _ := service.GetAllDoctorLog(orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "monitorLogList": monitorLogList,
- "total": total,
- "patients": patients,
- "role": role,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) GetAfterLogList() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- record_date := this.GetString("record_date")
-
- page, _ := this.GetInt64("page")
-
- limit, _ := this.GetInt64("limit")
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var recordDateTime int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- recordDateTime = theTime.Unix()
- }
- afterLogList, total, err := service.GetAfterLogList(patient_id, page, limit, recordDateTime, orgId)
-
- patients, _ := service.GetAllPatientLog(orgId)
-
- role, _ := service.GetAllDoctorLog(orgId)
- if err == nil {
- this.ServeSuccessJSON(map[string]interface{}{
- "afterLogList": afterLogList,
- "total": total,
- "patients": patients,
- "role": role,
- })
- return
-
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (this *DialysisApiController) SaveGatherSetting() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
- is_index_number, _ := this.GetInt64("is_index_number")
- fmt.Println("this,23o2332232323232332", is_index_number)
- is_zone, _ := this.GetInt64("is_zone")
- is_number, _ := this.GetInt64("is_number")
- is_birth, _ := this.GetInt64("is_birth")
- is_age, _ := this.GetInt64("is_age")
- is_name, _ := this.GetInt64("is_name")
- is_mode_type, _ := this.GetInt64("is_mode_type")
- is_prescription_status, _ := this.GetInt64("is_prescription_status")
- is_admission_number, _ := this.GetInt64("is_admission_number")
- is_dialysis_no, _ := this.GetInt64("is_dialysis_no")
- is_dry_weight, _ := this.GetInt64("is_dry_weight")
- is_dialysis_dialyszers, _ := this.GetInt64("is_dialysis_dialyszers")
- is_dialysis_strainer, _ := this.GetInt64("is_dialysis_strainer")
- is_dialysis_irrigation, _ := this.GetInt64("is_dialysis_irrigation")
- is_calcium, _ := this.GetInt64("is_calcium")
- is_kalium, _ := this.GetInt64("is_kalium")
- is_change_nurse, _ := this.GetInt64("is_change_nurse")
- is_puncture_needle, _ := this.GetInt64("is_puncture_needle")
- is_anticoagulant, _ := this.GetInt64("is_anticoagulant")
- is_tube, _ := this.GetInt64("is_tube")
- is_cuhong, _ := this.GetInt64("is_cuhong")
- is_zuoka, _ := this.GetInt64("is_zuoka")
- is_zhetangtie, _ := this.GetInt64("is_zhetangtie")
- is_paligu, _ := this.GetInt64("is_paligu")
- is_guhuachun, _ := this.GetInt64("is_guhuachun")
- is_niaojimei, _ := this.GetInt64("is_niaojimei")
- is_putaosuangai, _ := this.GetInt64("is_putaosuangai")
- is_jiaguan, _ := this.GetInt64("is_jiaguan")
- is_xiongxiewutai, _ := this.GetInt64("is_xiongxiewutai")
-
- gatherSetting := models.XtDialysisGatherSetting{
- UserOrgId: orgId,
- IndexNumber: is_index_number,
- Zone: is_zone,
- Number: is_number,
- Birth: is_birth,
- Name: is_name,
- Age: is_age,
- ModeType: is_mode_type,
- PrescriptionStatus: is_prescription_status,
- AdmissionNumber: is_admission_number,
- DialysisNo: is_dialysis_no,
- DryWeight: is_dry_weight,
- DialysisDialyszers: is_dialysis_dialyszers,
- DialysisStrainer: is_dialysis_strainer,
- DialysisIrrigation: is_dialysis_irrigation,
- Calcium: is_calcium,
- Kalium: is_kalium,
- ChangeNurse: is_change_nurse,
- PunctureNeedle: is_puncture_needle,
- Anticoagulant: is_anticoagulant,
- Tube: is_tube,
- Cuhong: is_cuhong,
- Zuoka: is_zuoka,
- Zhetangtie: is_zhetangtie,
- Paligu: is_paligu,
- Guhuachun: is_guhuachun,
- Niaojimei: is_niaojimei,
- Putaosuangai: is_putaosuangai,
- Jiaguan: is_jiaguan,
- Xiongxiewutai: is_xiongxiewutai,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Status: 1,
- }
- //查询该机构有没有设置
- gatherSettingOne, _ := service.GetGatherSettingByOrgId(orgId)
- if gatherSettingOne.ID == 0 {
- service.CreateGather(gatherSetting)
- } else {
- gatherSetting.ID = gatherSettingOne.ID
- service.SaveGather(gatherSetting)
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "gatherSetting": gatherSetting,
- })
- return
- }
-
- func (this *DialysisApiController) GetGatherSetting() {
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- gatherSetting, _ := service.GetGatherSetting(orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "gatherSetting": gatherSetting,
- })
- return
- }
-
- func (this *DialysisApiController) GetDialysisGatherList() {
-
- keyword := this.GetString("keywords")
-
- limit, _ := this.GetInt64("limit")
-
- page, _ := this.GetInt64("page")
-
- partion_type := this.GetString("partition_id")
- idSplit := strings.Split(partion_type, ",")
- schedule_type, _ := this.GetInt64("schedule_type")
-
- start_time := this.GetString("schedule_date")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
-
- orgId := this.GetAdminUserInfo().CurrentOrgId
-
- scheduids := this.GetString("ids")
- var ids []string
- if scheduids != "" {
- ids = strings.Split(scheduids, ",")
- }
-
- list, total, _ := service.GetDialysisGatherList(keyword, limit, page, idSplit, schedule_type, startTime.Unix(), orgId, ids)
- gatherSetting, _ := service.GetGatherSetting(orgId)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- "total": total,
- "gatherSetting": gatherSetting,
- })
- return
- }
-
- func (this *DialysisApiController) GetPatientDialysisRecordList() {
-
- patient_id, _ := this.GetInt64("patient_id")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- start_time := this.GetString("start_time")
-
- end_time := this.GetString("end_time")
-
- var startdateunix int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startdateunix = theTime.Unix()
- }
- var enddateunix int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- enddateunix = theTime.Unix()
- }
-
- org_id := this.GetAdminUserInfo().CurrentOrgId
-
- if org_id == 9538 || org_id == 10101 || org_id == 10353 {
- list, _ := service.GetPatientDialysisRecordList(patient_id, startdateunix, enddateunix)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- return
- } else {
- list, _ := service.GetPatientDialysisRecordListOne(patient_id, startdateunix, enddateunix)
- this.ServeSuccessJSON(map[string]interface{}{
- "list": list,
- })
- }
-
- return
- }
-
- func (this *DialysisApiController) GetPatientRecordList() {
-
- patient_id, _ := this.GetInt64("patient_id")
- orgId := this.GetAdminUserInfo().CurrentOrgId
- beforList, _ := service.GetPatientBeforRecordList(patient_id, orgId)
- afterList, _ := service.GetPatientAfterRecordList(patient_id, orgId)
- monitorList, _ := service.GetMonitorRecordByGroup(patient_id, orgId)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "beforList": beforList,
- "afterList": afterList,
- "monitorList": monitorList,
- })
-
- }
-
- func (this *DialysisApiController) GetDialysisTotalCount() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- start_time := this.GetString("start_time")
-
- end_time := this.GetString("end_time")
-
- patient_id, _ := this.GetInt64("patient_id")
-
- var startdateunix int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startdateunix = theTime.Unix()
- }
- var enddateunix int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- enddateunix = theTime.Unix()
- }
- orgId := this.GetAdminUserInfo().CurrentOrgId
- order, _ := service.GetDialysisTotalCountByTime(orgId, startdateunix, enddateunix, patient_id)
- this.ServeSuccessJSON(map[string]interface{}{
- "order": order,
- })
- }
-
- func (this *DialysisApiController) GetPatientBefor() {
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
-
- record_date := this.GetString("record_date")
-
- patient_id, _ := this.GetInt64("patient_id")
-
- user_org_id := this.GetAdminUserInfo().CurrentOrgId
-
- var startdateunix int64
- if len(record_date) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
- if err != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- startdateunix = theTime.Unix()
- }
-
- patientBefor, _ := service.GetPatientBefor(patient_id, startdateunix, user_org_id)
-
- prescription, _ := service.GetDialysisPrescribeOneList(patient_id, startdateunix, user_org_id)
-
- this.ServeSuccessJSON(map[string]interface{}{
- "patientBefor": patientBefor,
- "prescription": prescription,
- })
- }
|