123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564 |
- package controllers
-
- import (
- "Xcx_New/models"
- "Xcx_New/service"
- "Xcx_New/utils"
- "encoding/json"
- "fmt"
- "github.com/jinzhu/gorm"
- "math"
- "reflect"
- "strconv"
- "strings"
-
- //"strings"
- "time"
-
- "Xcx_New/enums"
-
- "github.com/astaxie/beego"
- )
-
- type DialysisApiController struct {
- BaseAuthAPIController
- }
-
- func DialysisApiRegistRouters() {
- beego.Router("/api/dialysis/device", &DialysisApiController{}, "get:GetDeviceList")
- beego.Router("/api/dialysis/patients", &DialysisApiController{}, "get:GetDialysisWatch")
- beego.Router("/api/dialysis/zone", &DialysisApiController{}, "get:GetAllDeviceZone")
- beego.Router("/api/dialysis/info", &DialysisApiController{}, "get:GetSchedualPatientsInfo")
- beego.Router("/api/dialysis/advice/create", &DialysisApiController{}, "Post:CreateDoctorAdvice")
- beego.Router("/api/dialysis/advice/get", &DialysisApiController{}, "Get:GetDoctorAdvice")
- beego.Router("/api/dialysis/advice/edit", &DialysisApiController{}, "put:EditDoctorAdvice")
- beego.Router("/api/dialysis/monitor/create", &DialysisApiController{}, "Post:CreateMonitor")
- beego.Router("/api/dialysis/monitor/del", &DialysisApiController{}, "Post:DelMonitor")
- beego.Router("/api/dialysis/dialysisorder", &DialysisApiController{}, "Get:GetDialysisOrder")
- beego.Router("/api/dialysis/prescription", &DialysisApiController{}, "Post:PostPrescription")
- beego.Router("/api/dialysis/soulution", &DialysisApiController{}, "Post:PostSoulution")
- beego.Router("/api/dialysis/dobule", &DialysisApiController{}, "Post:PostDouleCheck")
- beego.Router("/api/dialysis/accepts", &DialysisApiController{}, "Post:PostReceiveTreatmentAsses")
- beego.Router("/api/dialysis/assessmentbeforedislysis", &DialysisApiController{}, "Post:PostAssessmentBeforeDislysis")
- beego.Router("/api/dialysis/assessmentafterdislysis", &DialysisApiController{}, "Post:PostAssessmentAfterDislysis")
- beego.Router("/api/dialysis/treatmentsummary", &DialysisApiController{}, "Post:PostTreatmentSummary")
-
- beego.Router("/api/dialysis/advice_remind", &DialysisApiController{}, "Get:GetLongAdvice")
- beego.Router("/api/advice_remind/create", &DialysisApiController{}, "Post:CreateRemindDoctorAdvice")
-
- beego.Router("/api/solution/get", &DialysisApiController{}, "Get:GetSolution")
-
- beego.Router("/api/schedule/get", &DialysisApiController{}, "Get:GetSchedule")
-
- beego.Router("/api/today_monitor/get", &DialysisApiController{}, "Get:GetTodayMonitor")
-
- beego.Router("/api/dryweight/commit", &DialysisApiController{}, "Post:UploadDryWeight")
-
- beego.Router("/api/func_per/get", &DialysisApiController{}, "Get:GetFuncPurview")
-
- beego.Router("/api/doctoradvice/get", &DialysisApiController{}, "Get:GetLastOrNextDoctorAdvice")
-
- beego.Router("/api/dialysisgoods/get", &DialysisApiController{}, "Get:GetDialysisGoods")
- beego.Router("/api/goodstatistics/get", &DialysisApiController{}, "Get:GetDialysisGoodsStatistics")
- beego.Router("/api/queue/get", &DialysisApiController{}, "Get:GetQueueCall")
- beego.Router("/api/queue/update", &DialysisApiController{}, "Get:UpdateQueueCall")
- }
-
- func (c *DialysisApiController) GetQueueCall() {
- adminUserInfo := c.GetAdminUserInfo()
- queueConfig, _ := service.FindQueueCallInfo(adminUserInfo.CurrentOrgId)
-
- if queueConfig.ID <= 0 {
- queueConfig.OrgId = adminUserInfo.CurrentOrgId
- queueConfig.Qhsj = 10
- queueConfig.Jzdcbbcs = 3
- queueConfig.Jzbbsy = 1
- queueConfig.Jzjhyc = 0
- queueConfig.Sjdcbbcs = 3
- queueConfig.Sjbbsy = 0
- queueConfig.Sjjhyc = 0
- queueConfig.Txxqyxs = 0
- queueConfig.Txglsyxs = 0
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "queue_config": queueConfig,
- })
- }
-
- func (c *DialysisApiController) UpdateQueueCall() {
- adminUserInfo := c.GetAdminUserInfo()
- queueConfig, _ := service.FindQueueCallInfo(adminUserInfo.CurrentOrgId)
-
- if queueConfig.ID <= 0 {
- queueConfig.OrgId = adminUserInfo.CurrentOrgId
- queueConfig.Qhsj = 10
- queueConfig.Jzdcbbcs = 3
- queueConfig.Jzbbsy = 1
- queueConfig.Jzjhyc = 0
- queueConfig.Sjdcbbcs = 3
- queueConfig.Sjbbsy = 0
- queueConfig.Sjjhyc = 0
- queueConfig.Txxqyxs = 0
- queueConfig.Txglsyxs = 0
- queueConfig.CreateTime = time.Now().Unix()
- queueConfig.UpdateTime = time.Now().Unix()
- }
-
- qhsj, _ := c.GetInt64("qhsj", 0)
- if qhsj > 0 {
- queueConfig.Qhsj = qhsj
- }
-
- jzdcbbcs, _ := c.GetInt64("jzdcbbcs", 0)
- if jzdcbbcs > 0 {
- queueConfig.Jzdcbbcs = jzdcbbcs
- }
-
- jzbbsy, _ := c.GetInt64("jzbbsy", 0)
- if jzbbsy > 0 {
- queueConfig.Jzbbsy = jzbbsy
- }
-
- jzjhyc, _ := c.GetInt64("jzjhyc", 0)
- queueConfig.Jzjhyc = jzjhyc
-
- sjdcbbcs, _ := c.GetInt64("sjdcbbcs", 0)
- if sjdcbbcs > 0 {
- queueConfig.Sjdcbbcs = sjdcbbcs
- }
-
- sjbbsy, _ := c.GetInt64("sjbbsy", 0)
- if sjbbsy > 0 {
- queueConfig.Sjbbsy = sjbbsy
- }
-
- sjjhyc, _ := c.GetInt64("sjjhyc", 0)
- queueConfig.Sjjhyc = sjjhyc
-
- txxqyxs, _ := c.GetInt64("txxqyxs", 0)
- queueConfig.Txxqyxs = txxqyxs
-
- txglsyxs, _ := c.GetInt64("txglsyxs", 0)
- queueConfig.Txglsyxs = txglsyxs
-
- queueConfig.UpdateTime = time.Now().Unix()
-
- service.UpDateQueueCallInfo(queueConfig)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "queue_config": queueConfig,
- })
- }
-
- func (c *DialysisApiController) PostPrescription() {
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- mode_id, _ := c.GetInt64("mode_id", 0)
- dialysis_duration, _ := c.GetFloat("dialysis_duration", 0)
- dialyzer, _ := c.GetInt64("dialyzer", 0)
- dialyzerPerfusionApparatus := c.GetString("dialyzer_perfusion_apparatus")
- perfusion_apparatus, _ := c.GetInt64("perfusion_apparatus", 0)
- blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
- dewater_amount, _ := c.GetFloat("dewater_amount", 0)
- displace_liqui, _ := c.GetFloat("displace_liqui", 0)
- replacement_way, _ := c.GetInt64("replacement_way", 0)
- anticoagulant, _ := c.GetInt64("anticoagulant", 0)
- anticoagulant_shouji, _ := c.GetFloat("anticoagulant_shouji", 0)
- anticoagulant_weichi, _ := c.GetFloat("anticoagulant_weichi", 0)
- anticoagulant_zongliang, _ := c.GetFloat("anticoagulant_zongliang", 0)
- anticoagulant_gaimingcheng := c.GetString("anticoagulant_gaimingcheng")
- anticoagulant_gaijiliang := c.GetString("anticoagulant_gaijiliang")
- kalium, _ := c.GetFloat("kalium", 0)
- sodium, _ := c.GetFloat("sodium", 0)
- replacement_total, _ := c.GetFloat("replacement_total", 0)
-
- calcium, _ := c.GetFloat("calcium", 0)
- bicarbonate, _ := c.GetFloat("bicarbonate", 0)
- glucose, _ := c.GetFloat("glucose", 0)
- // dry_weight, _ := c.GetFloat("dry_weight", 0)
- dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
- dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
- conductivity, _ := c.GetFloat("conductivity", 0)
- remark := c.GetString("remark")
- dialysisDurationHour, _ := c.GetInt64("dialysis_duration_hour", 0)
- dialysisDurationMinute, _ := c.GetInt64("dialysis_duration_minute", 0)
- targetUltrafiltration, _ := c.GetFloat("target_ultrafiltration", 0)
- dialysateFormulation, _ := c.GetInt64("dialysate_formulation", 0)
- body_fluid, _ := c.GetInt64("body_fluid", 0)
- special_medicine, _ := c.GetInt64("special_medicine", 0)
- special_medicine_other := c.GetString("special_medicine_other")
- displace_liqui_part, _ := c.GetInt64("displace_liqui_part", 0)
- displace_liqui_value, _ := c.GetFloat("displace_liqui_value", 0)
- blood_access, _ := c.GetInt64("blood_access", 0)
- ultrafiltration, _ := c.GetFloat("ultrafiltration", 0)
- body_fluid_other := c.GetString("body_fluid_other")
- target_ktv, _ := c.GetFloat("target_ktv", 0)
-
- niprocart, _ := c.GetInt64("niprocart", 0)
- jms, _ := c.GetInt64("jms", 0)
- fistula_needle_set, _ := c.GetInt64("fistula_needle_set", 0)
- fistula_needle_set_16, _ := c.GetInt64("fistula_needle_set_16", 0)
- hemoperfusion, _ := c.GetInt64("hemoperfusion", 0)
- dialyser_sterilised, _ := c.GetInt64("dialyser_sterilised", 0)
- filtryzer, _ := c.GetInt64("filtryzer", 0)
-
- dialyzers, _ := c.GetInt64("dialyzers", 0)
- injector, _ := c.GetInt64("injector", 0)
- bloodlines, _ := c.GetInt64("bloodlines", 0)
- tubing_hemodialysis, _ := c.GetInt64("tubing_hemodialysis", 0)
- safe_package, _ := c.GetInt64("package", 0)
- a_liquid, _ := c.GetInt64("a_liquid", 0)
- preImpules, _ := c.GetFloat("pre_impulse", 0)
- fmt.Println("", preImpules)
-
- anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
- anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
-
- //heparin_sodium := c.GetString("heparin_sodium")
- //fmt.Println("肝素钠",heparin_sodium)
- //nucleoprotamine := c.GetString("nucleoprotamine")
- //fmt.Println("鱼精蛋白",nucleoprotamine)
- //push_the_protamine := c.GetString("push_the_protamine")
- //fmt.Println("下机前推注鱼精蛋白",push_the_protamine)
- // var prescription_doctor int64
- blood := c.GetString("blood")
- dialysis_dialyszers := c.GetString("dialysis_dialyszers")
-
- dialysis_irrigation := c.GetString("dialysis_irrigation")
- antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
- displace_speed := c.GetString("displace_speed")
- illness, _ := c.GetInt64("illness")
- amylaceum := c.GetString("amylaceum")
- single_time := c.GetString("single_time")
- single_water := c.GetString("single_water")
- replacement_flow := c.GetString("replacement_flow")
- plasma_separator := c.GetString("plasma_separator")
- bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
- oxygen_uptake, _ := c.GetInt64("oxygen_uptake")
- oxygen_flow := c.GetString("oxygen_flow")
- oxygen_time := c.GetString("oxygen_time")
-
- hemodialysis_pipelines := c.GetString("hemodialysis_pipelines")
- hemodialysis_pipelines_count, _ := c.GetFloat("hemodialysis_pipelines_count", 0)
-
- puncture_needle := c.GetString("puncture_needle")
- puncture_needle_count, _ := c.GetFloat("puncture_needle_count", 0)
-
- epo := c.GetString("epo")
- epo_count, _ := c.GetFloat("epo_count", 0)
- max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- //if template.TemplateId == 2 || template.TemplateId == 6 {
- // if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- prescription := models.DialysisPrescription{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- RecordDate: recordDate.Unix(),
- ModeId: mode_id,
- DialysisDuration: dialysis_duration,
- Dialyzer: dialyzer,
- ReplacementTotal: replacement_total,
- PerfusionApparatus: perfusion_apparatus,
- BloodFlowVolume: blood_flow_volume,
- DewaterAmount: dewater_amount,
- DisplaceLiqui: displace_liqui,
- ReplacementWay: replacement_way,
- Anticoagulant: anticoagulant,
- AnticoagulantShouji: anticoagulant_shouji,
- AnticoagulantWeichi: anticoagulant_weichi,
- AnticoagulantZongliang: anticoagulant_zongliang,
- AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
- AnticoagulantGaijiliang: anticoagulant_gaijiliang,
- Kalium: kalium,
- Sodium: sodium,
- Calcium: calcium,
- Bicarbonate: bicarbonate,
- Glucose: glucose,
- // DryWeight: dry_weight,
- DialysateFlow: dialysate_flow,
- DialysateTemperature: dialysate_temperature,
- Conductivity: conductivity,
- Remark: remark,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DialysisDurationMinute: dialysisDurationMinute,
- DialysisDurationHour: dialysisDurationHour,
- TargetUltrafiltration: targetUltrafiltration,
- DialysateFormulation: dialysateFormulation,
- DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
- BodyFluid: body_fluid,
- SpecialMedicine: special_medicine,
- SpecialMedicineOther: special_medicine_other,
- DisplaceLiquiPart: displace_liqui_part,
- DisplaceLiquiValue: displace_liqui_value,
- BloodAccess: blood_access,
- Ultrafiltration: ultrafiltration,
- BodyFluidOther: body_fluid_other,
- TargetKtv: target_ktv,
- Niprocart: niprocart,
- Jms: jms,
- FistulaNeedleSet: fistula_needle_set,
- FistulaNeedleSet16: fistula_needle_set_16,
- Hemoperfusion: hemoperfusion,
- DialyserSterilised: dialyser_sterilised,
- Filtryzer: filtryzer,
- Dialyzers: dialyzers,
- Injector: injector,
- Bloodlines: bloodlines,
- TubingHemodialysis: tubing_hemodialysis,
- Package: safe_package,
- ALiquid: a_liquid,
- PreImpulse: preImpules,
- AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
- AnticoagulantStopTimeMin: anticoagulant_stop_time_min,
- Blood: blood,
- DialysisDialyszers: dialysis_dialyszers,
- DialysisIrrigation: dialysis_irrigation,
- AntioxidantCommodityName: antioxidant_commodity_name,
- DisplaceSpeed: displace_speed,
- Illness: illness,
- Amylaceum: amylaceum,
- SingleTime: single_time,
- SingleWater: single_water,
- ReplacementFlow: replacement_flow,
- PlasmaSeparator: plasma_separator,
- BilirubinAdsorptionColumn: bilirubin_adsorption_column,
- OxygenFlow: oxygen_flow,
- OxygenUptake: oxygen_uptake,
- OxygenTime: oxygen_time,
- HemodialysisPipelines: hemodialysis_pipelines,
- HemodialysisPipelinesCount: hemodialysis_pipelines_count,
- PunctureNeedle: puncture_needle,
- PunctureNeedleCount: puncture_needle_count,
- Epo: epo,
- EpoCount: epo_count,
- MaxUltrafiltrationRate: max_ultrafiltration_rate,
- }
-
- //查询最近透析准备表里是否存在 透析器 灌流器
-
- //splitStr := strings.Split(dialysis_dialyszers, ",")
- //
- //splitIrrigation := strings.Split(dialysis_irrigation, ",")
- //
- //mation, _ := service.GetGoodInfoMation(adminUserInfo.CurrentOrgId)
- //if len(mation)>0{
- // for _, item := range splitStr {
- // for _,it := range mation{
- // if(item == it.SpecificationName){
- //
- // //查询最近一次的透析器
- // _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
- //
- // if errcode == gorm.ErrRecordNotFound{
- // //插入数据
- // prepare := models.DialysisBeforePrepare{
- // UserOrgId: adminUserInfo.CurrentOrgId,
- // PatientId: patient,
- // RecordDate: recordDate.Unix(),
- // GoodTypeId: it.GoodTypeId,
- // GoodId: it.ID,
- // Count: 1,
- // Ctime: time.Now().Unix(),
- // Creater: adminUserInfo.AdminUser.Id,
- // Status:1,
- //
- // }
- // errcode := service.CreateDialysisBeforePrepareOne(&prepare)
- // fmt.Println("",errcode)
- // }
- // }
- // }
- //
- // }
- //
- // for _, item := range splitIrrigation {
- // for _,it := range mation{
- // if(item == it.SpecificationName){
- // //查询最近一次的透析器
- // _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
- // if errcode == gorm.ErrRecordNotFound{
- // //插入数据
- // prepare := models.DialysisBeforePrepare{
- // UserOrgId: adminUserInfo.CurrentOrgId,
- // PatientId: patient,
- // RecordDate: recordDate.Unix(),
- // GoodTypeId: it.GoodTypeId,
- // GoodId: it.ID,
- // Count: 1,
- // Ctime: time.Now().Unix(),
- // Creater: adminUserInfo.AdminUser.Id,
- // Status:1,
- //
- // }
- // errcode := service.CreateDialysisBeforePrepareOne(&prepare)
- // fmt.Println(errcode)
- // }
- // }
- // }
- // }
- //
- //}
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription.PrescriptionDoctor = appRole.AdminUserId
- }
-
- _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if dialysisPrescription.ID == 0 { //新增
- if mode_id > 0 {
- service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- }
-
- prescription.Creater = adminUserInfo.AdminUser.Id
- err := service.AddSigleRecord(&prescription)
- if err == nil {
- updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
- if updateErr != nil {
- utils.ErrorLog("%v", updateErr)
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "prescription": &prescription,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
-
- } else { //修改
- if mode_id > 0 {
- service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- }
-
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
- //if template.TemplateId == 1 {
- // if dialysisPrescription.Creater > 0 && dialysisPrescription.Creater != adminUserInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription_doctor := adminUserInfo.AdminUser.Id
- prescription.PrescriptionDoctor = prescription_doctor
-
- }
-
- if dialysisPrescription.Creater == 0 { //体重称
- prescription.Creater = adminUserInfo.AdminUser.Id
-
- } else {
- prescription.Creater = dialysisPrescription.Creater
- }
-
- prescription.CreatedTime = dialysisPrescription.CreatedTime
- prescription.UpdatedTime = time.Now().Unix()
- prescription.Modifier = adminUserInfo.AdminUser.Id
- prescription.ID = dialysisPrescription.ID
-
- updateErr := service.UpDateDialysisPrescription(&prescription)
- if updateErr == nil {
- updateErr := service.UpdateScheduleModeId(patient, adminUserInfo.CurrentOrgId, recordDate.Unix(), mode_id)
- if updateErr != nil {
- utils.ErrorLog("%v", updateErr)
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "prescription": &prescription,
- })
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- }
-
- }
- func (c *DialysisApiController) PostSoulution() {
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- mode_id, _ := c.GetInt64("mode_id", 0)
- dialysis_duration, _ := c.GetFloat("dialysis_duration", 0)
- dialyzer, _ := c.GetInt64("dialyzer", 0)
- perfusion_apparatus, _ := c.GetInt64("perfusion_apparatus", 0)
- blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
- replacement_total, _ := c.GetFloat("replacement_total", 0)
- dialyzerPerfusionApparatus := c.GetString("dialyzer_perfusion_apparatus")
-
- dewater_amount, _ := c.GetFloat("dewater_amount", 0)
- displace_liqui, _ := c.GetFloat("displace_liqui", 0)
- replacement_way, _ := c.GetInt64("replacement_way", 0)
- anticoagulant, _ := c.GetInt64("anticoagulant", 0)
- anticoagulant_shouji, _ := c.GetFloat("anticoagulant_shouji", 0)
- anticoagulant_weichi, _ := c.GetFloat("anticoagulant_weichi", 0)
- anticoagulant_zongliang, _ := c.GetFloat("anticoagulant_zongliang", 0)
- anticoagulant_gaimingcheng := c.GetString("anticoagulant_gaimingcheng")
- anticoagulant_gaijiliang := c.GetString("anticoagulant_gaijiliang")
- kalium, _ := c.GetFloat("kalium", 0)
- sodium, _ := c.GetFloat("sodium", 0)
- calcium, _ := c.GetFloat("calcium", 0)
- bicarbonate, _ := c.GetFloat("bicarbonate", 0)
- glucose, _ := c.GetFloat("glucose", 0)
- // dry_weight, _ := c.GetFloat("dry_weight", 0)
- dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
- dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
- conductivity, _ := c.GetFloat("conductivity", 0)
- remark := c.GetString("remark")
- dialysisDurationHour, _ := c.GetInt64("dialysis_duration_hour", 0)
- dialysisDurationMinute, _ := c.GetInt64("dialysis_duration_minute", 0)
- targetUltrafiltration, _ := c.GetFloat("target_ultrafiltration", 0)
- dialysateFormulation, _ := c.GetInt64("dialysate_formulation", 0)
- body_fluid, _ := c.GetInt64("body_fluid", 0)
- special_medicine, _ := c.GetInt64("special_medicine", 0)
- special_medicine_other := c.GetString("special_medicine_other")
- displace_liqui_part, _ := c.GetInt64("displace_liqui_part", 0)
- displace_liqui_value, _ := c.GetFloat("displace_liqui_value", 0)
- blood_access, _ := c.GetInt64("blood_access", 0)
- ultrafiltration, _ := c.GetFloat("ultrafiltration", 0)
- body_fluid_other := c.GetString("body_fluid_other")
- target_ktv, _ := c.GetFloat("target_ktv", 0)
-
- niprocart, _ := c.GetInt64("niprocart", 0)
- jms, _ := c.GetInt64("jms", 0)
- fistula_needle_set, _ := c.GetInt64("fistula_needle_set", 0)
- fistula_needle_set_16, _ := c.GetInt64("fistula_needle_set_16", 0)
- hemoperfusion, _ := c.GetInt64("hemoperfusion", 0)
- dialyser_sterilised, _ := c.GetInt64("dialyser_sterilised", 0)
- filtryzer, _ := c.GetInt64("filtryzer", 0)
-
- dialyzers, _ := c.GetInt64("dialyzers", 0)
- injector, _ := c.GetInt64("injector", 0)
- bloodlines, _ := c.GetInt64("bloodlines", 0)
- tubing_hemodialysis, _ := c.GetInt64("tubing_hemodialysis", 0)
- safe_package, _ := c.GetInt64("package", 0)
- a_liquid, _ := c.GetInt64("a_liquid", 0)
-
- anticoagulant_stop_time_hour, _ := c.GetInt64("anticoagulant_stop_time_hour", 0)
- anticoagulant_stop_time_min, _ := c.GetInt64("anticoagulant_stop_time_min", 0)
- blood := c.GetString("blood")
- dialysis_dialyszers := c.GetString("dialysis_dialyszers")
- dialysis_irrigation := c.GetString("dialysis_irrigation")
- antioxidant_commodity_name := c.GetString("antioxidant_commodity_name")
- displace_speed := c.GetString("displace_speed")
- illness, _ := c.GetInt64("illness")
- amylaceum := c.GetString("amylaceum")
- single_time := c.GetString("single_time")
- single_water := c.GetString("single_water")
- replacement_flow := c.GetString("replacement_flow")
- plasma_separator := c.GetString("plasma_separator")
- bilirubin_adsorption_column := c.GetString("bilirubin_adsorption_column")
- oxygen_uptake, _ := c.GetInt64("oxygen_uptake")
- oxygen_flow := c.GetString("oxygen_flow")
- oxygen_time := c.GetString("oxygen_time")
-
- hemodialysis_pipelines := c.GetString("hemodialysis_pipelines")
- hemodialysis_pipelines_count, _ := c.GetFloat("hemodialysis_pipelines_count", 0)
-
- puncture_needle := c.GetString("puncture_needle")
- puncture_needle_count, _ := c.GetFloat("puncture_needle_count", 0)
-
- epo := c.GetString("epo")
- epo_count, _ := c.GetFloat("epo_count", 0)
- max_ultrafiltration_rate, _ := c.GetFloat("max_ultrafiltration_rate")
- var prescription_doctor int64
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription_doctor = appRole.AdminUserId
- }
-
- if mode_id > 0 {
- service.ModifyScheduleMode(mode_id, patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- }
-
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
- //
- //if template.TemplateId == 2 || template.TemplateId == 6 {
- // if appRole.UserType == 3 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- prescription := models.DialysisPrescription{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- RecordDate: recordDate.Unix(),
- ModeId: mode_id,
- DialysisDuration: dialysis_duration,
- Dialyzer: dialyzer,
- PerfusionApparatus: perfusion_apparatus,
- BloodFlowVolume: blood_flow_volume,
- DewaterAmount: dewater_amount,
- DisplaceLiqui: displace_liqui,
- ReplacementWay: replacement_way,
- Anticoagulant: anticoagulant,
- AnticoagulantShouji: anticoagulant_shouji,
- AnticoagulantWeichi: anticoagulant_weichi,
- AnticoagulantZongliang: anticoagulant_zongliang,
- AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
- AnticoagulantGaijiliang: anticoagulant_gaijiliang,
- Kalium: kalium,
- Sodium: sodium,
- Calcium: calcium,
- Bicarbonate: bicarbonate,
- Glucose: glucose,
- // DryWeight: dry_weight,
- DialysateFlow: dialysate_flow,
- DialysateTemperature: dialysate_temperature,
- Conductivity: conductivity,
- Remark: remark,
- PrescriptionDoctor: prescription_doctor,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DialysisDurationMinute: dialysisDurationMinute,
- DialysisDurationHour: dialysisDurationHour,
- TargetUltrafiltration: targetUltrafiltration,
- DialysateFormulation: dialysateFormulation,
- ReplacementTotal: replacement_total,
- DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
- BodyFluid: body_fluid,
- SpecialMedicine: special_medicine,
- SpecialMedicineOther: special_medicine_other,
- DisplaceLiquiPart: displace_liqui_part,
- DisplaceLiquiValue: displace_liqui_value,
- BloodAccess: blood_access,
- Ultrafiltration: ultrafiltration,
- BodyFluidOther: body_fluid_other,
- TargetKtv: target_ktv,
- Niprocart: niprocart,
- Jms: jms,
- FistulaNeedleSet: fistula_needle_set,
- FistulaNeedleSet16: fistula_needle_set_16,
- Hemoperfusion: hemoperfusion,
- DialyserSterilised: dialyser_sterilised,
- Filtryzer: filtryzer,
- Dialyzers: dialyzers,
- Injector: injector,
- Bloodlines: bloodlines,
- TubingHemodialysis: tubing_hemodialysis,
- Package: safe_package,
- ALiquid: a_liquid,
-
- AnticoagulantStopTimeHour: anticoagulant_stop_time_hour,
- AnticoagulantStopTimeMin: anticoagulant_stop_time_min,
- Blood: blood,
- DialysisIrrigation: dialysis_irrigation,
- DialysisDialyszers: dialysis_dialyszers,
- AntioxidantCommodityName: antioxidant_commodity_name,
- DisplaceSpeed: displace_speed,
- Illness: illness,
- Amylaceum: amylaceum,
- SingleTime: single_time,
- SingleWater: single_water,
- ReplacementFlow: replacement_flow,
- PlasmaSeparator: plasma_separator,
- BilirubinAdsorptionColumn: bilirubin_adsorption_column,
- OxygenTime: oxygen_time,
- OxygenUptake: oxygen_uptake,
- OxygenFlow: oxygen_flow,
- HemodialysisPipelines: hemodialysis_pipelines,
- HemodialysisPipelinesCount: hemodialysis_pipelines_count,
- PunctureNeedle: puncture_needle,
- PunctureNeedleCount: puncture_needle_count,
- Epo: epo,
- EpoCount: epo_count,
- MaxUltrafiltrationRate: max_ultrafiltration_rate,
- }
-
- //查询最近透析准备表里是否存在 透析器 灌流器
-
- //splitStr := strings.Split(dialysis_dialyszers, ",")
- //
- //splitIrrigation := strings.Split(dialysis_irrigation, ",")
- //
- //mation, _ := service.GetGoodInfoMation(adminUserInfo.CurrentOrgId)
- //if len(mation)>0{
- // for _, item := range splitStr {
- // for _,it := range mation{
- // if(item == it.SpecificationName){
- //
- // //查询最近一次的透析器
- // _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
- //
- // if errcode == gorm.ErrRecordNotFound{
- // //插入数据
- // prepare := models.DialysisBeforePrepare{
- // UserOrgId: adminUserInfo.CurrentOrgId,
- // PatientId: patient,
- // RecordDate: recordDate.Unix(),
- // GoodTypeId: it.GoodTypeId,
- // GoodId: it.ID,
- // Count: 1,
- // Ctime: time.Now().Unix(),
- // Creater: adminUserInfo.AdminUser.Id,
- // Status:1,
- //
- // }
- // errcode := service.CreateDialysisBeforePrepareOne(&prepare)
- // fmt.Println("",errcode)
- // }
- // }
- // }
- //
- // }
- //
- // for _, item := range splitIrrigation {
- // for _,it := range mation{
- // if(item == it.SpecificationName){
- // //查询最近一次的透析器
- // _, errcode := service.GetDialysisBeforePrepare(it.GoodTypeId, it.ID, adminUserInfo.CurrentOrgId,patient)
- // if errcode == gorm.ErrRecordNotFound{
- // //插入数据
- // prepare := models.DialysisBeforePrepare{
- // UserOrgId: adminUserInfo.CurrentOrgId,
- // PatientId: patient,
- // RecordDate: recordDate.Unix(),
- // GoodTypeId: it.GoodTypeId,
- // GoodId: it.ID,
- // Count: 1,
- // Ctime: time.Now().Unix(),
- // Creater: adminUserInfo.AdminUser.Id,
- // Status:1,
- //
- // }
- // errcode := service.CreateDialysisBeforePrepareOne(&prepare)
- // fmt.Println(errcode)
- // }
- // }
- // }
- // }
- //}
-
- _, dialysisPrescription := service.FindDialysisPrescriptionByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if dialysisPrescription.ID == 0 { //新增
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription.PrescriptionDoctor = adminUserInfo.AdminUser.Id
- }
-
- prescription.Creater = adminUserInfo.AdminUser.Id
-
- } else { //修改
-
- //template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
- //if template.TemplateId == 1 {
- // if dialysisPrescription.Creater != adminUserInfo.AdminUser.Id && dialysisPrescription.Creater != 0 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
- if appRole.UserType == 2 || appRole.UserType == 1 {
- prescription_doctor := adminUserInfo.AdminUser.Id
- prescription.PrescriptionDoctor = prescription_doctor
- } else {
- prescription.PrescriptionDoctor = dialysisPrescription.PrescriptionDoctor
- }
-
- if dialysisPrescription.Creater == 0 {
- prescription.Creater = adminUserInfo.AdminUser.Id
- } else {
- prescription.Creater = dialysisPrescription.Creater
- }
-
- prescription.CreatedTime = dialysisPrescription.CreatedTime
- prescription.UpdatedTime = time.Now().Unix()
- prescription.Modifier = adminUserInfo.AdminUser.Id
-
- prescription.ID = dialysisPrescription.ID
-
- }
-
- solution := models.DialysisSolution{
- RegistrarsId: adminUserInfo.AdminUser.Id,
- UserOrgId: adminUserInfo.CurrentOrgId,
- Doctor: prescription_doctor,
- PatientId: patient,
- ModeId: mode_id,
- DialysisDuration: dialysis_duration,
- PerfusionApparatus: perfusion_apparatus,
- BloodFlowVolume: blood_flow_volume,
- Dewater: dewater_amount,
- DisplaceLiqui: displace_liqui,
- ReplacementWay: replacement_way,
- Anticoagulant: anticoagulant,
- AnticoagulantShouji: anticoagulant_shouji,
- AnticoagulantWeichi: anticoagulant_weichi,
- AnticoagulantZongliang: anticoagulant_zongliang,
- AnticoagulantGaimingcheng: anticoagulant_gaimingcheng,
- AnticoagulantGaijiliang: anticoagulant_gaijiliang,
- Kalium: kalium,
- Sodium: sodium,
- Calcium: calcium,
- Bicarbonate: bicarbonate,
- Glucose: glucose,
- // DryWeight: dry_weight,
- DialysateFlow: dialysate_flow,
- DialysateTemperature: dialysate_temperature,
- Conductivity: conductivity,
- Remark: remark,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- DialysisDurationMinute: dialysisDurationMinute,
- DialysisDurationHour: dialysisDurationHour,
- TargetUltrafiltration: targetUltrafiltration,
- DialysateFormulation: dialysateFormulation,
- DialyzerPerfusionApparatus: dialyzerPerfusionApparatus,
- BodyFluid: body_fluid,
- SpecialMedicine: special_medicine,
- SpecialMedicineOther: special_medicine_other,
- DisplaceLiquiPart: displace_liqui_part,
- DisplaceLiquiValue: displace_liqui_value,
- BloodAccess: blood_access,
- Ultrafiltration: ultrafiltration,
- BodyFluidOther: body_fluid_other,
- ReplacementTotal: replacement_total,
- TargetKtv: target_ktv,
- DialysisIrrigation: dialysis_irrigation,
- DialysisDialyszers: dialysis_dialyszers,
- HemodialysisPipelines: hemodialysis_pipelines,
- HemodialysisPipelinesCount: hemodialysis_pipelines_count,
- PunctureNeedle: puncture_needle,
- PunctureNeedleCount: puncture_needle_count,
- Epo: epo,
- EpoCount: epo_count,
- MaxUltrafiltrationRate: max_ultrafiltration_rate,
- }
- err := service.SavePrescriptionAndCreateSolution(&solution, &prescription)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "solution": &solution,
- "prescription": &prescription,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- }
- func (c *DialysisApiController) PostDouleCheck() {
-
- id, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
- checkTimeStr := c.GetString("check_time")
- firstCheckTimeStr := c.GetString("first_check_time")
- creater, _ := c.GetInt64("creater", 0)
- modifier, _ := c.GetInt64("modifier", 0)
-
- dialysis_item_check, _ := c.GetInt64("dialysis_item_check", 0)
- dialysis_parameter_check, _ := c.GetInt64("dialysis_parameter_check", 0)
- vascular_access_verification, _ := c.GetInt64("vascular_access_verification", 0)
- pipeline_connection_check, _ := c.GetInt64("pipeline_connection_check", 0)
- dialysis_item_desc := c.GetString("dialysis_item_desc")
- dialysis_parameter_desc := c.GetString("dialysis_parameter_desc")
- vascular_access_desc := c.GetString("vascular_access_desc")
- pipeline_connection_desc := c.GetString("pipeline_connection_desc")
- collator, _ := c.GetInt64("collator", 0)
-
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- var checkDate int64
-
- if len(checkTimeStr) == 0 {
- //checkTimeStr = time.Now().Format("2006-01-02 15:04")
- checkDate = 0
- } else {
- checkDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", checkTimeStr)
- checkDate = checkDateUnix.Unix()
- }
-
- var firstCheckTimeDate int64
-
- if len(firstCheckTimeStr) == 0 {
- //firstCheckTimeStr = time.Now().Format("2006-01-02 15:04")
- firstCheckTimeDate = 0
- } else {
- firstCheckTimeDateUnix, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", firstCheckTimeStr)
-
- firstCheckTimeDate = firstCheckTimeDateUnix.Unix()
-
- }
-
- doubleCheck := models.DoubleCheck{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: id,
- DialysisItemCheck: dialysis_item_check,
- DialysisParameterCheck: dialysis_parameter_check,
- VascularAccessVerification: vascular_access_verification,
- PipelineConnectionCheck: pipeline_connection_check,
- DialysisItemDesc: dialysis_item_desc,
- DialysisParameterDesc: dialysis_parameter_desc,
- VascularAccessDesc: vascular_access_desc,
- PipelineConnectionDesc: pipeline_connection_desc,
- Collator: collator,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- CheckDate: recordDate.Unix(),
- }
-
- _, check := service.FindDoubleCheckByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if check.ID == 0 { //新增
- doubleCheck.FirstCheckTime = firstCheckTimeDate
- doubleCheck.CheckTime = checkDate
- doubleCheck.Creater = creater
- doubleCheck.Modifier = modifier
-
- err := service.AddSigleDoubleCheck(&doubleCheck)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "doubleCheck": doubleCheck,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
- } else { //修改
- doubleCheck.FirstCheckTime = firstCheckTimeDate
- doubleCheck.CheckTime = checkDate
- doubleCheck.Creater = creater
- doubleCheck.Modifier = modifier
- doubleCheck.CreatedTime = check.CreatedTime
- doubleCheck.UpdatedTime = time.Now().Unix()
- doubleCheck.ID = check.ID
- err := service.UpdateDoubleCheck(&doubleCheck)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "doubleCheck": doubleCheck,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- }
-
- }
- func (c *DialysisApiController) PostReceiveTreatmentAsses() {
- id, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
- way, _ := c.GetInt64("way", 0)
- consciousness, _ := c.GetInt64("consciousness", 0)
- appetite, _ := c.GetInt64("appetite", 0)
- condition, _ := c.GetInt64("condition", 0)
- posture, _ := c.GetInt64("posture")
- score := c.GetString("score")
-
- sick_condition, _ := c.GetInt64("sick_condition", 0)
- danger_level, _ := c.GetInt64("danger_level", 0)
- intake, _ := c.GetInt64("intake", 0)
- nutrition, _ := c.GetInt64("nutrition", 0)
- psychological_assessment, _ := c.GetInt64("psychological_assessment", 0)
- psychological_assessment_other := c.GetString("psychological_assessment_other")
- sick_condition_other := c.GetString("sick_condition_other")
-
- //precaution, _ := c.GetInt64("precaution", 0)
- precaution := c.GetString("precaution")
- precaution_other := c.GetString("precaution_other")
- psychological_other := c.GetString("psychological_other")
- admission_number := c.GetString("admission_number")
- tumble, _ := c.GetInt64("tumble")
- if id <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- patient, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, id)
- if patient.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- _, receiveTreatment := service.FindReceiveTreatmentAssesByReordDate(id, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- receiveTreatmentAsses := models.ReceiveTreatmentAsses{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: id,
- RecordDate: recordDate.Unix(),
- Way: way,
- Consciousness: consciousness,
- Appetite: appetite,
- Condition: condition,
- SickCondition: sick_condition,
- DangerLevel: danger_level,
- Intake: intake,
- Nutrition: nutrition,
- PsychologicalAssessment: psychological_assessment,
- PsychologicalAssessmentOther: psychological_assessment_other,
- SickConditionOther: sick_condition_other,
- Posture: posture,
- CreatedTime: time.Now().Unix(),
- UpdateTime: time.Now().Unix(),
- Status: 1,
- Score: score,
- Precaution: precaution,
- PrecautionOther: precaution_other,
- PsychologicalOther: psychological_other,
- AdmissionNumber: admission_number,
- Tumble: tumble,
- }
-
- if receiveTreatment.ID == 0 { //新增
- receiveTreatmentAsses.Creater = adminUserInfo.AdminUser.Id
- err := service.AddSigleReceiveTreatmentAssesRecord(&receiveTreatmentAsses)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "receiveTreatmentAsses": receiveTreatmentAsses,
- })
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
-
- } else { //修改
- //if receiveTreatment.Creater != adminUserInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- receiveTreatmentAsses.Creater = receiveTreatment.Creater
- receiveTreatmentAsses.CreatedTime = receiveTreatment.CreatedTime
- receiveTreatmentAsses.UpdateTime = time.Now().Unix()
- receiveTreatmentAsses.Modifier = adminUserInfo.AdminUser.Id
- receiveTreatmentAsses.ID = receiveTreatment.ID
- err := service.UpadateReceiveTreatmentAsses(&receiveTreatmentAsses)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "receiveTreatmentAsses": receiveTreatmentAsses,
- })
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
- }
-
- }
-
- func (c *DialysisApiController) PostAssessmentAfterDislysis() {
-
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
- fmt.Println(recordDateStr)
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
-
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- // data := make(map[string]interface{}, 0)
- var data models.AssessmentAfterDislysis
- var err error
- err = json.Unmarshal(c.Ctx.Input.RequestBody, &data)
- fmt.Println(err)
- if err != nil {
- c.ErrorLog("数据解析错误:%v", err)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- assessment, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- assessment.DialysisOrderId = data.DialysisOrderId
- assessment.Evaluator = adminUserInfo.AdminUser.Id
- assessment.Status = 1
- assessment.WeightAfter = data.WeightAfter
- assessment.WeightLoss = data.WeightLoss
- assessment.Temperature = data.Temperature
- assessment.SystolicBloodPressure = data.SystolicBloodPressure
- assessment.DiastolicBloodPressure = data.DiastolicBloodPressure
- assessment.PulseFrequency = data.PulseFrequency
- assessment.ActualUltrafiltration = data.ActualUltrafiltration
- assessment.ActualDisplacement = data.ActualDisplacement
- assessment.ActualTreatmentHour = data.ActualTreatmentHour
- assessment.ActualTreatmentMinute = data.ActualTreatmentMinute
- assessment.Cruor = data.Cruor
- assessment.SymptomAfterDialysis = data.SymptomAfterDialysis
- assessment.DialysisIntakes = data.DialysisIntakes
- assessment.InternalFistula = data.InternalFistula
- assessment.BloodAccessPartId = data.BloodAccessPartId
- assessment.BloodAccessPartOperaId = data.BloodAccessPartOperaId
- assessment.Catheter = data.Catheter
- assessment.Complication = data.Complication
- assessment.PuncturePointOozingBlood = data.PuncturePointOozingBlood
- assessment.PuncturePointHaematoma = data.PuncturePointHaematoma
- assessment.InternalFistulaTremorAc = data.InternalFistulaTremorAc
- assessment.PatientGose = data.PatientGose
- assessment.InpatientDepartment = data.InpatientDepartment
- assessment.ObservationContent = data.ObservationContent
- assessment.ObservationContentOther = data.ObservationContentOther
- assessment.Remark = data.Remark
- assessment.BreathingRate = data.BreathingRate
- assessment.DialysisProcess = data.DialysisProcess
- assessment.InAdvanceMinute = data.InAdvanceMinute
- assessment.InAdvanceReasonOther = data.InAdvanceReasonOther
- assessment.InAdvanceReason = data.InAdvanceReason
- assessment.HemostasisOpera = data.HemostasisOpera
- assessment.HemostasisMinute = data.HemostasisMinute
- assessment.TremorNoise = data.TremorNoise
- assessment.DisequilibriumSyndrome = data.DisequilibriumSyndrome
- assessment.DisequilibriumSyndromeOption = data.DisequilibriumSyndromeOption
- assessment.ArterialTube = data.ArterialTube
- assessment.IntravenousTube = data.IntravenousTube
- assessment.DialysisIntakesUnit = data.DialysisIntakesUnit
- assessment.Dialyzer = data.Dialyzer
- assessment.IsEat = data.IsEat
- assessment.CvcA = data.CvcA
- assessment.CvcV = data.CvcV
- assessment.Channel = data.Channel
- assessment.ReturnBlood = data.ReturnBlood
- assessment.RehydrationVolume = data.RehydrationVolume
- assessment.DialysisDuring = data.DialysisDuring
- assessment.StrokeVolume = data.StrokeVolume
- assessment.BloodFlow = data.BloodFlow
- assessment.SealingFluidDispose = data.SealingFluidDispose
- assessment.SealingFluidSpecial = data.SealingFluidSpecial
- assessment.DosageOfAnticoagulants = data.DosageOfAnticoagulants
- assessment.SupineSystolicBloodPressure = data.SupineSystolicBloodPressure
- assessment.SettingPressure = data.SettingPressure
- assessment.SupineDiastolicBloodPressure = data.SupineDiastolicBloodPressure
- assessment.DiastolicPressure = data.DiastolicPressure
- assessment.AdditionalWeight = data.AdditionalWeight
- assessment.OtherComplication = data.OtherComplication
- assessment.Ktv = data.Ktv
-
- assessment.Urr = data.Urr
- assessment.Hypertenison = data.Hypertenison
- assessment.Hypopiesia = data.Hypopiesia
- assessment.LeaveOfficeMethod = data.LeaveOfficeMethod
- assessment.Lapse = data.Lapse
- assessment.Consciousness = data.Consciousness
- assessment.Fallrisk = data.Fallrisk
- assessment.MachineRun = data.MachineRun
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
-
- if assessment.ID > 0 {
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
- assessment.AssessmentTime = time.Now().Unix()
- } else {
- if assessment.Creater == 0 {
- assessment.Modifier = adminUserInfo.AdminUser.Id
- assessment.Creater = adminUserInfo.AdminUser.Id
- } else {
- assessment.Modifier = adminUserInfo.AdminUser.Id
- }
- }
-
- assessment.UpdatedTime = time.Now().Unix()
- err = service.UpdateAssessmentAfterDislysisRecord(&assessment)
- } else {
- if appRole.UserType == 2 || appRole.UserType == 1 {
- assessment.AssessmentDoctor = adminUserInfo.AdminUser.Id
- assessment.AssessmentTime = time.Now().Unix()
- } else {
- assessment.Creater = adminUserInfo.AdminUser.Id
- }
- assessment.CreatedTime = time.Now().Unix()
- assessment.UpdatedTime = time.Now().Unix()
- assessment.UserOrgId = adminUserInfo.CurrentOrgId
- assessment.PatientId = patient
- assessment.AssessmentDate = recordDate.Unix()
-
- err = service.AddSigleAssessmentAfterDislysisRecord(&assessment)
- }
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "AssessmentAfterDislysis": &assessment,
- })
-
- }
-
- func (c *DialysisApiController) PostAssessmentBeforeDislysis() {
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- weight_before, _ := c.GetFloat("weight_before", 0)
- dry_weight, _ := c.GetFloat("dry_weight", 0)
- additional_weight, _ := c.GetFloat("additional_weight", 0)
- temperature, _ := c.GetFloat("temperature", 0)
- pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
- systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
- diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
- last_post_dialysis := c.GetString("last_post_dialysis")
- dialysis_interphase := c.GetString("dialysis_interphase")
- symptom_before_dialysis := c.GetString("symptom_before_dialysis")
- bloodAccessPartOperaId, _ := c.GetInt64("blood_access_part_opera_id", 0)
- //bloodAccessPartId, _ := c.GetInt64("blood_access_part_id", 0)
- bloodAccessPartId := c.GetString("blood_access_part_id")
- internalFistula := c.GetString("internal_fistula")
- internal_fistula_skin := c.GetString("internal_fistula_skin")
- catheter := c.GetString("catheter")
- catheter_bend, _ := c.GetInt("catheter_bend")
- complication := c.GetString("complication")
- is_hemorrhage, _ := c.GetInt64("is_hemorrhage", 0)
- hemorrhage := c.GetString("hemorrhage")
- hemorrhage_other := c.GetString("hemorrhage_other")
- remark := c.GetString("remark")
- puncture_method := c.GetString("puncture_method")
-
- dialysis_count, _ := c.GetInt64("dialysis_count", 0)
- emergency_treatment, _ := c.GetInt64("emergency_treatment", 0)
- emergency_treatment_other := c.GetString("emergency_treatment_other")
- ductus_arantii := c.GetString("ductus_arantii")
- venous_catheterization_part_other := c.GetString("venous_catheterization_part_other")
- venous_catheterization_part, _ := c.GetInt64("venous_catheterization_part", 0)
- venous_catheterization, _ := c.GetInt64("venous_catheterization", 0)
- //puncture_way, _ := c.GetInt64("puncture_way", 0)
- puncture_way := c.GetString("puncture_way")
- blood_access_noise, _ := c.GetInt64("blood_access_noise", 0)
- internal_fistula_other := c.GetString("internal_fistula_other")
- blood_access_internal_fistula := c.GetString("blood_access_internal_fistula")
-
- breathing_rate, _ := c.GetFloat("breathing_rate", 0)
-
- is_infect, _ := c.GetInt64("is_infect", 0)
- exposed, _ := c.GetFloat("exposed", 0)
- //skin, _ := c.GetInt64("skin", 0)
- skin := c.GetString("skin")
- skin_other := c.GetString("skin_other")
- infect_other := c.GetString("infect_other")
- ductus_arantii_other := c.GetString("ductus_arantii_other")
- machine_type := c.GetString("machine_type")
- puncture_needle := c.GetString("puncture_needle")
- humor_excessive_symptom, _ := c.GetInt64("humor_excessive_symptom", 0)
- phinholing := c.GetString("pinholing")
-
- catheter_suture := c.GetString("catheter_suture")
- catheter_suture_other := c.GetString("catheter_suture_other")
- edema := c.GetString("edema")
- urine_volume, _ := c.GetFloat("urine_volume", 0)
- special_treatment := c.GetString("special_treatment")
- catheter_maintenance := c.GetString("catheter_maintenance")
- thrombusType := c.GetString("thromubus_type")
- thrombusInt, _ := strconv.ParseInt(thrombusType, 10, 64)
- thrombus_a := c.GetString("thromubus_a")
- thrombus_av := c.GetString("thrombus_av")
- thrombus_v := c.GetString("thromubus_v")
- dehydration := c.GetString("dehydration")
- pre_dialysis_drugs := c.GetString("pre_dialysis_drugs")
- period, _ := c.GetInt64("period")
- estimated_food_intake := c.GetString("estimated_food_intake")
- blood_pressure_during_dialysis := c.GetString("blood_pressure_during_dialysis")
- assessmentBeforeDislysis := models.PredialysisEvaluation{
- DialysisCount: dialysis_count,
- EmergencyTreatment: emergency_treatment,
- EmergencyTreatmentOther: emergency_treatment_other,
- DuctusArantii: ductus_arantii,
- VenousCatheterization: venous_catheterization,
- VenousCatheterizationPart: venous_catheterization_part,
- VenousCatheterizationPartOther: venous_catheterization_part_other,
- PunctureWay: puncture_way,
- BloodAccessInternalFistula: blood_access_internal_fistula,
- BloodAccessNoise: blood_access_noise,
- InternalFistulaOther: internal_fistula_other,
- Evaluator: adminUserInfo.AdminUser.Id,
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- AssessmentDate: recordDate.Unix(),
- Temperature: temperature,
- PulseFrequency: pulse_frequency,
- SystolicBloodPressure: systolic_blood_pressure,
- DiastolicBloodPressure: diastolic_blood_pressure,
- WeightBefore: weight_before,
- DryWeight: dry_weight,
- AdditionalWeight: additional_weight,
- DialysisInterphase: dialysis_interphase,
- LastPostDialysis: last_post_dialysis,
- SymptomBeforeDialysis: symptom_before_dialysis,
- InternalFistula: internalFistula,
- InternalFistulaSkin: internal_fistula_skin,
- Catheter: catheter,
- CatheterBend: catheter_bend,
- Complication: complication,
- CreatedTime: time.Now().Unix(),
- Status: 1,
- Remark: remark,
- IsHemorrhage: is_hemorrhage,
- Hemorrhage: hemorrhage,
- HemorrhageOther: hemorrhage_other,
- BloodAccessPartId: bloodAccessPartId,
- BloodAccessPartOperaId: bloodAccessPartOperaId,
- PunctureMethod: puncture_method,
- BreathingRate: breathing_rate,
- IsInfect: is_infect,
- Exposed: exposed,
- Skin: skin,
- SkinOther: skin_other,
- InfectOther: infect_other,
- DuctusArantiiOther: ductus_arantii_other,
- MachineType: machine_type,
- PunctureNeedle: puncture_needle,
- HumorExcessiveSymptom: humor_excessive_symptom,
- Phinholing: phinholing,
- CatheterSuture: catheter_suture,
- CatheterSutureOther: catheter_suture_other,
- Edema: edema,
- UrineVolume: urine_volume,
- SpecialTreatment: special_treatment,
- CatheterMaintenance: catheter_maintenance,
- ThromubusType: thrombusInt,
- ThrombusAv: thrombus_av,
- ThromubusA: thrombus_a,
- ThromubusV: thrombus_v,
- Dehydration: dehydration,
- PreDialysisDrugs: pre_dialysis_drugs,
- Period: period,
- EstimatedFoodIntake: estimated_food_intake,
- BloodPressureDuringDialysis: blood_pressure_during_dialysis,
- }
-
- appRole, _ := service.FindAdminRoleTypeById(adminUserInfo.CurrentOrgId, adminUserInfo.AdminUser.Id, adminUserInfo.CurrentAppId)
-
- _, evaluation := service.FindPredialysisEvaluationByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if evaluation.ID == 0 { //新增
- if appRole.UserType == 2 || appRole.UserType == 1 {
- assessmentBeforeDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
- assessmentBeforeDislysis.AssessmentTime = time.Now().Unix()
- } else {
- assessmentBeforeDislysis.Creater = adminUserInfo.AdminUser.Id
-
- }
-
- err := service.AddSigleAssessmentBeforeDislysisRecord(&assessmentBeforeDislysis)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "assessmentBeforeDislysis": &assessmentBeforeDislysis,
- })
- } else {
- //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
- } else { //修改
- //if appRole.UserType == 3 {
- // if evaluation.Creater != adminUserInfo.AdminUser.Id && evaluation.Creater != 0 {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- if appRole.UserType == 2 || appRole.UserType == 1 {
- assessmentBeforeDislysis.AssessmentDoctor = adminUserInfo.AdminUser.Id
- assessmentBeforeDislysis.AssessmentTime = time.Now().Unix()
- } else {
- if evaluation.Creater == 0 {
- assessmentBeforeDislysis.Modifier = adminUserInfo.AdminUser.Id
- assessmentBeforeDislysis.Creater = adminUserInfo.AdminUser.Id
- } else {
- assessmentBeforeDislysis.Modifier = adminUserInfo.AdminUser.Id
- }
- }
-
- assessmentBeforeDislysis.UpdatedTime = time.Now().Unix()
- assessmentBeforeDislysis.ID = evaluation.ID
- assessmentBeforeDislysis.CreatedTime = evaluation.CreatedTime
- //
-
- //新增逻辑
- templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- var dewater_amount float64
- dewater_amount = 0
- if evaluation.DryWeight > 0 {
- dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
- if templateInfo.TemplateId == 17 || templateInfo.TemplateId == 22 || templateInfo.TemplateId == 21 || templateInfo.TemplateId == 34 {
- dewater_amount = dewater_amount * 1000
- }
- if dewater_amount <= 0 {
- dewater_amount = 0
- }
- } else {
- dewater_amount = 0
- }
- // 计算透析处方的相关超滤量
- schedual, _ := service.MobileGetSchedualDetail(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- var lastDialysisPrescribe *models.DialysisPrescription
- var dialysisSolution *models.DialysisSolution
- var dialysisPrescribe *models.DialysisPrescription
- var mode_id int64
- if schedual != nil {
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribeByModeId(adminUserInfo.CurrentOrgId, patient, recordDate.Unix(), schedual.ModeId)
- if dialysisPrescribe == nil {
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- }
- lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeId(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
- // 获取透析模版
- dialysisSolution, _ = service.MobileGetDialysisSolutionByModeId(adminUserInfo.CurrentOrgId, patient, schedual.ModeId)
- mode_id = schedual.ModeId
- } else {
- //lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribe(adminUserInfo.Org.Id, id,schedual.ModeId)
- // 获取透析模版
- dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.CurrentOrgId, patient, recordDate.Unix())
- dialysisSolution, _ = service.MobileGetDialysisSolution(adminUserInfo.CurrentOrgId, patient)
-
- if dialysisPrescribe == nil && dialysisSolution != nil {
- mode_id = dialysisSolution.ModeId
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- mode_id = 0
- }
- }
-
- // 插入透析处方
- if dialysisPrescribe == nil && dialysisSolution != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = dialysisSolution.UserOrgId
- newprescribe.PatientId = dialysisSolution.PatientId
- newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
- newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
- newprescribe.ModeId = dialysisSolution.ModeId
- newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
- newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
- newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
- newprescribe.BloodFilter = dialysisSolution.BloodFilter
- newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
- newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
- newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
- newprescribe.Glucose = dialysisSolution.Glucose
- newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
- newprescribe.Kalium = dialysisSolution.Kalium
- newprescribe.Sodium = dialysisSolution.Sodium
- newprescribe.Calcium = dialysisSolution.Calcium
- newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
- newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
- newprescribe.Conductivity = dialysisSolution.Conductivity
- newprescribe.BodyFluid = dialysisSolution.BodyFluid
- newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
- newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
- newprescribe.BloodAccess = dialysisSolution.BloodAccess
- newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
- newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
- newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
- newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
- newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
- newprescribe.Dialyzer = dialysisSolution.Dialyzer
- newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
- newprescribe.TargetKtv = dialysisSolution.TargetKtv
-
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Status = 1
-
- err := service.AddSigleRecord(&newprescribe)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
-
- if dialysisPrescribe == nil && dialysisSolution == nil {
- if lastDialysisPrescribe != nil {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
- newprescribe.PatientId = lastDialysisPrescribe.PatientId
- newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
- newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
- newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
- newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
- newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
- newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
- newprescribe.ModeId = lastDialysisPrescribe.ModeId
- newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
- newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
- newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
- newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
- newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
- newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
- newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
- newprescribe.Glucose = lastDialysisPrescribe.Glucose
- newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
- newprescribe.Kalium = lastDialysisPrescribe.Kalium
- newprescribe.Sodium = lastDialysisPrescribe.Sodium
- newprescribe.Calcium = lastDialysisPrescribe.Calcium
- newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
- newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
- newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
- newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
- newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
- newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
- newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
- newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
- newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
- newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
- newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
- newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
- newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
- newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
- newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
- newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
- newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
- newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Status = 1
- err := service.AddSigleRecord(&newprescribe)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- } else {
- var newprescribe models.DialysisPrescription
- newprescribe.UserOrgId = adminUserInfo.CurrentOrgId
- newprescribe.PatientId = patient
- newprescribe.ModeId = mode_id
- newprescribe.CreatedTime = time.Now().Unix()
- newprescribe.UpdatedTime = time.Now().Unix()
- newprescribe.RecordDate = recordDate.Unix()
- newprescribe.DewaterAmount = dewater_amount
- newprescribe.TargetUltrafiltration = dewater_amount
- newprescribe.Status = 1
-
- err := service.AddSigleRecord(&newprescribe)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
- }
- }
-
- err := service.UpadatePredialysisEvaluation(&assessmentBeforeDislysis)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "assessmentBeforeDislysis": &assessmentBeforeDislysis,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
-
- }
-
- }
- func (c *DialysisApiController) PostTreatmentSummary() {
- patient, _ := c.GetInt64("patient", 0)
- recordDateStr := c.GetString("record_date")
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- if len(recordDateStr) == 0 {
- recordDateStr = time.Now().Format("2006-01-02")
- }
- recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
- if parseDateErr != nil {
- c.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- mission := c.GetString("mission")
- dialysis_summary := c.GetString("dialysis_summary")
- nursingRecord := c.GetString("nursing_record")
- specialRecord := c.GetString("special_record")
- sj_nurse := adminUserInfo.AdminUser.Id
- zl_nurse := adminUserInfo.AdminUser.Id
- hd_nurse := adminUserInfo.AdminUser.Id
- xj_nurse := adminUserInfo.AdminUser.Id
- zl_doctor := adminUserInfo.AdminUser.Id
-
- treatmentSummary := models.TreatmentSummary{
- UserOrgId: adminUserInfo.CurrentOrgId,
- PatientId: patient,
- AssessmentDate: recordDate.Unix(),
- Mission: mission,
- DialysisSummary: dialysis_summary,
- SjNurse: sj_nurse,
- ZlNurse: zl_nurse,
- HdNurse: hd_nurse,
- XjNurse: xj_nurse,
- ZlDoctor: zl_doctor,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- NursingRecord: nursingRecord,
- SpecialRecord: specialRecord,
- }
-
- _, tempTreatmentSummary := service.FindTreatmentSummaryByReordDate(patient, recordDate.Unix(), adminUserInfo.CurrentOrgId)
- if tempTreatmentSummary.ID == 0 { //新增
- treatmentSummary.Creater = adminUserInfo.AdminUser.Id
- err := service.AddSigleSummaryRecord(&treatmentSummary)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "summary": treatmentSummary,
- })
- } else {
-
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
-
- }
-
- } else { //修改
- //if tempTreatmentSummary.Creater != adminUserInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- //}
-
- treatmentSummary.Creater = tempTreatmentSummary.Creater
- treatmentSummary.CreatedTime = tempTreatmentSummary.CreatedTime
- treatmentSummary.UpdatedTime = time.Now().Unix()
- treatmentSummary.Modifier = adminUserInfo.AdminUser.Id
- treatmentSummary.ID = tempTreatmentSummary.ID
- err := service.UpdateSummeRecord(&treatmentSummary)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "summary": treatmentSummary,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
- }
-
- }
-
- }
-
- func (c *DialysisApiController) GetDeviceList() {
- adminUserInfo := c.GetAdminUserInfo()
- device, _ := service.FindAllDeviceInfo(adminUserInfo.CurrentOrgId)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "device": device,
- })
- }
-
- func (c *DialysisApiController) GetAllDeviceZone() {
- adminUserInfo := c.GetAdminUserInfo()
- err, zone := service.GetAllDeviceZone(adminUserInfo.CurrentOrgId)
- dics, _, err := service.GetDrugWayDics(adminUserInfo.CurrentOrgId)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "zone": zone,
- "dics": dics,
- })
- }
-
- }
-
- func (c *DialysisApiController) GetDialysisWatch() {
- page, _ := c.GetInt64("page", 1)
- limit, _ := c.GetInt64("limit", 10)
- schedulType, _ := c.GetInt64("schedul_type", 0)
- startTime, _ := c.GetInt64("schedul_time", 0)
- partitionType, _ := c.GetInt64("partition_type", 0)
- keywords := c.GetString("keywords")
-
- adminUserInfo := c.GetAdminUserInfo()
- if len(keywords) > 0 {
- dialysisSchedule, err, total := service.GetDialysisWatchByKeyword(adminUserInfo.CurrentOrgId, keywords, schedulType, partitionType, page, limit)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "schedule": dialysisSchedule,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- }
-
- } else {
- dialysisSchedule, err, total := service.GetDialysisWatch(adminUserInfo.CurrentOrgId, startTime/1000, schedulType, partitionType, page, limit)
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "schedule": dialysisSchedule,
- "total": total,
- })
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- }
- }
- }
-
- func (c *DialysisApiController) GetSchedualPatientsInfo() {
- patientId, _ := c.GetInt64("id", 0)
- record_date, _ := c.GetInt64("record_date", 0)
- adminUserInfo := c.GetAdminUserInfo()
- _, dialysisOrder := service.FindDialysisRecordById(adminUserInfo.CurrentOrgId, patientId, record_date)
- var dialysisStatus int64
- if dialysisOrder == nil { //没有透析记录
- dialysisStatus = 0 //未透析
- } else {
- dialysisStatus = dialysisOrder.Stage
- }
- //用户基本信息
- schedualPatientInfo, _ := service.FindPatientInfoById(adminUserInfo.CurrentOrgId, patientId, record_date)
-
- //接诊评估
- receiverTreatmentAccess, _ := service.FindReceiverTreatmentAccessRecordById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //透前评估
- PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //临时医嘱
- DoctorAdvice, _ := service.FindDoctorAdviceById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //双人核对
- DoubleCheck, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //透析监测
- Record, _ := service.FindAllMonitorRecord(adminUserInfo.CurrentOrgId, patientId, record_date)
-
- //透后评估
- AssessmentAfterDislysis, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patientId, record_date)
- //透析小结
- TreatmentSummary, _ := service.FindTreatmentSummaryById(adminUserInfo.CurrentOrgId, patientId, record_date)
-
- //透析处方
- dialysisPrescription, _ := service.FindPatientPrescribeById(adminUserInfo.CurrentOrgId, patientId, record_date)
- if dialysisPrescription.ID == 0 {
- solution, _ := service.FindDialysisSolution(adminUserInfo.CurrentOrgId, patientId)
- c.ServeSuccessJSON(map[string]interface{}{
- "patientInfo": schedualPatientInfo,
- "dialysisPrescription": solution,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "predialysisEvaluation": PredialysisEvaluation,
- "doctorAdvice": DoctorAdvice,
- "doubleCheck": DoubleCheck,
- "assessmentAfterDislysis": AssessmentAfterDislysis,
- "treatmentSummary": TreatmentSummary,
- "monitorRecord": Record,
- "dialysisStatus": dialysisStatus,
- "dialysisOrder": dialysisOrder,
- "isSolution": 1,
- })
- } else {
- c.ServeSuccessJSON(map[string]interface{}{
- "patientInfo": schedualPatientInfo,
- "dialysisPrescription": dialysisPrescription,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "predialysisEvaluation": PredialysisEvaluation,
- "doctorAdvice": DoctorAdvice,
- "doubleCheck": DoubleCheck,
- "assessmentAfterDislysis": AssessmentAfterDislysis,
- "treatmentSummary": TreatmentSummary,
- "monitorRecord": Record,
- "dialysisStatus": dialysisStatus,
- "dialysisOrder": dialysisOrder,
- "isSolution": 2,
- })
-
- }
-
- }
-
- func (c *DialysisApiController) CreateDoctorAdvice() {
- patient, _ := c.GetInt64("id", 0)
- dialysis_id, _ := c.GetInt64("dialysis_id", 0)
- record_date, _ := c.GetInt64("record_date", 0)
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- var advice models.DoctorAdvice
- code, subAdivice := adviceFormDatas(&advice, c.Ctx.Input.RequestBody, "create")
- if code > 0 {
- c.ServeFailJSONWithSGJErrorCode(code)
- return
- }
-
- if advice.ParentId > 0 {
- old, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, advice.ParentId)
- if old.ID == 0 || old.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
- return
- }
-
- if old.StopState == 1 || old.ExecutionState == 1 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdviceStoped)
- return
- }
-
- if old.ParentId > 0 {
- advice.ParentId = old.ParentId
- }
- advice.StartTime = old.StartTime
- advice.AdviceDoctor = old.AdviceDoctor
- advice.DeliveryWay = old.DeliveryWay
- advice.ExecutionFrequency = old.ExecutionFrequency
- }
- advice.RecordDate = record_date
- advice.DialysisOrderId = dialysis_id
- advice.Status = 1
- advice.CreatedTime = time.Now().Unix()
- advice.UpdatedTime = time.Now().Unix()
- advice.StopState = 2
- advice.ExecutionState = 2
- advice.AdviceType = 2
- advice.UserOrgId = adminUserInfo.CurrentOrgId
- advice.PatientId = patient
- advice.AdviceDoctor = adminUserInfo.AdminUser.Id
-
- err := service.CreateDoctorAdvice(&advice)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
- return
- }
-
- for _, subAdvice := range subAdivice {
- subAdvice.ParentId = advice.ID
- subAdvice.PatientId = patient
- subAdvice.RecordDate = record_date
- subAdvice.CreatedTime = time.Now().Unix()
- subAdvice.UpdatedTime = time.Now().Unix()
- subAdvice.UserOrgId = adminUserInfo.CurrentOrgId
-
- }
- service.CreateSubDoctorAdvice(subAdivice)
- _, subAdivices := service.FindAllSubDoctorAdvice(patient, advice.ID)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- "subAdvice": subAdivices,
- })
- return
-
- }
- func (c *DialysisApiController) EditDoctorAdvice() {
- patient, _ := c.GetInt64("patient", 0)
- id, _ := c.GetInt64("id", 0)
- parent_id, _ := c.GetInt64("parent_id", 0)
- execution_time := c.GetString("execution_time")
- // execution_staff, _ := c.GetInt64("execution_staff", 0)
- // checker, _ := c.GetInt64("checker", 0)
-
- if id <= 0 || patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminUserInfo := c.GetAdminUserInfo()
- advice, _ := service.FindDoctorAdvice(adminUserInfo.CurrentOrgId, id)
- if advice.ID == 0 || advice.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceNotExist)
- return
- }
- if len(execution_time) <= 0 {
- utils.ErrorLog("execution_time")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
-
- }
-
- execution_staff := adminUserInfo.AdminUser.Id
- checker := adminUserInfo.AdminUser.Id
-
- timeLayout2 := "2006-01-02 15:04"
- loc, _ := time.LoadLocation("Local")
-
- theTime, errs := time.ParseInLocation(timeLayout2, execution_time, loc)
- if errs != nil {
- utils.ErrorLog(errs.Error())
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
-
- return
- }
-
- advices := models.DoctorAdvice{
- ExecutionStaff: execution_staff,
- ExecutionTime: theTime.Unix(),
- Checker: checker,
- UpdatedTime: time.Now().Unix(),
- }
- var err error
- if parent_id > 0 {
- err = service.ExceDoctorAdviceById(&advices, parent_id, patient)
- } else {
- err = service.ExceDoctorAdviceById(&advices, id, patient)
- }
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateDoctorAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- })
- return
-
- }
- func (c *DialysisApiController) GetDoctorAdvice() {
- patient, _ := c.GetInt64("patient_id", 0)
- parent_id, _ := c.GetInt64("parent_id", 0)
- adviceId, _ := c.GetInt64("id", 0)
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- dminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(dminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
- var subAdvice []*models.DoctorAdvice
- var advice models.DoctorAdvice
-
- if parent_id > 0 {
- _, advice = service.FindAdivceById(dminUserInfo.CurrentOrgId, patient, parent_id)
- if advice.ID == 0 || advice.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
- return
- }
- subAdvice = service.FindSubAdivceById(patient, parent_id)
-
- } else {
- _, advice = service.FindAdivceById(dminUserInfo.CurrentOrgId, patient, adviceId)
- if advice.ID == 0 || advice.PatientId != patient {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParentAdviceNotExist)
- return
- }
- subAdvice = service.FindSubAdivceById(patient, adviceId)
-
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advice": advice,
- "subAdvice": subAdvice,
- })
- }
- func (this *DialysisApiController) DelMonitor() {
- recordID, _ := this.GetInt64("record_id")
- patientID, _ := this.GetInt64("patient_id")
- if recordID <= 0 || patientID <= 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adminInfo := this.GetAdminUserInfo()
- patient, getPatientErr := service.MobileGetPatientById(adminInfo.CurrentOrgId, patientID)
- if getPatientErr != nil {
- this.ErrorLog("获取患者信息失败:%v", getPatientErr)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- } else if patient == nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- monitor, getMonitorErr := service.GetMonitor(adminInfo.CurrentOrgId, patientID, recordID)
- if getMonitorErr != nil {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- return
- }
- //if monitor != nil {
- // if monitor.MonitoringNurse != adminInfo.AdminUser.Id {
- // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminInfo.CurrentOrgId, adminInfo.CurrentAppId, adminInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
- // if getPermissionErr != nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
- // return
- // } else if headNursePermission == nil {
- // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
- // return
- // }
- // }
- //}
-
- err := service.DisableMonitor(adminInfo.CurrentOrgId, patientID, recordID, adminInfo.AdminUser.Id)
- if err != nil {
- this.ErrorLog("删除透析监测记录失败:%v", err)
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "record_id": monitor.ID,
- })
-
- }
- func (c *DialysisApiController) CreateMonitor() {
- patient, _ := c.GetInt64("id", 0)
- dialysis_order_id, _ := c.GetInt64("dialysis_order_id", 0)
- monitoring_date, _ := c.GetInt64("monitoring_date", 0)
- operate_time, _ := c.GetInt64("operate_time", 0)
- // monitoring_time := c.GetString("monitoring_time")
- pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
- breathing_rated, _ := c.GetFloat("breathing_rated", 0)
- systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
- diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
- blood_pressure_type, _ := c.GetInt64("blood_pressure_type", 0)
- blood_flow_volume, _ := c.GetFloat("blood_flow_volume", 0)
- venous_pressure, _ := c.GetFloat("venous_pressure", 0)
- venous_pressure_type, _ := c.GetInt64("venous_pressure_type", 1)
- transmembrane_pressure, _ := c.GetFloat("transmembrane_pressure", 0)
- transmembrane_pressure_type, _ := c.GetInt64("transmembrane_pressure_type", 1)
- ultrafiltration_rate, _ := c.GetFloat("ultrafiltration_rate", 0)
- ultrafiltration_volume, _ := c.GetFloat("ultrafiltration_volume", 0)
- sodium_concentration, _ := c.GetFloat("sodium_concentration", 0)
- arterial_pressure, _ := c.GetFloat("arterial_pressure", 0)
- arterial_pressure_type, _ := c.GetInt64("arterial_pressure_type", 1)
- dialysate_temperature, _ := c.GetFloat("dialysate_temperature", 0)
- temperature, _ := c.GetFloat("temperature", 0)
- replacement_rate, _ := c.GetFloat("replacement_rate", 0)
- displacement_quantity, _ := c.GetFloat("displacement_quantity", 0)
- conductivity, _ := c.GetFloat("conductivity", 0)
-
- displacement_flow_quantity, _ := c.GetFloat("displacement_flow_quantity", 0)
-
- heparin, _ := c.GetFloat("heparin", 0)
- dialysate_flow, _ := c.GetFloat("dialysate_flow", 0)
-
- ktv, _ := c.GetFloat("ktv", 0)
- symptom := c.GetString("symptom")
- dispose := c.GetString("dispose")
- result := c.GetString("results")
-
- monitoring_nurse, _ := c.GetInt64("monitoring_nurse", 0)
-
- monitor_anticoagulant, _ := c.GetInt64("monitor_anticoagulant")
- monitor_anticoagulant_value := c.GetString("monitor_anticoagulant_value")
- monitoring_date = monitoring_date / 1000
- // operate_time = operate_time / 1000
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
- patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- if patientInfo.ID == 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- return
- }
-
- monitorRecord := models.MonitoringRecord{
- PatientId: patient,
- MonitoringDate: monitoring_date,
- DialysisOrderId: dialysis_order_id,
- OperateTime: operate_time,
- // MonitoringTime: monitoring_time,
- PulseFrequency: pulse_frequency,
- BreathingRate: breathing_rated,
- SystolicBloodPressure: systolic_blood_pressure,
- DiastolicBloodPressure: diastolic_blood_pressure,
- BloodPressureType: blood_pressure_type,
- BloodFlowVolume: blood_flow_volume,
- VenousPressure: venous_pressure,
- VenousPressureType: venous_pressure_type,
- TransmembranePressure: transmembrane_pressure,
- TransmembranePressureType: transmembrane_pressure_type,
- UltrafiltrationRate: ultrafiltration_rate,
- UltrafiltrationVolume: ultrafiltration_volume,
- SodiumConcentration: sodium_concentration,
- ArterialPressure: arterial_pressure,
- ArterialPressureType: arterial_pressure_type,
- DialysateTemperature: dialysate_temperature,
- Temperature: temperature,
- ReplacementRate: replacement_rate,
- DisplacementQuantity: displacement_quantity,
- Ktv: ktv,
- Symptom: symptom,
- Dispose: dispose,
- Result: result,
- MonitoringNurse: monitoring_nurse,
- Status: 1,
- CreatedTime: time.Now().Unix(),
- UpdatedTime: time.Now().Unix(),
- UserOrgId: adminUserInfo.CurrentOrgId,
- Conductivity: conductivity,
- DisplacementFlowQuantity: displacement_flow_quantity,
- Heparin: heparin,
- DialysateFlow: dialysate_flow,
- MonitorAnticoagulant: monitor_anticoagulant,
- MonitorAnticoagulantValue: monitor_anticoagulant_value,
- }
-
- err := service.CreateMonitor(&monitorRecord)
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "monitor": monitorRecord,
- })
- return
-
- }
-
- // 已弃用
- // func (c *DialysisApiController) CreateRecordData() {
- // patient, _ := c.GetInt64("id", 0)
- // status, _ := c.GetInt64("status", 0)
-
- // now := time.Now()
- // year, month, day := now.Date()
- // today_time := time.Date(year, month, day, 0, 0, 0, 0, time.Local)
- // todayTimeStamp := today_time.Unix()
-
- // if patient <= 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- // return
- // }
-
- // adminUserInfo := c.GetAdminUserInfo()
- // patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
- // if patientInfo.ID == 0 {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
- // return
- // }
-
- // record := &models.DialysisOrder{
- // DialysisDate: todayTimeStamp,
- // UserOrgId: adminUserInfo.CurrentOrgId,
- // PatientId: patient,
- // Stage: status,
- // Status: 1,
- // CreatedTime: time.Now().Unix(),
- // UpdatedTime: time.Now().Unix(),
- // }
-
- // if status == 1 {
- // //创建透析记录
- // err := service.CreateDialysisRecord(patient, adminUserInfo.CurrentOrgId, record)
- // if err == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "dialysisOrder": record,
- // })
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- // }
-
- // } else {
-
- // record_id, _ := c.GetInt64("record_id", 0)
- // //修改透析记录状态
- // errs := service.ModifyDialysisRecord(record_id)
- // //结束时候透析次数加1
- // service.UpdateSolutionByPatientId(patient)
-
- // if errs == nil {
- // c.ServeSuccessJSON(map[string]interface{}{
- // "dialysisOrder": record,
- // })
-
- // } else {
- // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
-
- // }
-
- // }
-
- // }
-
- func adviceFormDatas(advice *models.DoctorAdvice, data []byte, action string) (code int, subAdvice []*models.DoctorAdvice) {
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(data, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- timeLayout := "2006-01-02 "
- timeLayout2 := "2006-01-02 15:04"
-
- loc, _ := time.LoadLocation("Local")
-
- if action == "create" {
- if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
- utils.ErrorLog("advice_type")
- code = enums.ErrorCodeParamWrong
- return
- }
-
- adviceType := int64(dataBody["advice_type"].(float64))
- if adviceType != 1 && adviceType != 2 {
- utils.ErrorLog("advice_type != 1&&2")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceType = adviceType
-
- if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
- utils.ErrorLog("advice_date")
- code = enums.ErrorCodeParamWrong
- return
- }
- adviceDate, _ := dataBody["advice_date"].(string)
- if len(adviceDate) == 0 {
- utils.ErrorLog("len(adviceDate) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- theTime, err := time.ParseInLocation(timeLayout, adviceDate, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceDate = theTime.Unix()
-
- }
-
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- code = enums.ErrorCodeParamWrong
- return
- }
- startDate, _ := dataBody["start_time"].(string)
- if len(startDate) == 0 {
- utils.ErrorLog("len(startDate) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- theTime, err := time.ParseInLocation(timeLayout2, startDate, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.StartTime = theTime.Unix()
-
- if dataBody["advice_name"] == nil || reflect.TypeOf(dataBody["advice_name"]).String() != "string" {
- utils.ErrorLog("advice_name")
- code = enums.ErrorCodeParamWrong
- return
- }
- adviceName, _ := dataBody["advice_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.AdviceName = adviceName
-
- if dataBody["delivery_way"] == nil || reflect.TypeOf(dataBody["delivery_way"]).String() != "string" {
- utils.ErrorLog("delivery_way")
- code = enums.ErrorCodeParamWrong
- return
- }
- deliveryWay, _ := dataBody["delivery_way"].(string)
- if len(deliveryWay) == 0 {
- utils.ErrorLog("len(deliveryWay) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.DeliveryWay = deliveryWay
-
- if dataBody["execution_frequency"] == nil || reflect.TypeOf(dataBody["execution_frequency"]).String() != "string" {
- utils.ErrorLog("execution_frequency")
- code = enums.ErrorCodeParamWrong
- return
- }
- execution_frequency, _ := dataBody["execution_frequency"].(string)
- if len(execution_frequency) == 0 {
- utils.ErrorLog("len(execution_frequency) == 0")
- code = enums.ErrorCodeParamWrong
- return
- }
- advice.ExecutionFrequency = execution_frequency
-
- if dataBody["advice_desc"] != nil && reflect.TypeOf(dataBody["advice_desc"]).String() == "string" {
- adviceDsc, _ := dataBody["advice_desc"].(string)
- advice.AdviceDesc = adviceDsc
- }
-
- if dataBody["drug_spec_unit"] != nil && reflect.TypeOf(dataBody["drug_spec_unit"]).String() == "string" {
- drugSpecUnit, _ := dataBody["drug_spec_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
-
- if dataBody["single_dose"] != nil && reflect.TypeOf(dataBody["single_dose"]).String() == "string" {
- singleDose, _ := strconv.ParseFloat(dataBody["single_dose"].(string), 64)
- advice.SingleDose = singleDose
- }
-
- if dataBody["single_dose_unit"] != nil && reflect.TypeOf(dataBody["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := dataBody["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
-
- if dataBody["prescribing_number"] != nil && reflect.TypeOf(dataBody["prescribing_number"]).String() == "string" {
- prescribingNumber, _ := strconv.ParseFloat(dataBody["prescribing_number"].(string), 64)
- advice.PrescribingNumber = prescribingNumber
- }
-
- if dataBody["prescribing_number_unit"] != nil && reflect.TypeOf(dataBody["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := dataBody["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
-
- if dataBody["subAdviceForm"] != nil && reflect.TypeOf(dataBody["subAdviceForm"]).String() == "[]interface {}" {
- thisContagions, _ := dataBody["subAdviceForm"].([]interface{})
- if len(thisContagions) > 0 {
- for _, item := range thisContagions {
- items := item.(map[string]interface{})
- advice_name, _ := items["advice_name"].(string)
- advice_desc, _ := items["advice_desc"].(string)
- drug_spec_unit, _ := items["drug_spec_unit"].(string)
-
- prescribing_number_unit, _ := items["prescribing_number_unit"].(string)
- single_dose_unit, _ := items["single_dose_unit"].(string)
- prescribing_number, _ := strconv.ParseFloat(items["prescribing_number"].(string), 64)
- single_dose, _ := strconv.ParseFloat(items["single_dose"].(string), 64)
-
- advice := &models.DoctorAdvice{
- AdviceName: advice_name,
- AdviceDesc: advice_desc,
- SingleDose: single_dose,
- SingleDoseUnit: single_dose_unit,
- DrugSpecUnit: drug_spec_unit,
- PrescribingNumber: prescribing_number,
- PrescribingNumberUnit: prescribing_number_unit,
- }
- subAdvice = append(subAdvice, advice)
-
- }
- }
- }
-
- return
-
- }
-
- func (c *DialysisApiController) GetDialysisOrder() {
- xtno := c.GetString("xtno")
- xtdate := c.GetString("xtdate")
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", xtdate+" 00:00:00", loc)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- xttime := theTime.Unix()
-
- operatorIDs := make([]int64, 0)
-
- adminUserInfo := c.GetAdminUserInfo()
-
- adminUser, _ := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
-
- patientInfo, _ := service.FindPatientWithDeviceByNo(adminUserInfo.CurrentOrgId, xtno, xttime)
-
- //透析单
- dialysisOrder, _ := service.MobileGetSchedualDialysisRecord(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- if dialysisOrder != nil {
- if dialysisOrder.FinishNurse > 0 {
- operatorIDs = append(operatorIDs, dialysisOrder.FinishNurse)
- }
- if dialysisOrder.StartNurse > 0 {
- operatorIDs = append(operatorIDs, dialysisOrder.StartNurse)
- }
- }
-
- //透前评估
- PredialysisEvaluation, _ := service.FindPredialysisEvaluationById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- predialysName, err := service.FindPredialysisName(PredialysisEvaluation.BloodAccessPartOperaId, adminUserInfo.CurrentOrgId)
- //透后评估
- AssessmentAfterDislysis, _ := service.FindAssessmentAfterDislysisById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- if AssessmentAfterDislysis.Modifier > 0 {
- operatorIDs = append(operatorIDs, AssessmentAfterDislysis.Modifier)
- }
- //上次透前评估
- lastPredialysisEvaluation, _ := service.GetLastTimePredialysisEvaluation(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- lastOrder, _ := service.GetLastTimeOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- //透析处方
- dialysisPrescription, _ := service.FindPatientPrescribeWidyDevideById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- if dialysisPrescription.PrescriptionDoctor > 0 {
- operatorIDs = append(operatorIDs, dialysisPrescription.PrescriptionDoctor)
- }
-
- //获取病人的透析模式
- schedule, err := service.FindDialysisMode(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- order, err := service.FindDialysisMacher(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- nurse, err := service.FindPunctureNurse(order.PunctureNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
-
- startNuse, err := service.FindeStartNuse(order.StartNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
- FinishNuse, err := service.FindeStartNuse(order.FinishNurse, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
- //获取透析处方
- dialysisway, err := service.FindDialysisWay(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //获取临时医嘱
- doctorAdvice, _ := service.FindDoctorOrder(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //config, err := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
-
- //获取医嘱内容
- doctor, err := service.FindDoctor(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
- DoctorName, err := service.FindDoctorName(doctorAdvice.AdviceDoctor, adminUserInfo.CurrentAppId, adminUserInfo.CurrentOrgId)
-
- DoctorAdvice, _ := service.FindDoctorAdviceOrderById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- doctorAdevieInfo, err := service.FindDoctorAdviceByInfo(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //获取上次的透后体重
- // assessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- assessmentAfterDislysis, _ := service.MobileGetLast(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //获取透析次数
- _, total, err := service.GetTotalDialysisCout(adminUserInfo.CurrentOrgId, patientInfo.ID)
-
- if len(DoctorAdvice) > 0 {
- for _, item := range DoctorAdvice {
- if item.AdviceDoctor > 0 {
- operatorIDs = append(operatorIDs, item.AdviceDoctor)
- }
- if item.ExecutionStaff > 0 {
- operatorIDs = append(operatorIDs, item.ExecutionStaff)
- }
- if item.Checker > 0 {
- operatorIDs = append(operatorIDs, item.Checker)
- }
- }
- }
-
- //透析监测
- Record, _ := service.FindAllMonitorRecord(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //透析检测
- //monitor, err := service.FindAllMonitor(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //透析小结
- TreatmentSummary, _ := service.FindTreatmentSummaryById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- //接诊评估
- receiverTreatmentAccess, _ := service.FindReceiverTreatmentAccessRecordById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- check, _ := service.FindDoubleCheckById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- dialysis_count, _ := service.GetDialysisOrderCount(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- patientInfo.TotalDialysis = dialysis_count
-
- //相关操作对应的操作人
- //operators, _ := service.GetAdminUserES(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, operatorIDs)
- operators, err := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
- templateInfo, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
-
- //获取当前日期月份的第一天
- firstmonth := service.GetFirstDateOfMonth(theTime)
- firstMonthDate := firstmonth.Unix()
- //获取当前月份的病人透析次数
- dialysiscount, err := service.GetDialysisCountByPatientId(firstMonthDate, xttime, patientInfo.ID, adminUserInfo.CurrentOrgId)
-
- //获取his数据
- hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
-
- //hisAdvice, err := service.GetHisDoctorPatientById(adminUserInfo.Org.Id, patientInfo.ID, xttime)
- config, _ := service.GetHisDoctorConfig(adminUserInfo.CurrentOrgId)
-
- project_config, _ := service.GetHisProjectConfig(adminUserInfo.CurrentOrgId)
- projects, _ := service.FindAllHisProjectById(adminUserInfo.CurrentOrgId, patientInfo.ID, xttime)
- //if config.IsOpen == 1 && project_config.IsOpen == 1 && len(projects) > 0 {
- // for _, item := range projects {
- // var advice *models.HisDoctorAdviceInfo
- // advice.ID = item.ID
- // advice.Checker = item.Checker
- // advice.CheckTime = item.CheckTime
- // advice.CheckState = item.CheckState
- // advice.ExecutionState = item.ExecutionState
- // advice.ExecutionStaff = item.ExecutionStaff
- // advice.PrescribingNumber = float64(item.Count)
- // advice.PrescribingNumberUnit = item.Unit
- // advice.AdviceDoctor = item.Doctor
- // if item.Type == 3 {
- // advice.AdviceName = item.GoodInfo.GoodName
- // } else if item.Type == 2 {
- // advice.AdviceName = item.HisProject.ProjectName
- // }
- // advice.StartTime = item.StartTime
- // hisAdvice = append(hisAdvice, advice)
- // }
- //}
- if config.IsOpen == 1 {
- c.ServeSuccessJSON(map[string]interface{}{
- "xtdate": xtdate,
- "users": adminUser,
- "patientInfo": patientInfo,
- "PredialysisEvaluation": PredialysisEvaluation,
- "AssessmentAfterDislysis": AssessmentAfterDislysis,
- "dialysisPrescription": dialysisPrescription,
- "advices": hisAdvice,
- "monitors": Record,
- "summary": TreatmentSummary,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "dialysisOrder": dialysisOrder,
- "operators": operators,
- "org_template_info": templateInfo,
- "check": check,
- "schedule": schedule,
- "dialysisway": dialysisway,
- "order": order,
- "doctorAdvice": doctorAdvice,
- "doctor": doctor,
- "nurse": nurse,
- "doctorAdevieInfo": doctorAdevieInfo,
- "total": total,
- "startNuse": startNuse,
- "DoctorName": DoctorName,
- "assessmentAfterDislysis": assessmentAfterDislysis,
- "predialysName": predialysName,
- "FinishNuse": FinishNuse,
- "lastPredialysisEvaluation": lastPredialysisEvaluation,
- "dialysiscount": dialysiscount,
- "last_order": lastOrder,
- "project_config": project_config,
- "projects": projects,
- })
-
- }
- if config.IsOpen == 0 || config.IsOpen == 2 {
- c.ServeSuccessJSON(map[string]interface{}{
- "xtdate": xtdate,
- "users": adminUser,
- "patientInfo": patientInfo,
- "PredialysisEvaluation": PredialysisEvaluation,
- "AssessmentAfterDislysis": AssessmentAfterDislysis,
- "dialysisPrescription": dialysisPrescription,
- "advices": DoctorAdvice,
- "monitors": Record,
- "summary": TreatmentSummary,
- "receiverTreatmentAccess": receiverTreatmentAccess,
- "dialysisOrder": dialysisOrder,
- "operators": operators,
- "org_template_info": templateInfo,
- "check": check,
- "schedule": schedule,
- "dialysisway": dialysisway,
- "order": order,
- "doctorAdvice": doctorAdvice,
- "doctor": doctor,
- "nurse": nurse,
- "doctorAdevieInfo": doctorAdevieInfo,
- "total": total,
- "startNuse": startNuse,
- "DoctorName": DoctorName,
- "assessmentAfterDislysis": assessmentAfterDislysis,
- "predialysName": predialysName,
- "FinishNuse": FinishNuse,
- "lastPredialysisEvaluation": lastPredialysisEvaluation,
- "dialysiscount": dialysiscount,
- "last_order": lastOrder,
- "project_config": project_config,
- "projects": projects,
- })
-
- }
-
- }
-
- //
- func (c *DialysisApiController) GetLongAdvice() {
- patient_id, _ := c.GetInt64("patient_id")
- adminUserInfo := c.GetAdminUserInfo()
- _, config := service.FindDoctorAdviceRecordByOrgId(adminUserInfo.CurrentOrgId)
-
- //patient, _ := service.FindPatientIsOpenRemindById(patient_id, adminUserInfo.Org.Id)
- if config.IsOpenRemind == 0 { //针对老用户,即没开启推送功能,也没有 不开启推送功能,不做任何处理
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "1",
- })
- return
- } else { //开启推送提醒
- //开启推送提醒逻辑 提交长期处方的时候,弹起长期医嘱推送
- var advice_three []*models.DoctorAdvice
- //groupNo := service.GetMaxLongAdviceGroupID(adminUserInfo.Org.Id, patient_id)
- advices, err := service.GetLastLongAdviceByGroupNo(adminUserInfo.CurrentOrgId, patient_id)
- advices_two, err := service.GetLastLongAdviceByGroupNoThree(adminUserInfo.CurrentOrgId, patient_id)
-
- for _, advice := range advices {
- if advice.FrequencyType == 3 {
- t := time.Now()
- week := int(t.Weekday())
-
- switch week {
- case 1:
- if strings.Index(advice.WeekDay, "周一") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 2:
- if strings.Index(advice.WeekDay, "周二") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 3:
- if strings.Index(advice.WeekDay, "周三") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 4:
- if strings.Index(advice.WeekDay, "周四") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- case 5:
- if strings.Index(advice.WeekDay, "周五") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- case 6:
- if strings.Index(advice.WeekDay, "周六") == -1 {
- advice_three = append(advice_three, advice)
- }
-
- break
- case 0:
- if strings.Index(advice.WeekDay, "周日") == -1 {
- advice_three = append(advice_three, advice)
- }
- break
- }
- }
- }
-
- for _, advice := range advices_two {
- p, _ := time.Parse("2006-01-02", time.Now().Format("2006-01-02"))
- now := p.Unix()
- dayStr := strconv.FormatInt(advice.DayCount, 10)
- dayStr2 := "-" + dayStr
- count, _ := strconv.ParseInt(dayStr2, 10, 64)
- oldTime := time.Now().AddDate(0, 0, int(count)).Unix()
- advices, _ := service.FindAllDoctorAdviceByTime(now, oldTime, patient_id, adminUserInfo.CurrentOrgId, advice.TemplateId)
-
- for _, ad := range advices {
- advice_three = append(advice_three, ad)
- }
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "status": "2",
- "advices": advices,
- "advices_two": RemoveRepeatedElement(advice_three),
- "is_open_remind": config.IsOpenRemind,
- })
- }
- }
-
- }
-
- func RemoveRepeatedElement(arr []*models.DoctorAdvice) (newArr []*models.DoctorAdvice) {
- newArr = make([]*models.DoctorAdvice, 0)
- for i := 0; i < len(arr); i++ {
- repeat := false
- for j := i + 1; j < len(arr); j++ {
- if arr[i].ID == arr[j].ID {
- repeat = true
- break
- }
- }
- if !repeat {
- newArr = append(newArr, arr[i])
- }
- }
- return
- }
-
- func (c *DialysisApiController) CreateRemindDoctorAdvice() {
-
- patient, _ := c.GetInt64("id", 0)
- groupNo, _ := c.GetInt64("groupno", 0)
-
- if patient <= 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- adminUserInfo := c.GetAdminUserInfo()
-
- dataBody := make(map[string]interface{}, 0)
- err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
- if err != nil {
- utils.ErrorLog(err.Error())
- return
- }
- utils.ErrorLog("%v", dataBody)
-
- timeLayout := "2006-01-02 15:04"
- loc, _ := time.LoadLocation("Local")
-
- timeLayout2 := "2006-01-02"
- loc2, _ := time.LoadLocation("Local")
-
- if dataBody["advice_type"] == nil || reflect.TypeOf(dataBody["advice_type"]).String() != "float64" {
- utils.ErrorLog("advice_type")
- return
- }
- adviceType := int64(2)
-
- if dataBody["advice_date"] == nil || reflect.TypeOf(dataBody["advice_date"]).String() != "string" {
- utils.ErrorLog("advice_date")
- return
- }
- adviceDate, _ := dataBody["advice_date"].(string)
- theTime, err := time.ParseInLocation(timeLayout2, adviceDate, loc2)
- fmt.Println("the-----------------", theTime)
- AdviceDate := theTime.Unix()
- RecordDate := theTime.Unix()
-
- if dataBody["start_time"] == nil || reflect.TypeOf(dataBody["start_time"]).String() != "string" {
- utils.ErrorLog("start_time")
- return
- }
- startTime, _ := dataBody["start_time"].(string)
- if len(startTime) == 0 {
- utils.ErrorLog("len(start_time) == 0")
- return
- }
- theTimeUnix, err := time.ParseInLocation(timeLayout, startTime, loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- return
- }
- StartTime := theTimeUnix.Unix()
- fmt.Println("startTIME", StartTime)
- Remark := ""
- if dataBody["remark"] != nil && reflect.TypeOf(dataBody["remark"]).String() == "string" {
- remark, _ := dataBody["remark"].(string)
- Remark = remark
- }
-
- var advices []*models.GroupAdvice
- if dataBody["advices"] == nil || reflect.TypeOf(dataBody["advices"]).String() != "[]interface {}" {
- utils.ErrorLog("advices")
- return
- }
- adviceNames := dataBody["advices"].([]interface{})
- for _, adviceNameMap := range adviceNames {
- adviceNameM := adviceNameMap.(map[string]interface{})
- var advice models.GroupAdvice
- advice.Remark = Remark
- advice.AdviceType = adviceType
- advice.StartTime = StartTime
- advice.AdviceDate = AdviceDate
-
- advice.RecordDate = RecordDate
- advice.Status = 1
- advice.CreatedTime = time.Now().Unix()
- advice.UpdatedTime = time.Now().Unix()
- advice.StopState = 2
- advice.ExecutionState = 2
- advice.UserOrgId = adminUserInfo.CurrentOrgId
- advice.PatientId = patient
- advice.AdviceDoctor = adminUserInfo.AdminUser.Id
-
- if adviceNameM["advice_name"] == nil || reflect.TypeOf(adviceNameM["advice_name"]).String() != "string" {
- utils.ErrorLog("advice_name")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- adviceName, _ := adviceNameM["advice_name"].(string)
- if len(adviceName) == 0 {
- utils.ErrorLog("len(advice_name) == 0")
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- advice.AdviceName = adviceName
-
- if adviceNameM["drug_spec"] != nil && reflect.TypeOf(adviceNameM["drug_spec"]).String() == "string" {
- drugSpec, _ := strconv.ParseFloat(adviceNameM["drug_spec"].(string), 64)
- advice.DrugSpec = drugSpec
- }
-
- if adviceNameM["advice_desc"] != nil && reflect.TypeOf(adviceNameM["advice_desc"]).String() == "string" {
- adviceDesc, _ := adviceNameM["advice_desc"].(string)
- advice.AdviceDesc = adviceDesc
- }
-
- if adviceNameM["drug_spec_unit"] != nil && reflect.TypeOf(adviceNameM["drug_spec_unit"]).String() == "string" {
- drugSpecUnit, _ := adviceNameM["drug_spec_unit"].(string)
- advice.DrugSpecUnit = drugSpecUnit
- }
-
- //if adviceNameM["single_dose"] != nil && reflect.TypeOf(adviceNameM["single_dose"]).String() == "string" {
- // singleDose, _ := strconv.ParseFloat(adviceNameM["single_dose"].(string), 64)
- // advice.SingleDose = singleDose
- //}
-
- if adviceNameM["single_dose"] != nil || reflect.TypeOf(adviceNameM["single_dose"]).String() == "float64" {
- //single_dose := int64(adviceNameM["single_dose"].(float64))
- advice.SingleDose = adviceNameM["single_dose"].(float64)
- }
-
- if adviceNameM["single_dose_unit"] != nil && reflect.TypeOf(adviceNameM["single_dose_unit"]).String() == "string" {
- singleDoseUnit, _ := adviceNameM["single_dose_unit"].(string)
- advice.SingleDoseUnit = singleDoseUnit
- }
-
- //if adviceNameM["prescribing_number"] != nil && reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "string" {
- // prescribingNumber, _ := strconv.ParseFloat(adviceNameM["prescribing_number"].(string), 64)
- // advice.PrescribingNumber = prescribingNumber
- //}
-
- if adviceNameM["prescribing_number"] != nil || reflect.TypeOf(adviceNameM["prescribing_number"]).String() == "float64" {
-
- advice.PrescribingNumber = adviceNameM["prescribing_number"].(float64)
- }
-
- if adviceNameM["prescribing_number_unit"] != nil && reflect.TypeOf(adviceNameM["prescribing_number_unit"]).String() == "string" {
- prescribingNumberUnit, _ := adviceNameM["prescribing_number_unit"].(string)
- advice.PrescribingNumberUnit = prescribingNumberUnit
- }
- if adviceNameM["delivery_way"] != nil && reflect.TypeOf(adviceNameM["delivery_way"]).String() == "string" {
- deliveryWay, _ := adviceNameM["delivery_way"].(string)
- advice.DeliveryWay = deliveryWay
- }
-
- if adviceNameM["execution_frequency"] != nil && reflect.TypeOf(adviceNameM["execution_frequency"]).String() == "string" {
- executionFrequency, _ := adviceNameM["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
-
- if adviceNameM["frequency_type"] != nil || reflect.TypeOf(adviceNameM["frequency_type"]).String() == "float64" {
- frequency_type := int64(adviceNameM["frequency_type"].(float64))
- advice.FrequencyType = frequency_type
- }
-
- if adviceNameM["day_count"] != nil || reflect.TypeOf(adviceNameM["day_count"]).String() == "float64" {
- day_count := int64(adviceNameM["day_count"].(float64))
- advice.DayCount = day_count
- }
-
- if adviceNameM["way"] != nil || reflect.TypeOf(adviceNameM["way"]).String() == "float64" {
- way := int64(adviceNameM["way"].(float64))
- advice.Way = way
- }
-
- if adviceNameM["drug_id"] != nil || reflect.TypeOf(adviceNameM["drug_id"]).String() == "float64" {
- drug_id := int64(adviceNameM["drug_id"].(float64))
- advice.DrugId = drug_id
- }
-
- if adviceNameM["drug_name_id"] != nil || reflect.TypeOf(adviceNameM["drug_name_id"]).String() == "float64" {
- drug_name_id := int64(adviceNameM["drug_name_id"].(float64))
- advice.DrugNameId = drug_name_id
- }
-
- if adviceNameM["week_day"] != nil && reflect.TypeOf(adviceNameM["week_day"]).String() == "string" {
- week_day, _ := adviceNameM["week_day"].(string)
- advice.WeekDay = week_day
- }
-
- if adviceNameM["template_id"] != nil && reflect.TypeOf(adviceNameM["template_id"]).String() == "string" {
- template_id, _ := adviceNameM["template_id"].(string)
- advice.TemplateId = template_id
- }
-
- if adviceNameM["execution_frequency"] != nil && reflect.TypeOf(adviceNameM["execution_frequency"]).String() == "string" {
- executionFrequency, _ := adviceNameM["execution_frequency"].(string)
- advice.ExecutionFrequency = executionFrequency
- }
-
- if adviceNameM["child"] != nil && reflect.TypeOf(adviceNameM["child"]).String() == "[]interface {}" {
- children := adviceNameM["child"].([]interface{})
- if len(children) > 0 {
- for _, childrenMap := range children {
- childMap := childrenMap.(map[string]interface{})
- var child models.GroupAdvice
- child.Remark = Remark
- child.AdviceType = adviceType
- child.StartTime = StartTime
- child.AdviceDate = AdviceDate
- child.RecordDate = RecordDate
- child.Status = 1
- child.CreatedTime = time.Now().Unix()
- child.UpdatedTime = time.Now().Unix()
- child.StopState = 2
- child.ExecutionState = 2
- child.UserOrgId = adminUserInfo.CurrentOrgId
- child.PatientId = patient
- child.AdviceDoctor = adminUserInfo.AdminUser.Id
-
- if childMap["advice_name"] == nil || reflect.TypeOf(childMap["advice_name"]).String() != "string" {
- utils.ErrorLog("child advice_name")
- return
- }
- childAdviceName, _ := childMap["advice_name"].(string)
- if len(childAdviceName) == 0 {
- utils.ErrorLog("len(child advice_name) == 0")
- return
- }
- child.AdviceName = childAdviceName
-
- if childMap["advice_desc"] != nil && reflect.TypeOf(childMap["advice_desc"]).String() == "string" {
- childAdviceDesc, _ := childMap["advice_desc"].(string)
- child.AdviceDesc = childAdviceDesc
- }
-
- if childMap["drug_spec"] != nil && reflect.TypeOf(childMap["drug_spec"]).String() == "string" {
- childDrugSpec, _ := strconv.ParseFloat(childMap["drug_spec"].(string), 64)
- child.DrugSpec = childDrugSpec
- }
-
- if childMap["drug_spec_unit"] != nil && reflect.TypeOf(childMap["drug_spec_unit"]).String() == "string" {
- childDrugSpecUnit, _ := childMap["drug_spec_unit"].(string)
- child.DrugSpecUnit = childDrugSpecUnit
- }
-
- if childMap["single_dose"] != nil && reflect.TypeOf(childMap["single_dose"]).String() == "string" {
- childSingleDose, _ := strconv.ParseFloat(childMap["single_dose"].(string), 64)
- child.SingleDose = childSingleDose
- }
-
- if childMap["single_dose_unit"] != nil && reflect.TypeOf(childMap["single_dose_unit"]).String() == "string" {
- childSingleDoseUnit, _ := childMap["single_dose_unit"].(string)
- child.SingleDoseUnit = childSingleDoseUnit
- }
-
- if childMap["prescribing_number"] != nil && reflect.TypeOf(childMap["prescribing_number"]).String() == "string" {
- childPrescribingNumber, _ := strconv.ParseFloat(childMap["prescribing_number"].(string), 64)
- child.PrescribingNumber = childPrescribingNumber
- }
-
- if childMap["prescribing_number_unit"] != nil && reflect.TypeOf(childMap["prescribing_number_unit"]).String() == "string" {
- childPrescribingNumberUnit, _ := childMap["prescribing_number_unit"].(string)
- child.PrescribingNumberUnit = childPrescribingNumberUnit
- }
-
- child.DeliveryWay = advice.DeliveryWay
- child.ExecutionFrequency = advice.ExecutionFrequency
- advice.Children = append(advice.Children, &child)
- }
- }
- }
-
- advices = append(advices, &advice)
- }
-
- list, err := service.CreateMGroupAdvice(adminUserInfo.CurrentOrgId, advices, groupNo)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateDoctorAdviceFail)
- return
- }
-
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "ok",
- "advices": list,
- })
-
- return
-
- }
-
- func (c *DialysisApiController) GetSolution() {
- patient_id, _ := c.GetInt64("patient_id")
- mode_id, _ := c.GetInt64("mode_id")
- adminUserInfo := c.GetAdminUserInfo()
-
- solution, err := service.MobileGetDialysisSolutionByModeId(adminUserInfo.CurrentOrgId, patient_id, mode_id)
- prescription, err := service.MobileGetLastDialysisPrescribeByModeId(adminUserInfo.CurrentOrgId, patient_id, mode_id)
- system_prescription, err := service.MobileGetSystemDialysisPrescribeByModeId(adminUserInfo.CurrentOrgId, mode_id)
-
- if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "solution": solution,
- "prescription": prescription,
- "system_prescription": system_prescription,
- })
-
- }
-
- func (c *DialysisApiController) GetSchedule() {
- schedual_type, _ := c.GetInt64("schedual_type")
- adminUserInfo := c.GetAdminUserInfo()
-
- //timeLayout := "2006-01-02 15:04:05"
- //
- //date := time.Now().Format("2006-01-02") + " 00:00:00"
- //loc, _ := time.LoadLocation("Local")
- //theStartTime, _ := time.ParseInLocation(timeLayout, date, loc)
- //scheduleTime := theStartTime.Unix()
- scheduleTime, _ := c.GetInt64("record_date")
-
- deviceNumber, _ := service.GetAllDeviceNumbers(adminUserInfo.CurrentOrgId, scheduleTime, schedual_type)
-
- c.ServeSuccessJSON(map[string]interface{}{
- "number": deviceNumber,
- })
-
- }
-
- func (this *DialysisApiController) GetTodayMonitor() {
- thisTime := time.Now()
- scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
- timeLayout := "2006-01-02 15:04:05"
- loc, _ := time.LoadLocation("Local")
- theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
- theAssessmentDateTime := theStartTime.Unix()
-
- patientID, _ := this.GetInt64("patient_id")
- monitorDate, _ := this.GetInt64("monitoring_date", theAssessmentDateTime)
- adminInfo := this.GetAdminUserInfo()
- record, _ := service.FindLastMonitorRecordToday(patientID, adminInfo.CurrentOrgId, monitorDate)
- fristrecord, _ := service.FindFirstMonitorRecordToday(patientID, adminInfo.CurrentOrgId, monitorDate)
-
- template, _ := service.GetOrgInfoTemplate(adminInfo.CurrentOrgId)
-
- var ultrafiltration_rate float64
- _, prescription := service.FindDialysisPrescriptionByReordDate(patientID, theAssessmentDateTime, adminInfo.CurrentOrgId)
- //针对福建医师汇 获取透前评估预增脱水量
-
- _, evaluation := service.FindPredialysisEvaluationByReordDate(patientID, theAssessmentDateTime, adminInfo.CurrentOrgId)
- fmt.Println("透前评估数据", evaluation)
-
- if prescription.ID > 0 {
- if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
-
- totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
- if template.TemplateId == 6 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
- if template.TemplateId == 6 && adminInfo.CurrentOrgId == 10121 {
-
- dehydration, _ := strconv.ParseFloat(evaluation.Dehydration, 64)
- ultrafiltration_rate = math.Floor((prescription.TargetUltrafiltration + dehydration) / float64(totalMin) * 60 * 1000)
-
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- if template.TemplateId == 41 { //adminInfo.CurrentOrgId == 9538
- ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
- record.UltrafiltrationRate = ultrafiltration_rate
- }
-
- // 只针对方济医院
- if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
- value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
- ultrafiltration_rate = value
- record.UltrafiltrationRate = ultrafiltration_rate
- }
- }
- }
- // record.UltrafiltrationRate = ultrafiltration_rate
-
- record.UltrafiltrationVolume = 0
-
- if template.TemplateId == 1 && adminInfo.CurrentOrgId != 9849 {
- if ultrafiltration_rate > 0 {
- value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", float64(record.OperateTime+3600-fristrecord.OperateTime)/3600*ultrafiltration_rate), 6)
- record.UltrafiltrationVolume = value
- }
- }
-
- if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 || template.TemplateId == 34 || template.TemplateId == 41 {
- if ultrafiltration_rate > 0 && adminInfo.CurrentOrgId != 9538 {
- ultrafiltration_volume := math.Floor(float64(record.OperateTime+3600-fristrecord.OperateTime) / 3600 * ultrafiltration_rate)
-
- record.UltrafiltrationVolume = ultrafiltration_volume
- }
-
- }
-
- this.ServeSuccessJSON(map[string]interface{}{
- "monitor": record,
- })
-
- }
-
- func (c *DialysisApiController) UploadDryWeight() {
- patient_id, _ := c.GetInt64("id")
- dry_weight, _ := c.GetFloat("dry_weight")
- doctor_id, _ := c.GetInt64("doctor_id")
- remark := c.GetString("remark")
- adminUserInfo := c.GetAdminUserInfo()
- weightAdjust, err := service.FindLastDryWeightAdjust(adminUserInfo.CurrentOrgId, patient_id)
- fmt.Println(err)
- if err == gorm.ErrRecordNotFound {
- dryWeight := &models.SgjPatientDryweight{
- PatientId: patient_id,
- DryWeight: dry_weight,
- Remakes: remark,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Creator: doctor_id,
- Status: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- AdjustedValue: "/",
- UserId: adminUserInfo.AdminUser.Id,
- }
- createErr := service.CreatePatientWeightAdjust(dryWeight)
-
- if createErr == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "提交成功",
- "weight": dryWeight,
- })
- }
-
- } else {
- dryWeight := &models.SgjPatientDryweight{
- PatientId: patient_id,
- DryWeight: dry_weight,
- Remakes: remark,
- Ctime: time.Now().Unix(),
- Mtime: time.Now().Unix(),
- Creator: doctor_id,
- Status: 1,
- UserOrgId: adminUserInfo.CurrentOrgId,
- AdjustedValue: "/",
- UserId: adminUserInfo.AdminUser.Id,
- }
- var value float64
- value = dry_weight - weightAdjust.DryWeight
- fmt.Println(value)
-
- if value < 0 {
- dryWeight.AdjustedValue = strconv.FormatFloat(math.Abs(value), 'f', 1, 64) + "(下调)"
- } else if value == 0 {
- dryWeight.AdjustedValue = "/"
- } else if value > 0 {
- dryWeight.AdjustedValue = strconv.FormatFloat(value, 'f', 1, 64) + "(上调)"
- }
- fmt.Println(value)
-
- createErr := service.CreatePatientWeightAdjust(dryWeight)
- if createErr == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "msg": "提交成功",
- "weight": dryWeight,
- })
- }
- }
-
- }
-
- func (this *DialysisApiController) GetFuncPurview() {
- adminUserInfo := this.GetAdminUserInfo()
- user_id := adminUserInfo.AdminUser.Id
- app_id := adminUserInfo.CurrentAppId
- org_id := adminUserInfo.CurrentOrgId
- create_url := this.GetString("create_url")
- modify_url := this.GetString("modify_url")
- modify_other_url := this.GetString("modify_other_url")
- del_url := this.GetString("del_url")
- del_other_url := this.GetString("del_other_url")
- exce_url := this.GetString("exce_url")
- check_url := this.GetString("check_url")
- modify_exce_url := this.GetString("modify_exce_url")
- module, _ := this.GetInt64("module", 0)
-
- app_role, _ := service.GetAppRole(org_id, app_id, user_id)
- var is_has_create bool
- var is_has_modify bool
- var is_has_modify_other bool
- var is_has_del bool
- var is_has_del_other bool
- var is_has_exce bool
- var is_has_check bool
- var is_has_modify_exce bool
-
- org, _ := service.GetOrgById(adminUserInfo.CurrentOrgId)
-
- if adminUserInfo.AdminUser.Id != org.Creator {
-
- if app_role != nil {
- if len(app_role.RoleIds) > 0 {
- roles := strings.Split(app_role.RoleIds, ",")
- var userRolePurviews string
- for _, item := range roles {
- role_id, _ := strconv.ParseInt(item, 10, 64)
- purviews, _ := service.GetRoleFuncPurviewIds(role_id)
- if len(userRolePurviews) == 0 {
- userRolePurviews = purviews
- } else {
- userRolePurviews = userRolePurviews + "," + purviews
- }
- }
- userRolePurviewsArr := RemoveRepeatedPurviewElement2(strings.Split(userRolePurviews, ","))
- funcPurviews, _ := service.FindAllFuncPurview(userRolePurviewsArr)
- for _, item := range funcPurviews {
- //for _, url := range strings.Split(item.Urlfor,","){
- if strings.Split(item.Urlfor, ",")[1] == create_url {
- is_has_create = true
- }
- if strings.Split(item.Urlfor, ",")[1] == modify_url {
- is_has_modify = true
- }
- if strings.Split(item.Urlfor, ",")[1] == modify_other_url {
- is_has_modify_other = true
- }
- if strings.Split(item.Urlfor, ",")[1] == del_url {
- is_has_del = true
- }
- if strings.Split(item.Urlfor, ",")[1] == del_other_url {
- is_has_del_other = true
- }
- if strings.Split(item.Urlfor, ",")[1] == exce_url {
- is_has_exce = true
- }
- if strings.Split(item.Urlfor, ",")[1] == check_url {
- is_has_check = true
- }
- if strings.Split(item.Urlfor, ",")[1] == modify_exce_url {
- is_has_modify_exce = true
- }
-
- }
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRole)
- return
- }
- this.ServeSuccessJSON(map[string]interface{}{
- "is_has_create": is_has_create,
- "is_has_modify": is_has_modify,
- "is_has_modify_other": is_has_modify_other,
- "is_has_del": is_has_del,
- "is_has_del_other": is_has_del_other,
- "is_has_exce": is_has_exce,
- "is_has_check": is_has_check,
- "is_has_modify_exce": is_has_modify_exce,
- "module": module,
- })
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAdminUserIsExit)
- return
- }
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "is_has_create": true,
- "is_has_modify": true,
- "is_has_modify_other": true,
- "is_has_del": true,
- "is_has_del_other": true,
- "is_has_exce": true,
- "is_has_check": true,
- "is_has_modify_exce": true,
- "module": true,
- })
- }
- }
-
- func (this *DialysisApiController) GetLastOrNextDoctorAdvice() {
- change_type, _ := this.GetInt64("type", 0)
- record_date := this.GetString("record_time")
- patient_id, _ := this.GetInt64("patient_id", 0)
-
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- theAdviceRecordTime, _ := time.ParseInLocation(timeLayout, record_date, loc)
- record_time := theAdviceRecordTime.Unix()
- adminUserInfo := this.GetAdminUserInfo()
- advices, sch, err := service.GetDoctorAdviceByType(change_type, record_time, adminUserInfo.CurrentOrgId, patient_id)
- if err == nil {
- if len(advices) == 0 {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDoctorAdviceEmpty)
- return
- } else {
- this.ServeSuccessJSON(map[string]interface{}{
- "advices": advices,
- "schedule": sch,
- })
- return
- }
- } else {
- this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- }
-
- func (c *DialysisApiController) GetDialysisGoods() {
- schedualDate := c.GetString("schedule_date")
- schedule_type, _ := c.GetInt64("schedule_type")
- partition_id, _ := c.GetInt64("partition_id")
- page, _ := c.GetInt("page")
- limit, _ := c.GetInt("limit")
- keywords := c.GetString("keywords")
-
- patient_id, _ := c.GetInt64("patient_id")
-
- date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
- if parseDateErr != nil && len(schedualDate) != 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
-
- schedualEndDate := int64(0)
-
- endDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", schedualDate+" 23:59:59")
- if parseDateErr != nil && len(schedualDate) != 0 {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
- return
- }
- schedualEndDate = endDate.Unix()
-
- adminUser := c.GetAdminUserInfo()
-
- _, err := service.FindStockOutByIsSys(adminUser.CurrentOrgId, 1, date.Unix())
-
- goodTypes, _ := service.FindAllGoodType(adminUser.CurrentOrgId)
-
- if err == gorm.ErrRecordNotFound {
-
- dialysisGoods, _, total := service.PCGetDialysisGoods(adminUser.CurrentOrgId, date.Unix(), schedule_type, partition_id, page, limit, patient_id, keywords, schedualEndDate)
- for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
-
- goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.CurrentOrgId, date.Unix())
- lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.CurrentOrgId, date.Unix())
- item.LastAutomaticReduceDetail = goodUser
- item.LastDialysisBeforePrepare = lastGoodUserDetial
- }
- c.ServeSuccessJSON(map[string]interface{}{
- "dialysis_goods": dialysisGoods,
- "good_type": goodTypes,
- "total": total,
- })
- return
-
- } else if err == nil {
- //获取当天排班的每个患者的库存使用情况
- dialysisGoods, err, total := service.PCGetDialysisGoods(adminUser.CurrentOrgId, date.Unix(), schedule_type, partition_id, page, limit, patient_id, keywords, schedualEndDate)
- for _, item := range dialysisGoods { //获取当天排班的每个患者的最后日期的库存使用情况
- goodUser, _ := service.GetLastDialysisGoods(item.PatientId, adminUser.CurrentOrgId, date.Unix())
- lastGoodUserDetial, _ := service.GetLastDialysisBeforePrepare(item.PatientId, adminUser.CurrentOrgId, date.Unix())
-
- fmt.Println(goodUser)
- fmt.Println(lastGoodUserDetial)
-
- item.LastAutomaticReduceDetail = goodUser
- item.LastDialysisBeforePrepare = lastGoodUserDetial
- }
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "dialysis_goods": dialysisGoods,
- "good_type": goodTypes,
- "total": total,
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
- } else if err != nil {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
-
- }
-
- }
- func (c *DialysisApiController) GetDialysisGoodsStatistics() {
- start_time := c.GetString("start_time")
- end_time := c.GetString("end_time")
- timeLayout := "2006-01-02"
- loc, _ := time.LoadLocation("Local")
- var theStartTime int64
- if len(start_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theStartTime = theTime.Unix()
- }
- var theEndtTime int64
- if len(end_time) > 0 {
- theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
- if err != nil {
- utils.ErrorLog(err.Error())
- }
- theEndtTime = theTime.Unix()
- }
-
- adminUser := c.GetAdminUserInfo()
- outInfo, err := service.MobileGetGoodsStatistics(adminUser.CurrentOrgId, theStartTime, theEndtTime)
-
- if err == nil {
- c.ServeSuccessJSON(map[string]interface{}{
- "stock_out": outInfo,
- })
- return
-
- } else {
- c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
- return
- }
-
- }
|