dialysis_api_controller.go 175KB

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