dialysis_api_controller.go 225KB

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