check_weight_api_controller.go 69KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918
  1. package mobile_api_controllers
  2. import (
  3. "encoding/json"
  4. _ "encoding/json"
  5. "fmt"
  6. "net/http"
  7. "net/url"
  8. "strconv"
  9. _ "strings"
  10. "XT_New/enums"
  11. "XT_New/models"
  12. "XT_New/service"
  13. _ "XT_New/utils"
  14. "github.com/astaxie/beego"
  15. _ "github.com/astaxie/beego"
  16. "github.com/jinzhu/gorm"
  17. // "fmt"
  18. _ "reflect"
  19. "time"
  20. )
  21. type CheckWeightApiController struct {
  22. MobileBaseAPIAuthController
  23. }
  24. func (c *CheckWeightApiController) SaveBloodPressure() {
  25. id, _ := c.GetInt64("patient", 0)
  26. dialysistype, _ := c.GetInt64("dialysistype", 0)
  27. systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0) //收缩压
  28. diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0) //舒张压
  29. pulse_frequency, _ := c.GetFloat("pulse_frequency", 0) //脉率
  30. if id <= 0 {
  31. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32. return
  33. }
  34. if dialysistype <= 0 {
  35. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  36. return
  37. }
  38. if systolic_blood_pressure <= 0 {
  39. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  40. return
  41. }
  42. if diastolic_blood_pressure <= 0 {
  43. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  44. return
  45. }
  46. adminUserInfo := c.GetMobileAdminUserInfo()
  47. patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
  48. if patient.ID == 0 {
  49. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  50. return
  51. }
  52. thisTime := time.Now()
  53. scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
  54. timeLayout := "2006-01-02 15:04:05"
  55. loc, _ := time.LoadLocation("Local")
  56. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  57. theAssessmentDateTime := theStartTime.Unix()
  58. if dialysistype == 1 {
  59. theEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  60. if getPEErr != nil {
  61. c.ErrorLog("获取透前评估失败:%v", getPEErr)
  62. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  63. return
  64. }
  65. var evaluation models.PredialysisEvaluation
  66. if theEvaluation != nil {
  67. evaluation = *theEvaluation
  68. }
  69. // 如果今天没有透前评估,则插入新的数据
  70. if theEvaluation == nil {
  71. evaluation.CreatedTime = time.Now().Unix()
  72. evaluation.Status = 1
  73. evaluation.AssessmentDate = theAssessmentDateTime
  74. evaluation.PatientId = id
  75. evaluation.UserOrgId = adminUserInfo.Org.Id
  76. // 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
  77. lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  78. // 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
  79. assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  80. if getAADErr != nil {
  81. c.ErrorLog("获取透后评估失败:%v", getAADErr)
  82. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  83. return
  84. }
  85. // 获取干体重,先从干体重配置里去读,如果没有,则读取上一次透前评估的干体重
  86. weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
  87. if err == gorm.ErrRecordNotFound {
  88. if lastPredialysisEvaluation != nil {
  89. evaluation.DryWeight = lastPredialysisEvaluation.DryWeight
  90. evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
  91. evaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin
  92. evaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
  93. evaluation.Catheter = lastPredialysisEvaluation.Catheter
  94. evaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend
  95. evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
  96. evaluation.PunctureNeedleDirection = lastPredialysisEvaluation.PunctureNeedleDirection
  97. evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
  98. evaluation.PointPuncture = lastPredialysisEvaluation.PointPuncture
  99. evaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage
  100. evaluation.ThromubusType = lastPredialysisEvaluation.ThromubusType
  101. evaluation.Skin = lastPredialysisEvaluation.Skin
  102. evaluation.Complication = lastPredialysisEvaluation.Complication
  103. evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
  104. evaluation.LastPostDialysisOther = lastPredialysisEvaluation.LastPostDialysisOther
  105. } else {
  106. evaluation.DryWeight = 0
  107. }
  108. } else {
  109. evaluation.DryWeight = weight.DryWeight
  110. }
  111. if assessmentAfterDislysis != nil {
  112. evaluation.WeightAfterLastTransparency = assessmentAfterDislysis.WeightAfter
  113. }
  114. if lastPredialysisEvaluation != nil {
  115. evaluation.BloodAccessPartId = lastPredialysisEvaluation.BloodAccessPartId
  116. evaluation.BloodAccessPartOperaId = lastPredialysisEvaluation.BloodAccessPartOperaId
  117. evaluation.AdditionalWeight = lastPredialysisEvaluation.AdditionalWeight // 衣物重
  118. evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
  119. evaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin
  120. evaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
  121. evaluation.Catheter = lastPredialysisEvaluation.Catheter
  122. evaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend
  123. evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
  124. evaluation.PunctureNeedleDirection = lastPredialysisEvaluation.PunctureNeedleDirection
  125. evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
  126. evaluation.PointPuncture = lastPredialysisEvaluation.PointPuncture
  127. evaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage
  128. evaluation.ThromubusType = lastPredialysisEvaluation.ThromubusType
  129. evaluation.Skin = lastPredialysisEvaluation.Skin
  130. evaluation.Complication = lastPredialysisEvaluation.Complication
  131. evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
  132. evaluation.LastPostDialysisOther = lastPredialysisEvaluation.LastPostDialysisOther
  133. //从化益达 备注默认上一次数据
  134. if adminUserInfo.Org.Id == 10318 {
  135. evaluation.Remark = lastPredialysisEvaluation.Remark
  136. }
  137. }
  138. } else {
  139. evaluation.UpdatedTime = time.Now().Unix()
  140. }
  141. evaluation.SystolicBloodPressure = systolic_blood_pressure // 收缩压
  142. evaluation.DiastolicBloodPressure = diastolic_blood_pressure // 舒张压
  143. evaluation.PulseFrequency = pulse_frequency
  144. // 脉率
  145. evaluation.AssessmentTime = time.Now().Unix()
  146. err := service.UpadatePredialysisEvaluation(&evaluation)
  147. //记录日志
  148. byterequest, _ := json.Marshal(evaluation)
  149. assessmentBeforeDislysisLog := models.XtAssessmentBeforeDislysisLog{
  150. UserOrgId: adminUserInfo.Org.Id,
  151. AdminUserId: adminUserInfo.AdminUser.Id,
  152. ErrLog: string(byterequest),
  153. PatientId: evaluation.PatientId,
  154. RecordDate: evaluation.AssessmentDate,
  155. Ctime: time.Now().Unix(),
  156. Mtime: 0,
  157. Status: 1,
  158. Source: "物联网上传透前血压",
  159. }
  160. service.CreateBeforLog(assessmentBeforeDislysisLog)
  161. assessdateDateStart := thisTime.Format("2006-01-02")
  162. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
  163. redis := service.RedisClient()
  164. defer redis.Close()
  165. //清空key 值
  166. redis.Set(key, "", time.Second)
  167. keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_befores_list_all"
  168. redis.Set(keyOne, "", time.Second)
  169. keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  170. redis.Set(keyTwo, "", time.Second)
  171. redis.Close()
  172. if err != nil {
  173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
  174. return
  175. }
  176. c.ServeSuccessJSON(map[string]interface{}{
  177. "msg": "ok",
  178. "evaluation": evaluation,
  179. })
  180. return
  181. } else {
  182. // 保存透后相关数据
  183. assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  184. if getAADErr != nil {
  185. c.ErrorLog("获取透后评估失败:%v", getAADErr)
  186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  187. return
  188. }
  189. var afterevaluation models.AssessmentAfterDislysis
  190. if assessmentAfterDislysis != nil {
  191. afterevaluation = *assessmentAfterDislysis
  192. }
  193. if assessmentAfterDislysis == nil {
  194. afterevaluation.CreatedTime = time.Now().Unix()
  195. afterevaluation.Status = 1
  196. afterevaluation.AssessmentDate = theAssessmentDateTime
  197. afterevaluation.PatientId = id
  198. afterevaluation.UserOrgId = adminUserInfo.Org.Id
  199. } else {
  200. afterevaluation.UpdatedTime = time.Now().Unix()
  201. }
  202. afterevaluation.SystolicBloodPressure = systolic_blood_pressure // 收缩压
  203. afterevaluation.DiastolicBloodPressure = diastolic_blood_pressure // 舒张压
  204. afterevaluation.PulseFrequency = pulse_frequency // 脉率
  205. if adminUserInfo.Org.Id == 10138 {
  206. afterevaluation.LeaveOfficeMethod = assessmentAfterDislysis.LeaveOfficeMethod //离科方式
  207. afterevaluation.Lapse = assessmentAfterDislysis.Lapse //转归
  208. afterevaluation.Consciousness = assessmentAfterDislysis.Consciousness //意识
  209. afterevaluation.Fallrisk = assessmentAfterDislysis.Fallrisk //跌倒风险
  210. }
  211. err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
  212. //记录日志
  213. byterequest, _ := json.Marshal(afterevaluation)
  214. afterLog := models.XtAssessmentAfterDialysisLog{
  215. UserOrgId: adminUserInfo.Org.Id,
  216. AdminUserId: adminUserInfo.AdminUser.Id,
  217. ErrLog: string(byterequest),
  218. PatientId: afterevaluation.PatientId,
  219. RecordDate: afterevaluation.AssessmentDate,
  220. Ctime: time.Now().Unix(),
  221. Mtime: 0,
  222. Status: 1,
  223. Source: "物联网上传透后血压",
  224. }
  225. service.CreateAfterDialysisLog(afterLog)
  226. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis"
  227. redis := service.RedisClient()
  228. //清空key 值
  229. redis.Set(key, "", time.Second)
  230. keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis_list_all"
  231. redis.Set(keyThree, "", time.Second)
  232. assessdateDateStart := thisTime.Format("2006-01-02")
  233. keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  234. redis.Set(keyTwo, "", time.Second)
  235. defer redis.Close()
  236. if err == nil {
  237. c.ServeSuccessJSON(map[string]interface{}{
  238. "assessmentAfterDislysis": afterevaluation,
  239. })
  240. }
  241. }
  242. }
  243. func (c *CheckWeightApiController) SavePatientInfoDialysis() {
  244. id, _ := c.GetInt64("patient", 0)
  245. dialysistype, _ := c.GetInt64("dialysistype", 0)
  246. if id <= 0 {
  247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  248. return
  249. }
  250. if dialysistype <= 0 {
  251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  252. return
  253. }
  254. adminUserInfo := c.GetMobileAdminUserInfo()
  255. patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
  256. if patient.ID == 0 {
  257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  258. return
  259. }
  260. thisTime := time.Now()
  261. scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
  262. // scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
  263. timeLayout := "2006-01-02 15:04:05"
  264. loc, _ := time.LoadLocation("Local")
  265. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  266. // theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
  267. theAssessmentDateTime := theStartTime.Unix()
  268. // endTime := theEndTime.Unix()
  269. // dry_weight,_ := c.GetFloat("dry_weight",0) // 干体重
  270. weighing_before, _ := c.GetFloat("weighing_before", 0) // 透前体重
  271. dewater_amount, _ := c.GetFloat("dewater_amount", 0) // 目标脱水量(L)
  272. weight_after, _ := c.GetFloat("weight_after", 0) // 透后体重
  273. weight_loss, _ := c.GetFloat("weight_loss", 0) // 体重减少
  274. schedual, _ := service.MobileGetSchedualDetail(adminUserInfo.Org.Id, patient.ID, theStartTime.Unix())
  275. template, _ := service.GetOrgInfoTemplate(adminUserInfo.Org.Id)
  276. if template.TemplateId == 22 || template.TemplateId == 17 || template.TemplateId == 21 || template.TemplateId == 26 || template.TemplateId == 27 || template.TemplateId == 34 || template.TemplateId == 30 || template.TemplateId == 32 || template.TemplateId == 36 || template.TemplateId == 40 || template.TemplateId == 38 || template.TemplateId == 43 || template.TemplateId == 46 || template.TemplateId == 53 || template.TemplateId == 48 || adminUserInfo.Org.Id == 10345 || adminUserInfo.Org.Id == 10432 || adminUserInfo.Org.Id == 10441 || adminUserInfo.Org.Id == 10445 || adminUserInfo.Org.Id == 10138 || adminUserInfo.Org.Id == 10278 || adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10440 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10471 || adminUserInfo.Org.Id == 10537 || adminUserInfo.Org.Id == 10667 || adminUserInfo.Org.Id == 10723 {
  277. if adminUserInfo.Org.Id != 10447 {
  278. dewater_amount = dewater_amount * 1000
  279. }
  280. }
  281. if adminUserInfo.Org.Id == 10727 {
  282. dewater_amount = dewater_amount * 1000
  283. }
  284. if dewater_amount < 0 {
  285. dewater_amount = 0
  286. }
  287. if dialysistype == 1 {
  288. // 保存透前相关数据
  289. // 获取透析处方
  290. var lastDialysisPrescribe *models.DialysisPrescription
  291. var dialysisSolution *models.DialysisSolution
  292. var dialysisPrescribe *models.DialysisPrescription
  293. var system_dialysisPrescribe *models.SystemPrescription
  294. var mode_id int64
  295. //weightfirst, _ := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
  296. //if weightfirst.DryWeight > weighing_before {
  297. // return
  298. //}
  299. dialysisPrescribe, _ = service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  300. if schedual != nil {
  301. // 获取透析模版
  302. dialysisSolution, _ = service.MobileGetDialysisSolutionByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
  303. system_dialysisPrescribe, _ = service.MobileGetSystemDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, schedual.ModeId)
  304. lastDialysisPrescribe, _ = service.MobileGetLastDialysisPrescribeByModeIdSix(adminUserInfo.Org.Id, id, schedual.ModeId)
  305. //判断透析模式,针对河间咸的
  306. if adminUserInfo.Org.Id == 10090 {
  307. if dialysisSolution.ModeId != 2 && dialysisSolution.ModeId != 5 && dialysisSolution.ModeId != 12 {
  308. dialysisSolution.DisplaceLiquiPart = 0
  309. dialysisSolution.DisplaceLiquiValue = 0
  310. }
  311. if lastDialysisPrescribe.ModeId != 2 && lastDialysisPrescribe.ModeId != 5 && lastDialysisPrescribe.ModeId != 12 {
  312. dialysisSolution.DisplaceLiquiPart = 0
  313. dialysisSolution.DisplaceLiquiValue = 0
  314. }
  315. }
  316. mode_id = schedual.ModeId
  317. } else {
  318. // 获取透析模版
  319. dialysisSolution, _ = service.MobileGetDialysisSolution(adminUserInfo.Org.Id, id)
  320. if dialysisPrescribe == nil && dialysisSolution != nil {
  321. mode_id = dialysisSolution.ModeId
  322. }
  323. if dialysisPrescribe == nil && dialysisSolution == nil {
  324. mode_id = 0
  325. }
  326. }
  327. // 插入透析处方
  328. if dialysisPrescribe == nil && dialysisSolution != nil {
  329. var newprescribe models.DialysisPrescription
  330. newprescribe.UserOrgId = dialysisSolution.UserOrgId
  331. newprescribe.PatientId = dialysisSolution.PatientId
  332. newprescribe.Anticoagulant = dialysisSolution.Anticoagulant
  333. newprescribe.AnticoagulantShouji = dialysisSolution.AnticoagulantShouji
  334. newprescribe.AnticoagulantWeichi = dialysisSolution.AnticoagulantWeichi
  335. newprescribe.AnticoagulantZongliang = dialysisSolution.AnticoagulantZongliang
  336. newprescribe.AnticoagulantGaimingcheng = dialysisSolution.AnticoagulantGaimingcheng
  337. newprescribe.AnticoagulantGaijiliang = dialysisSolution.AnticoagulantGaijiliang
  338. newprescribe.ModeId = dialysisSolution.ModeId
  339. newprescribe.DialysisDuration = dialysisSolution.DialysisDuration
  340. newprescribe.ReplacementWay = dialysisSolution.ReplacementWay
  341. newprescribe.HemodialysisMachine = dialysisSolution.HemodialysisMachine
  342. newprescribe.BloodFilter = dialysisSolution.BloodFilter
  343. newprescribe.PerfusionApparatus = dialysisSolution.PerfusionApparatus
  344. newprescribe.BloodFlowVolume = dialysisSolution.BloodFlowVolume
  345. newprescribe.DisplaceLiqui = dialysisSolution.DisplaceLiqui
  346. newprescribe.Glucose = dialysisSolution.Glucose
  347. newprescribe.DialysateFlow = dialysisSolution.DialysateFlow
  348. newprescribe.Kalium = dialysisSolution.Kalium
  349. newprescribe.Sodium = dialysisSolution.Sodium
  350. newprescribe.Calcium = dialysisSolution.Calcium
  351. newprescribe.Bicarbonate = dialysisSolution.Bicarbonate
  352. newprescribe.DialysateTemperature = dialysisSolution.DialysateTemperature
  353. newprescribe.Conductivity = dialysisSolution.Conductivity
  354. newprescribe.BodyFluid = dialysisSolution.BodyFluid
  355. newprescribe.SpecialMedicine = dialysisSolution.SpecialMedicine
  356. newprescribe.SpecialMedicineOther = dialysisSolution.SpecialMedicineOther
  357. newprescribe.DisplaceLiquiPart = dialysisSolution.DisplaceLiquiPart
  358. newprescribe.DisplaceLiquiValue = dialysisSolution.DisplaceLiquiValue
  359. newprescribe.BloodAccess = dialysisSolution.BloodAccess
  360. newprescribe.Ultrafiltration = dialysisSolution.Ultrafiltration
  361. newprescribe.DialysisDurationHour = dialysisSolution.DialysisDurationHour
  362. newprescribe.DialysisDurationMinute = dialysisSolution.DialysisDurationMinute
  363. newprescribe.TargetUltrafiltration = dialysisSolution.TargetUltrafiltration
  364. newprescribe.DialysateFormulation = dialysisSolution.DialysateFormulation
  365. newprescribe.Dialyzer = dialysisSolution.Dialyzer
  366. newprescribe.ReplacementTotal = dialysisSolution.ReplacementTotal
  367. newprescribe.DialyzerPerfusionApparatus = dialysisSolution.DialyzerPerfusionApparatus
  368. newprescribe.DialysisIrrigation = dialysisSolution.DialysisIrrigation
  369. newprescribe.DialysisDialyszers = dialysisSolution.DialysisDialyszers
  370. newprescribe.DialysisStrainer = dialysisSolution.DialysisStrainer
  371. newprescribe.BodyFluidOther = dialysisSolution.BodyFluidOther
  372. newprescribe.TargetKtv = dialysisSolution.TargetKtv
  373. newprescribe.CreatedTime = time.Now().Unix()
  374. newprescribe.UpdatedTime = time.Now().Unix()
  375. newprescribe.RecordDate = theAssessmentDateTime
  376. newprescribe.DewaterAmount = dewater_amount
  377. newprescribe.TargetUltrafiltration = dewater_amount
  378. newprescribe.PrescriptionWater = dewater_amount
  379. newprescribe.Chaptalization = dialysisSolution.Chaptalization
  380. newprescribe.PrescribingNumber = 1
  381. newprescribe.BloodAccessPartId = dialysisSolution.BloodAccessPartId
  382. newprescribe.Status = 1
  383. if adminUserInfo.Org.Id != 10013 && adminUserInfo.Org.Id != 10014 && adminUserInfo.Org.Id != 10016 {
  384. newprescribe.Remark = dialysisSolution.Remark
  385. }
  386. if adminUserInfo.Org.Id == 10340 {
  387. newprescribe.TargetUltrafiltration = 0
  388. newprescribe.Sodium = 138
  389. newprescribe.Bicarbonate = 31.1
  390. newprescribe.DialysateFlow = 500
  391. newprescribe.TargetUltrafiltration = 0
  392. }
  393. // 针对新化博翔
  394. if adminUserInfo.Org.Id == 10447 {
  395. newprescribe.DisplaceLiquiPart = 1
  396. newprescribe.DisplaceLiquiValue = 32
  397. newprescribe.DialysateFlow = 500
  398. }
  399. if adminUserInfo.Org.Id == 10121 {
  400. newprescribe.DialysisDurationHour = 4
  401. newprescribe.DialysisDurationMinute = 0
  402. newprescribe.BloodAccess = dialysisSolution.BloodAccess
  403. }
  404. if adminUserInfo.Org.Id == 10445 {
  405. lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
  406. newprescribe.Remark = lastDialysisPrescription.Remark
  407. }
  408. //恒泰
  409. if adminUserInfo.Org.Id == 10490 || adminUserInfo.Org.Id == 10016 {
  410. newprescribe.Remark = ""
  411. }
  412. if adminUserInfo.Org.Id == 10599 {
  413. // 获取透析模版
  414. solutionone, _ := service.MobileGetDialysisSolutionByModeIdSevenTwety(adminUserInfo.Org.Id, id, schedual.ModeId)
  415. if solutionone.Anticoagulant > 0 {
  416. newprescribe.Anticoagulant = solutionone.Anticoagulant
  417. newprescribe.AnticoagulantShouji = solutionone.AnticoagulantShouji
  418. newprescribe.AnticoagulantWeichi = solutionone.AnticoagulantWeichi
  419. newprescribe.AnticoagulantZongliang = solutionone.AnticoagulantZongliang
  420. newprescribe.BloodAccess = solutionone.BloodAccess
  421. newprescribe.DialysisDurationHour = solutionone.DialysisDurationHour
  422. newprescribe.DialysisDurationMinute = solutionone.DialysisDurationMinute
  423. newprescribe.DialysisIrrigation = solutionone.DialysisIrrigation
  424. newprescribe.DialysisDialyszers = solutionone.DialysisDialyszers
  425. newprescribe.DialysisStrainer = solutionone.DialysisStrainer
  426. }
  427. }
  428. //针对普宁和揭阳
  429. if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10599 {
  430. prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
  431. if prescriptionTwenty.ID == 0 {
  432. //插入透析处方
  433. service.AddSigleRecord(&newprescribe)
  434. } else {
  435. //插入透析处方
  436. service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
  437. }
  438. } else {
  439. //插入透析处方
  440. service.AddSigleRecord(&newprescribe)
  441. }
  442. //记录日志
  443. byterequest, _ := json.Marshal(newprescribe)
  444. prescriptionLog := models.XtDialysisPrescriptionLog{
  445. UserOrgId: newprescribe.UserOrgId,
  446. Ctime: time.Now().Unix(),
  447. Mtime: 0,
  448. ErrLog: string(byterequest),
  449. AdminUserId: adminUserInfo.AdminUser.Id,
  450. RecordDate: newprescribe.RecordDate,
  451. PatientId: newprescribe.PatientId,
  452. Source: "物联网上传",
  453. Status: 1,
  454. }
  455. service.CreatePrescriptionLog(prescriptionLog)
  456. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
  457. redis := service.RedisClient()
  458. //清空key 值
  459. redis.Set(key, "", time.Second)
  460. keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
  461. redis.Set(keyTwo, "", time.Second)
  462. scheduleDateStartOne := thisTime.Format("2006-01-02")
  463. keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  464. redis.Set(keyThree, "", time.Second)
  465. defer redis.Close()
  466. }
  467. if dialysisPrescribe == nil && dialysisSolution == nil {
  468. if lastDialysisPrescribe != nil {
  469. var newprescribe models.DialysisPrescription
  470. newprescribe.UserOrgId = lastDialysisPrescribe.UserOrgId
  471. newprescribe.PatientId = lastDialysisPrescribe.PatientId
  472. newprescribe.Anticoagulant = lastDialysisPrescribe.Anticoagulant
  473. newprescribe.AnticoagulantShouji = lastDialysisPrescribe.AnticoagulantShouji
  474. newprescribe.AnticoagulantWeichi = lastDialysisPrescribe.AnticoagulantWeichi
  475. newprescribe.AnticoagulantZongliang = lastDialysisPrescribe.AnticoagulantZongliang
  476. newprescribe.AnticoagulantGaimingcheng = lastDialysisPrescribe.AnticoagulantGaimingcheng
  477. newprescribe.AnticoagulantGaijiliang = lastDialysisPrescribe.AnticoagulantGaijiliang
  478. newprescribe.ModeId = lastDialysisPrescribe.ModeId
  479. newprescribe.DialysisDuration = lastDialysisPrescribe.DialysisDuration
  480. newprescribe.ReplacementWay = lastDialysisPrescribe.ReplacementWay
  481. newprescribe.HemodialysisMachine = lastDialysisPrescribe.HemodialysisMachine
  482. newprescribe.BloodFilter = lastDialysisPrescribe.BloodFilter
  483. newprescribe.PerfusionApparatus = lastDialysisPrescribe.PerfusionApparatus
  484. newprescribe.BloodFlowVolume = lastDialysisPrescribe.BloodFlowVolume
  485. newprescribe.DisplaceLiqui = lastDialysisPrescribe.DisplaceLiqui
  486. newprescribe.Glucose = lastDialysisPrescribe.Glucose
  487. newprescribe.DialysateFlow = lastDialysisPrescribe.DialysateFlow
  488. newprescribe.Kalium = lastDialysisPrescribe.Kalium
  489. newprescribe.Sodium = lastDialysisPrescribe.Sodium
  490. newprescribe.Calcium = lastDialysisPrescribe.Calcium
  491. newprescribe.Bicarbonate = lastDialysisPrescribe.Bicarbonate
  492. newprescribe.DialysateTemperature = lastDialysisPrescribe.DialysateTemperature
  493. newprescribe.Conductivity = lastDialysisPrescribe.Conductivity
  494. newprescribe.BodyFluid = lastDialysisPrescribe.BodyFluid
  495. newprescribe.SpecialMedicine = lastDialysisPrescribe.SpecialMedicine
  496. newprescribe.SpecialMedicineOther = lastDialysisPrescribe.SpecialMedicineOther
  497. newprescribe.DisplaceLiquiPart = lastDialysisPrescribe.DisplaceLiquiPart
  498. newprescribe.DisplaceLiquiValue = lastDialysisPrescribe.DisplaceLiquiValue
  499. newprescribe.BloodAccess = lastDialysisPrescribe.BloodAccess
  500. newprescribe.Ultrafiltration = lastDialysisPrescribe.Ultrafiltration
  501. newprescribe.DialysisDurationHour = lastDialysisPrescribe.DialysisDurationHour
  502. newprescribe.DialysisDurationMinute = lastDialysisPrescribe.DialysisDurationMinute
  503. newprescribe.DialysateFormulation = lastDialysisPrescribe.DialysateFormulation
  504. newprescribe.Dialyzer = lastDialysisPrescribe.Dialyzer
  505. newprescribe.ReplacementTotal = lastDialysisPrescribe.ReplacementTotal
  506. newprescribe.DialyzerPerfusionApparatus = lastDialysisPrescribe.DialyzerPerfusionApparatus
  507. newprescribe.DialysisDialyszers = lastDialysisPrescribe.DialysisDialyszers
  508. newprescribe.DialysisIrrigation = lastDialysisPrescribe.DialysisIrrigation
  509. newprescribe.DialysisStrainer = lastDialysisPrescribe.DialysisStrainer
  510. newprescribe.BodyFluidOther = lastDialysisPrescribe.BodyFluidOther
  511. newprescribe.TargetKtv = lastDialysisPrescribe.TargetKtv
  512. newprescribe.BloodAccessPartId = lastDialysisPrescribe.BloodAccessPartId
  513. newprescribe.CreatedTime = time.Now().Unix()
  514. newprescribe.UpdatedTime = time.Now().Unix()
  515. newprescribe.RecordDate = theAssessmentDateTime
  516. newprescribe.DewaterAmount = dewater_amount
  517. newprescribe.TargetUltrafiltration = dewater_amount
  518. newprescribe.PrescriptionWater = dewater_amount
  519. newprescribe.Status = 1
  520. //if adminUserInfo.Org.Id != 10490 {
  521. // newprescribe.Remark = lastDialysisPrescribe.Remark
  522. //} else {
  523. // newprescribe.Remark = ""
  524. //}
  525. if adminUserInfo.Org.Id == 10490 || adminUserInfo.Org.Id == 10016 {
  526. newprescribe.Remark = ""
  527. }
  528. newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
  529. newprescribe.PrescribingNumber = 1
  530. if adminUserInfo.Org.Id == 10340 {
  531. newprescribe.TargetUltrafiltration = 0
  532. }
  533. if adminUserInfo.Org.Id == 10121 {
  534. newprescribe.DialysisDurationHour = 4
  535. newprescribe.DialysisDurationMinute = 0
  536. newprescribe.BloodAccess = dialysisSolution.BloodAccess
  537. }
  538. if adminUserInfo.Org.Id == 10445 {
  539. lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
  540. newprescribe.Remark = lastDialysisPrescription.Remark
  541. }
  542. //err := service.AddSigleRecord(&newprescribe)
  543. var err error
  544. if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10599 || adminUserInfo.Org.Id == 3877 {
  545. prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
  546. if prescriptionTwenty.ID == 0 {
  547. //插入透析处方
  548. service.AddSigleRecord(&newprescribe)
  549. } else {
  550. //插入透析处方
  551. service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
  552. }
  553. } else {
  554. //插入透析处方
  555. err = service.AddSigleRecord(&newprescribe)
  556. }
  557. //记录日志
  558. byterequest, _ := json.Marshal(newprescribe)
  559. prescriptionLog := models.XtDialysisPrescriptionLog{
  560. UserOrgId: adminUserInfo.Org.Id,
  561. Ctime: time.Now().Unix(),
  562. Mtime: 0,
  563. ErrLog: string(byterequest),
  564. AdminUserId: adminUserInfo.AdminUser.Id,
  565. RecordDate: newprescribe.RecordDate,
  566. PatientId: id,
  567. Source: "物联网上传",
  568. Status: 1,
  569. }
  570. service.CreatePrescriptionLog(prescriptionLog)
  571. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
  572. redis := service.RedisClient()
  573. //清空key 值
  574. redis.Set(key, "", time.Second)
  575. keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
  576. redis.Set(keyTwo, "", time.Second)
  577. scheduleDateStartOne := thisTime.Format("2006-01-02")
  578. keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  579. redis.Set(keyThree, "", time.Second)
  580. defer redis.Close()
  581. if err != nil {
  582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  583. }
  584. } else if system_dialysisPrescribe != nil {
  585. var newprescribe models.DialysisPrescription
  586. newprescribe.UserOrgId = system_dialysisPrescribe.UserOrgId
  587. newprescribe.PatientId = id
  588. newprescribe.Anticoagulant = system_dialysisPrescribe.Anticoagulant
  589. newprescribe.AnticoagulantShouji = system_dialysisPrescribe.AnticoagulantShouji
  590. newprescribe.AnticoagulantWeichi = system_dialysisPrescribe.AnticoagulantWeichi
  591. newprescribe.AnticoagulantZongliang = system_dialysisPrescribe.AnticoagulantZongliang
  592. newprescribe.AnticoagulantGaimingcheng = system_dialysisPrescribe.AnticoagulantGaimingcheng
  593. newprescribe.AnticoagulantGaijiliang = system_dialysisPrescribe.AnticoagulantGaijiliang
  594. newprescribe.ModeId = system_dialysisPrescribe.ModeId
  595. newprescribe.DialysisDuration = system_dialysisPrescribe.DialysisDuration
  596. newprescribe.ReplacementWay = system_dialysisPrescribe.ReplacementWay
  597. newprescribe.HemodialysisMachine = system_dialysisPrescribe.HemodialysisMachine
  598. newprescribe.BloodFilter = system_dialysisPrescribe.BloodFilter
  599. newprescribe.PerfusionApparatus = system_dialysisPrescribe.PerfusionApparatus
  600. newprescribe.BloodFlowVolume = system_dialysisPrescribe.BloodFlowVolume
  601. newprescribe.DisplaceLiqui = system_dialysisPrescribe.DisplaceLiqui
  602. newprescribe.Glucose = system_dialysisPrescribe.Glucose
  603. newprescribe.DialysateFlow = system_dialysisPrescribe.DialysateFlow
  604. newprescribe.Kalium = system_dialysisPrescribe.Kalium
  605. newprescribe.Sodium = system_dialysisPrescribe.Sodium
  606. newprescribe.Calcium = system_dialysisPrescribe.Calcium
  607. newprescribe.Bicarbonate = system_dialysisPrescribe.Bicarbonate
  608. newprescribe.DialysateTemperature = system_dialysisPrescribe.DialysateTemperature
  609. newprescribe.Conductivity = system_dialysisPrescribe.Conductivity
  610. newprescribe.BodyFluid = system_dialysisPrescribe.BodyFluid
  611. newprescribe.SpecialMedicine = system_dialysisPrescribe.SpecialMedicine
  612. newprescribe.SpecialMedicineOther = system_dialysisPrescribe.SpecialMedicineOther
  613. newprescribe.DisplaceLiquiPart = system_dialysisPrescribe.DisplaceLiquiPart
  614. newprescribe.DisplaceLiquiValue = system_dialysisPrescribe.DisplaceLiquiValue
  615. newprescribe.BloodAccess = system_dialysisPrescribe.BloodAccess
  616. newprescribe.Ultrafiltration = system_dialysisPrescribe.Ultrafiltration
  617. newprescribe.DialysisDurationHour = system_dialysisPrescribe.DialysisDurationHour
  618. newprescribe.DialysisDurationMinute = system_dialysisPrescribe.DialysisDurationMinute
  619. newprescribe.DialysateFormulation = system_dialysisPrescribe.DialysateFormulation
  620. newprescribe.Dialyzer = system_dialysisPrescribe.Dialyzer
  621. newprescribe.ReplacementTotal = system_dialysisPrescribe.ReplacementTotal
  622. newprescribe.DialyzerPerfusionApparatus = system_dialysisPrescribe.DialyzerPerfusionApparatus
  623. newprescribe.DialysisIrrigation = system_dialysisPrescribe.DialysisIrrigation
  624. newprescribe.DialysisDialyszers = system_dialysisPrescribe.DialysisDialyszers
  625. newprescribe.BodyFluidOther = system_dialysisPrescribe.BodyFluidOther
  626. newprescribe.TargetKtv = system_dialysisPrescribe.TargetKtv
  627. newprescribe.CreatedTime = time.Now().Unix()
  628. newprescribe.UpdatedTime = time.Now().Unix()
  629. newprescribe.RecordDate = theAssessmentDateTime
  630. newprescribe.DewaterAmount = dewater_amount
  631. newprescribe.TargetUltrafiltration = dewater_amount
  632. newprescribe.Chaptalization = lastDialysisPrescribe.Chaptalization
  633. newprescribe.BloodAccessPartId = lastDialysisPrescribe.BloodAccessPartId
  634. newprescribe.Status = 1
  635. newprescribe.PrescribingNumber = 1
  636. if adminUserInfo.Org.Id == 10340 {
  637. newprescribe.TargetUltrafiltration = 0
  638. }
  639. if adminUserInfo.Org.Id == 10121 {
  640. newprescribe.DialysisDurationHour = 4
  641. newprescribe.DialysisDurationMinute = 0
  642. newprescribe.BloodAccess = dialysisSolution.BloodAccess
  643. }
  644. if adminUserInfo.Org.Id == 10445 {
  645. lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
  646. newprescribe.Remark = lastDialysisPrescription.Remark
  647. }
  648. if adminUserInfo.Org.Id == 10597 || adminUserInfo.Org.Id == 10599 || adminUserInfo.Org.Id == 3877 {
  649. prescriptionTwenty, _ := service.GetLastDialysisPrescriptionTwenty(newprescribe.PatientId, newprescribe.RecordDate, newprescribe.UserOrgId)
  650. if prescriptionTwenty.ID == 0 {
  651. //插入透析处方
  652. service.AddSigleRecord(&newprescribe)
  653. } else {
  654. //插入透析处方
  655. service.UpdateAddSigleRecord(prescriptionTwenty.ID, newprescribe.TargetUltrafiltration)
  656. }
  657. } else {
  658. service.AddSigleRecord(&newprescribe)
  659. }
  660. //记录日志
  661. byterequest, _ := json.Marshal(newprescribe)
  662. prescriptionLog := models.XtDialysisPrescriptionLog{
  663. UserOrgId: adminUserInfo.Org.Id,
  664. Ctime: time.Now().Unix(),
  665. Mtime: 0,
  666. ErrLog: string(byterequest),
  667. AdminUserId: adminUserInfo.AdminUser.Id,
  668. RecordDate: newprescribe.RecordDate,
  669. PatientId: id,
  670. Source: "物联网上传",
  671. Status: 1,
  672. }
  673. service.CreatePrescriptionLog(prescriptionLog)
  674. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
  675. redis := service.RedisClient()
  676. //清空key 值
  677. redis.Set(key, "", time.Second)
  678. keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
  679. redis.Set(keyTwo, "", time.Second)
  680. scheduleDateStartOne := thisTime.Format("2006-01-02")
  681. keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  682. redis.Set(keyThree, "", time.Second)
  683. defer redis.Close()
  684. } else {
  685. var newprescribe models.DialysisPrescription
  686. newprescribe.UserOrgId = adminUserInfo.Org.Id
  687. newprescribe.PatientId = id
  688. newprescribe.ModeId = mode_id
  689. newprescribe.CreatedTime = time.Now().Unix()
  690. newprescribe.UpdatedTime = time.Now().Unix()
  691. newprescribe.RecordDate = theAssessmentDateTime
  692. newprescribe.DewaterAmount = dewater_amount
  693. newprescribe.TargetUltrafiltration = dewater_amount
  694. newprescribe.Status = 1
  695. if adminUserInfo.Org.Id == 10445 {
  696. lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
  697. newprescribe.Remark = lastDialysisPrescription.Remark
  698. }
  699. err := service.AddSigleRecord(&newprescribe)
  700. //记录日志
  701. byterequest, _ := json.Marshal(newprescribe)
  702. prescriptionLog := models.XtDialysisPrescriptionLog{
  703. UserOrgId: adminUserInfo.Org.Id,
  704. Ctime: time.Now().Unix(),
  705. Mtime: 0,
  706. ErrLog: string(byterequest),
  707. AdminUserId: adminUserInfo.AdminUser.Id,
  708. RecordDate: newprescribe.RecordDate,
  709. PatientId: id,
  710. Source: "物联网上传",
  711. Status: 1,
  712. }
  713. service.CreatePrescriptionLog(prescriptionLog)
  714. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
  715. redis := service.RedisClient()
  716. //清空key 值
  717. redis.Set(key, "", time.Second)
  718. keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
  719. redis.Set(keyTwo, "", time.Second)
  720. scheduleDateStartOne := thisTime.Format("2006-01-02")
  721. keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  722. redis.Set(keyThree, "", time.Second)
  723. defer redis.Close()
  724. if err != nil {
  725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  726. }
  727. }
  728. }
  729. if dialysisPrescribe != nil && dialysisPrescribe.TargetUltrafiltration == 0 {
  730. dialysisPrescribe.UpdatedTime = time.Now().Unix()
  731. dialysisPrescribe.RecordDate = theAssessmentDateTime
  732. dialysisPrescribe.DewaterAmount = dewater_amount
  733. dialysisPrescribe.TargetUltrafiltration = dewater_amount
  734. dialysisPrescribe.Status = 1
  735. if adminUserInfo.Org.Id == 10340 {
  736. dialysisPrescribe.TargetUltrafiltration = 0
  737. }
  738. if adminUserInfo.Org.Id == 10445 {
  739. lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
  740. dialysisPrescribe.Remark = lastDialysisPrescription.Remark
  741. }
  742. updateErr := service.UpDateDialysisPrescription(dialysisPrescribe)
  743. //记录日志
  744. byterequest, _ := json.Marshal(dialysisPrescribe)
  745. prescriptionLog := models.XtDialysisPrescriptionLog{
  746. UserOrgId: adminUserInfo.Org.Id,
  747. Ctime: time.Now().Unix(),
  748. Mtime: 0,
  749. ErrLog: string(byterequest),
  750. AdminUserId: adminUserInfo.AdminUser.Id,
  751. RecordDate: dialysisPrescribe.RecordDate,
  752. PatientId: id,
  753. Source: "物联网上传",
  754. Status: 1,
  755. }
  756. service.CreatePrescriptionLog(prescriptionLog)
  757. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":" + strconv.FormatInt(mode_id, 10) + ":dialysis_prescribe"
  758. redis := service.RedisClient()
  759. //清空key 值
  760. redis.Set(key, "", time.Second)
  761. keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":prescriptions_list_all"
  762. redis.Set(keyTwo, "", time.Second)
  763. scheduleDateStartOne := thisTime.Format("2006-01-02")
  764. keyThree := "scheduals_" + scheduleDateStartOne + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  765. redis.Set(keyThree, "", time.Second)
  766. defer redis.Close()
  767. if updateErr != nil {
  768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCommitFail)
  769. }
  770. }
  771. theEvaluation, getPEErr := service.MobileGetPredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  772. if getPEErr != nil {
  773. c.ErrorLog("获取透前评估失败:%v", getPEErr)
  774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  775. return
  776. }
  777. var evaluation models.PredialysisEvaluation
  778. if theEvaluation != nil {
  779. evaluation = *theEvaluation
  780. }
  781. // 如果今天没有透前评估,则插入新的数据
  782. if theEvaluation == nil {
  783. evaluation.CreatedTime = time.Now().Unix()
  784. evaluation.Status = 1
  785. evaluation.AssessmentDate = theAssessmentDateTime
  786. evaluation.PatientId = id
  787. evaluation.UserOrgId = adminUserInfo.Org.Id
  788. // 获取上一次透前评估信息,部分数据是需要从上一次透前评估继承
  789. lastPredialysisEvaluation, _ := service.MobileGetLastTimePredialysisEvaluationOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  790. // 获取上一次透后评估,插入本次透前评估的上次透后体重(weight_after_last_transparency)字段
  791. assessmentAfterDislysis, getAADErr := service.MobileGetLastTimeAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  792. if getAADErr != nil {
  793. c.ErrorLog("获取透后评估失败:%v", getAADErr)
  794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  795. return
  796. }
  797. // 获取干体重,先从干体重配置里去读,如果没有,则读取上一次透前评估的干体重
  798. weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
  799. if err == gorm.ErrRecordNotFound {
  800. if lastPredialysisEvaluation != nil {
  801. evaluation.DryWeight = lastPredialysisEvaluation.DryWeight
  802. } else {
  803. evaluation.DryWeight = 0
  804. }
  805. } else {
  806. evaluation.DryWeight = weight.DryWeight
  807. }
  808. if assessmentAfterDislysis != nil {
  809. evaluation.WeightAfterLastTransparency = assessmentAfterDislysis.WeightAfter
  810. }
  811. if lastPredialysisEvaluation != nil {
  812. evaluation.BloodAccessPartId = lastPredialysisEvaluation.BloodAccessPartId
  813. evaluation.BloodAccessPartOperaId = lastPredialysisEvaluation.BloodAccessPartOperaId
  814. evaluation.AdditionalWeight = lastPredialysisEvaluation.AdditionalWeight
  815. evaluation.Temperature = lastPredialysisEvaluation.Temperature
  816. evaluation.BreathingRate = lastPredialysisEvaluation.BreathingRate
  817. evaluation.Catheter = lastPredialysisEvaluation.Catheter
  818. evaluation.InternalFistula = lastPredialysisEvaluation.InternalFistula
  819. evaluation.PulseFrequency = lastPredialysisEvaluation.PulseFrequency
  820. evaluation.Complication = lastPredialysisEvaluation.Complication
  821. evaluation.LastPostDialysis = lastPredialysisEvaluation.LastPostDialysis
  822. evaluation.DialysisInterphase = lastPredialysisEvaluation.DialysisInterphase
  823. evaluation.SymptomBeforeDialysis = lastPredialysisEvaluation.SymptomBeforeDialysis
  824. evaluation.PunctureNeedle = lastPredialysisEvaluation.PunctureNeedle
  825. evaluation.PunctureWay = lastPredialysisEvaluation.PunctureWay
  826. evaluation.InternalFistulaSkin = lastPredialysisEvaluation.InternalFistulaSkin //血透通路皮肤情况
  827. evaluation.CatheterBend = lastPredialysisEvaluation.CatheterBend //导管打折
  828. evaluation.IsHemorrhage = lastPredialysisEvaluation.IsHemorrhage //出血
  829. evaluation.IsInfect = lastPredialysisEvaluation.IsInfect //感染
  830. evaluation.Exposed = lastPredialysisEvaluation.Exposed // 外漏
  831. evaluation.DialysisCount = lastPredialysisEvaluation.DialysisCount //呼吸频次
  832. evaluation.Phinholing = lastPredialysisEvaluation.Phinholing //针眼
  833. evaluation.Remark = lastPredialysisEvaluation.Remark
  834. if adminUserInfo.Org.Id == 10318 || adminUserInfo.Org.Id == 10490 || adminUserInfo.Org.Id == 10016 {
  835. evaluation.Remark = ""
  836. }
  837. if adminUserInfo.Org.Id == 10340 || adminUserInfo.Org.Id == 10447 {
  838. evaluation.BreathingRate = "20"
  839. }
  840. if adminUserInfo.Org.Id == 10445 {
  841. evaluation.VenousCatheterization = lastPredialysisEvaluation.VenousCatheterization
  842. }
  843. if adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10469 || adminUserInfo.Org.Id == 10471 {
  844. evaluation.PulseFrequency = 80
  845. }
  846. if adminUserInfo.Org.Id == 10440 {
  847. evaluation.Temperature = 36.5
  848. }
  849. if adminUserInfo.Org.Id == 10469 {
  850. evaluation.Temperature = 36.5
  851. }
  852. if adminUserInfo.Org.Id == 10471 {
  853. evaluation.Temperature = 36.5
  854. }
  855. }
  856. } else {
  857. evaluation.UpdatedTime = time.Now().Unix()
  858. }
  859. evaluation.WeightBefore = weighing_before
  860. evaluation.AssessmentTime = time.Now().Unix()
  861. if adminUserInfo.Org.Id == 10644 {
  862. evaluation.PunctureNeedle = ""
  863. }
  864. //针对患者称重两次没有数据的问题
  865. if adminUserInfo.Org.Id == 10702 || adminUserInfo.Org.Id == 10723 {
  866. dewater_amount = evaluation.WeightBefore - evaluation.DryWeight - evaluation.AdditionalWeight
  867. lastDialysisPrescription, _ := service.GetLastDialysisPrescription(id, adminUserInfo.Org.Id)
  868. service.UpdateMobileGetDialysisPrescribeOne(lastDialysisPrescription.ID, dewater_amount)
  869. }
  870. err := service.UpadatePredialysisEvaluation(&evaluation)
  871. //记录日志
  872. byterequest, _ := json.Marshal(evaluation)
  873. beforLog := models.XtAssessmentBeforeDislysisLog{
  874. UserOrgId: adminUserInfo.Org.Id,
  875. Ctime: time.Now().Unix(),
  876. Mtime: 0,
  877. ErrLog: string(byterequest),
  878. AdminUserId: adminUserInfo.AdminUser.Id,
  879. RecordDate: evaluation.AssessmentDate,
  880. PatientId: id,
  881. Source: "物联网上传",
  882. Status: 1,
  883. }
  884. service.CreateBeforLog(beforLog)
  885. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_before_dislysis"
  886. redis := service.RedisClient()
  887. //清空key 值
  888. redis.Set(key, "", time.Second)
  889. keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_befores_list_all"
  890. redis.Set(keyOne, "", time.Second)
  891. assessdateDateStart := thisTime.Format("2006-01-02")
  892. keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  893. redis.Set(keyTwo, "", time.Second)
  894. redis.Close()
  895. if err != nil {
  896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBUpdate)
  897. return
  898. }
  899. c.ServeSuccessJSON(map[string]interface{}{
  900. "msg": "ok",
  901. "evaluation": evaluation,
  902. })
  903. return
  904. } else {
  905. // 保存透后相关数据
  906. assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysisOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  907. if getAADErr != nil {
  908. c.ErrorLog("获取透后评估失败:%v", getAADErr)
  909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  910. return
  911. }
  912. var afterevaluation models.AssessmentAfterDislysis
  913. if assessmentAfterDislysis != nil {
  914. afterevaluation = *assessmentAfterDislysis
  915. }
  916. if assessmentAfterDislysis == nil {
  917. afterevaluation.CreatedTime = time.Now().Unix()
  918. afterevaluation.Status = 1
  919. afterevaluation.AssessmentDate = theAssessmentDateTime
  920. afterevaluation.PatientId = id
  921. afterevaluation.UserOrgId = adminUserInfo.Org.Id
  922. } else {
  923. afterevaluation.UpdatedTime = time.Now().Unix()
  924. }
  925. afterevaluation.WeightAfter = weight_after
  926. afterevaluation.WeightLoss = weight_loss
  927. if adminUserInfo.Org.Id == 10138 {
  928. afterevaluation.LeaveOfficeMethod = assessmentAfterDislysis.LeaveOfficeMethod //离科方式
  929. afterevaluation.Lapse = assessmentAfterDislysis.Lapse //转归
  930. afterevaluation.Consciousness = assessmentAfterDislysis.Consciousness //意识
  931. afterevaluation.Fallrisk = assessmentAfterDislysis.Fallrisk
  932. }
  933. if adminUserInfo.Org.Id == 10307 || adminUserInfo.Org.Id == 10445 {
  934. afterevaluation.ActualUltrafiltration = weight_loss * 1000 //中能建的计量单位是毫升(ml)
  935. }
  936. //北方营口
  937. if adminUserInfo.Org.Id == 10445 {
  938. prescribe, _ := service.MobileGetDialysisPrescribe(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  939. afterevaluation.ActualDisplacement = prescribe.DisplaceLiquiValue
  940. }
  941. //蓬安济民
  942. if adminUserInfo.Org.Id == 9829 || adminUserInfo.Org.Id == 10469 {
  943. afterevaluation.PulseFrequency = 80
  944. }
  945. if adminUserInfo.Org.Id == 10693 {
  946. afterevaluation.ActualUltrafiltration = assessmentAfterDislysis.ActualUltrafiltration
  947. afterevaluation.SystolicBloodPressure = assessmentAfterDislysis.SystolicBloodPressure
  948. afterevaluation.DiastolicBloodPressure = assessmentAfterDislysis.DiastolicBloodPressure
  949. afterevaluation.PulseFrequency = assessmentAfterDislysis.PulseFrequency
  950. if afterevaluation.ActualUltrafiltration == 0 {
  951. lastRecord, _ := service.GetLastMonitorRecordTwenty(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  952. UltrafiltrationVolumeOne, _ := strconv.ParseFloat(lastRecord.UltrafiltrationVolumeOne, 64)
  953. afterevaluation.ActualUltrafiltration = UltrafiltrationVolumeOne
  954. }
  955. if afterevaluation.SystolicBloodPressure == 0 {
  956. lastRecord, _ := service.GetLastMonitorRecordTwentyOne(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  957. systolicBloodPressureOne, _ := strconv.ParseFloat(lastRecord.MonitorSystolicBloodPressureOne, 64)
  958. afterevaluation.SystolicBloodPressure = systolicBloodPressureOne
  959. }
  960. if afterevaluation.DiastolicBloodPressure == 0 {
  961. lastRecord, _ := service.GetLastMonitorRecordTwentyTwo(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  962. MonitorDiastolicBloodPressureOne, _ := strconv.ParseFloat(lastRecord.MonitorDiastolicBloodPressureOne, 64)
  963. afterevaluation.DiastolicBloodPressure = MonitorDiastolicBloodPressureOne
  964. }
  965. if afterevaluation.PulseFrequency == 0 {
  966. lastRecord, _ := service.GetLastMonitorRecordTwentyThree(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  967. PulseFrequencyOne, _ := strconv.ParseFloat(lastRecord.PulseFrequencyOne, 64)
  968. afterevaluation.PulseFrequency = PulseFrequencyOne
  969. }
  970. if afterevaluation.ActualDisplacement == 0 {
  971. lastRecord, _ := service.GetLastMonitorRecordTwentyFour(adminUserInfo.Org.Id, id, theAssessmentDateTime)
  972. DisplacementQuantityOne, _ := strconv.ParseFloat(lastRecord.DisplacementQuantityOne, 64)
  973. afterevaluation.ActualDisplacement = DisplacementQuantityOne
  974. }
  975. }
  976. err := service.UpdateAssessmentAfterDislysisRecord(&afterevaluation)
  977. //记录日志
  978. byterequest, _ := json.Marshal(afterevaluation)
  979. afterDialysisLog := models.XtAssessmentAfterDialysisLog{
  980. UserOrgId: afterevaluation.UserOrgId,
  981. PatientId: afterevaluation.PatientId,
  982. RecordDate: afterevaluation.AssessmentDate,
  983. Status: 1,
  984. ErrLog: string(byterequest),
  985. AdminUserId: adminUserInfo.AdminUser.Id,
  986. Ctime: time.Now().Unix(),
  987. Mtime: 0,
  988. Source: "物联网称重",
  989. }
  990. service.CreateAfterDialysisLog(afterDialysisLog)
  991. key := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis"
  992. redis := service.RedisClient()
  993. //清空key 值
  994. redis.Set(key, "", time.Second)
  995. keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(theAssessmentDateTime, 10) + ":assessment_after_dislysis_list_all"
  996. redis.Set(keyThree, "", time.Second)
  997. assessdateDateStart := thisTime.Format("2006-01-02")
  998. keyTwo := "scheduals_" + assessdateDateStart + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  999. redis.Set(keyTwo, "", time.Second)
  1000. redis.Close()
  1001. if err == nil {
  1002. c.ServeSuccessJSON(map[string]interface{}{
  1003. "assessmentAfterDislysis": afterevaluation,
  1004. })
  1005. }
  1006. }
  1007. }
  1008. func (c *CheckWeightApiController) SetSyncTime() {
  1009. sn := c.GetString("sn")
  1010. if len(sn) > 0 {
  1011. redis := service.RedisClient()
  1012. defer redis.Close()
  1013. redis.Set(sn, 0, 0)
  1014. }
  1015. serviceTime := time.Now().Unix()
  1016. c.ServeSuccessJSON(map[string]interface{}{
  1017. "status": 1,
  1018. "servicetime": serviceTime,
  1019. })
  1020. }
  1021. func (c *CheckWeightApiController) GetPatientList() {
  1022. ftype, _ := c.GetInt64("type", 0)
  1023. sn := c.GetString("sn")
  1024. syncTime := int64(0)
  1025. redis := service.RedisClient()
  1026. defer redis.Close()
  1027. if len(sn) > 0 {
  1028. syncTimeStr, _ := redis.Get(sn).Result()
  1029. syncTime, _ = strconv.ParseInt(syncTimeStr, 10, 64)
  1030. }
  1031. if ftype == 1 {
  1032. timeNow := time.Now().Unix()
  1033. redis.Set(sn, timeNow, 0)
  1034. }
  1035. adminUserInfo := c.GetMobileAdminUserInfo()
  1036. patientList, total, error := service.GetPatientListByUpdateTime(adminUserInfo.Org.Id, int64(syncTime))
  1037. need_update := 0
  1038. if syncTime == 0 {
  1039. need_update = 1
  1040. }
  1041. if error != nil {
  1042. c.ErrorLog("获取病人列表失败:%v", error)
  1043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1044. return
  1045. }
  1046. serviceTime := time.Now().Unix()
  1047. c.ServeSuccessJSON(map[string]interface{}{
  1048. "need_update": need_update,
  1049. "patientlist": patientList,
  1050. "total": total,
  1051. "servicetime": serviceTime,
  1052. })
  1053. }
  1054. func (c *CheckWeightApiController) GetPatientListForSchedules() {
  1055. thisTime := time.Now()
  1056. scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
  1057. timeLayout := "2006-01-02 15:04:05"
  1058. loc, _ := time.LoadLocation("Local")
  1059. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  1060. syncTime := theStartTime.Unix()
  1061. adminUserInfo := c.GetMobileAdminUserInfo()
  1062. patientList, total, error := service.GetPatientListBySchedules(adminUserInfo.Org.Id, syncTime)
  1063. patientSchedule := make([]map[string]interface{}, 0)
  1064. for _, item := range patientList {
  1065. patientTemp := make(map[string]interface{})
  1066. patientTemp["patient_id"] = item.PatientId
  1067. patientTemp["patient_name"] = item.Patient.Name
  1068. patientTemp["schedule_type"] = item.ScheduleType
  1069. patientSchedule = append(patientSchedule, patientTemp)
  1070. }
  1071. if error != nil {
  1072. c.ErrorLog("获取病人列表失败:%v", error)
  1073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1074. return
  1075. }
  1076. serviceTime := time.Now().Unix()
  1077. c.ServeSuccessJSON(map[string]interface{}{
  1078. "patientlist": patientSchedule,
  1079. "total": total,
  1080. "servicetime": serviceTime,
  1081. })
  1082. }
  1083. func (c *CheckWeightApiController) GetPatientListForSchedulesFind() {
  1084. patient_name := c.GetString("patient_name") //脉率
  1085. thisTime := time.Now()
  1086. scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
  1087. timeLayout := "2006-01-02 15:04:05"
  1088. loc, _ := time.LoadLocation("Local")
  1089. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  1090. syncTime := theStartTime.Unix()
  1091. adminUserInfo := c.GetMobileAdminUserInfo()
  1092. if len(patient_name) == 0 {
  1093. patientList, total, error := service.GetPatientListBySchedules(adminUserInfo.Org.Id, syncTime)
  1094. patientSchedule := make([]map[string]interface{}, 0)
  1095. for _, item := range patientList {
  1096. patientTemp := make(map[string]interface{})
  1097. patientTemp["patient_id"] = item.PatientId
  1098. patientTemp["patient_name"] = item.Patient.Name
  1099. patientTemp["schedule_type"] = item.ScheduleType
  1100. patientSchedule = append(patientSchedule, patientTemp)
  1101. }
  1102. if error != nil {
  1103. c.ErrorLog("获取病人列表失败:%v", error)
  1104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1105. return
  1106. }
  1107. serviceTime := time.Now().Unix()
  1108. c.ServeSuccessJSON(map[string]interface{}{
  1109. "patientlist": patientSchedule,
  1110. "total": total,
  1111. "servicetime": serviceTime,
  1112. })
  1113. } else {
  1114. patientList, total, error := service.GetPatientListBySchedulesFind(adminUserInfo.Org.Id, syncTime, patient_name)
  1115. patientSchedule := make([]map[string]interface{}, 0)
  1116. for _, item := range patientList {
  1117. if item.Patient.ID > 0 {
  1118. patientTemp := make(map[string]interface{})
  1119. patientTemp["patient_id"] = item.PatientId
  1120. patientTemp["patient_name"] = item.Patient.Name
  1121. patientTemp["schedule_type"] = item.ScheduleType
  1122. patientSchedule = append(patientSchedule, patientTemp)
  1123. }
  1124. }
  1125. if error != nil {
  1126. c.ErrorLog("获取病人列表失败:%v", error)
  1127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1128. return
  1129. }
  1130. serviceTime := time.Now().Unix()
  1131. c.ServeSuccessJSON(map[string]interface{}{
  1132. "patientlist": patientSchedule,
  1133. "total": total,
  1134. "servicetime": serviceTime,
  1135. })
  1136. }
  1137. }
  1138. func (c *CheckWeightApiController) GetPatientListById() {
  1139. patientId, _ := c.GetInt64("patient_id", 0)
  1140. if patientId <= 0 {
  1141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1142. return
  1143. }
  1144. adminUserInfo := c.GetMobileAdminUserInfo()
  1145. patient, error := service.GetPatientListById(adminUserInfo.Org.Id, patientId)
  1146. if error != nil {
  1147. c.ErrorLog("获取病人详情失败:%v", error)
  1148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1149. return
  1150. }
  1151. c.ServeSuccessJSON(map[string]interface{}{
  1152. "patientinfo": patient,
  1153. })
  1154. }
  1155. func (c *CheckWeightApiController) GetPatientInfoDialysis() {
  1156. id, _ := c.GetInt64("patient", 0)
  1157. if id <= 0 {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1159. return
  1160. }
  1161. adminUserInfo := c.GetMobileAdminUserInfo()
  1162. patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
  1163. if patient.ID <= 0 {
  1164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1165. return
  1166. }
  1167. var dialysisinfo map[string]interface{}
  1168. dialysisinfo = make(map[string]interface{})
  1169. dialysisinfo["id"] = patient.ID
  1170. dialysisinfo["name"] = patient.Name
  1171. dialysisinfo["dialysis_no"] = patient.DialysisNo
  1172. thisTime := time.Now()
  1173. scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
  1174. scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
  1175. timeLayout := "2006-01-02 15:04:05"
  1176. loc, _ := time.LoadLocation("Local")
  1177. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  1178. theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
  1179. startTime := theStartTime.Unix()
  1180. endTime := theEndTime.Unix()
  1181. // 判断当前用户是透析前还是透析后
  1182. var dialysistype int
  1183. _, dialysisOrder := service.FindDialysisRecordById(adminUserInfo.Org.Id, id, startTime)
  1184. if dialysisOrder == nil {
  1185. dialysistype = 1
  1186. } else {
  1187. dialysistype = 2
  1188. }
  1189. // 获取当前或者下次排班信息
  1190. var sc map[string]interface{}
  1191. sc = make(map[string]interface{})
  1192. if dialysistype == 1 {
  1193. daySchedule, _ := service.GetPatientScheduleFormDay(adminUserInfo.Org.Id, startTime, endTime, id)
  1194. if len(daySchedule) <= 0 {
  1195. sc["code"] = 1
  1196. sc["msg"] = "抱歉,您今天没有排版!"
  1197. sc["mode"] = 0
  1198. sc["data"] = daySchedule
  1199. } else {
  1200. if daySchedule[0].Schedule.ID > 0 {
  1201. sc["code"] = 0
  1202. sc["msg"] = ""
  1203. var mode = "HD"
  1204. if daySchedule[0].Schedule.ModeId == 1 {
  1205. mode = "HD"
  1206. }
  1207. if daySchedule[0].Schedule.ModeId == 2 {
  1208. mode = "HDF"
  1209. }
  1210. if daySchedule[0].Schedule.ModeId == 3 {
  1211. mode = "HD+HP"
  1212. }
  1213. if daySchedule[0].Schedule.ModeId == 4 {
  1214. mode = "HP"
  1215. }
  1216. if daySchedule[0].Schedule.ModeId == 5 {
  1217. mode = "HF"
  1218. }
  1219. if daySchedule[0].Schedule.ModeId == 6 {
  1220. mode = "SCUF"
  1221. }
  1222. if daySchedule[0].Schedule.ModeId == 7 {
  1223. mode = "IUF"
  1224. }
  1225. if daySchedule[0].Schedule.ModeId == 8 {
  1226. mode = "HFHD"
  1227. }
  1228. if daySchedule[0].Schedule.ModeId == 9 {
  1229. mode = "HFHD+HP"
  1230. }
  1231. if daySchedule[0].Schedule.ModeId == 10 {
  1232. mode = "PHF"
  1233. }
  1234. if daySchedule[0].Schedule.ModeId == 11 {
  1235. mode = "HFR"
  1236. }
  1237. if daySchedule[0].Schedule.ModeId == 12 {
  1238. mode = "HDF+HP"
  1239. }
  1240. if daySchedule[0].Schedule.ModeId == 13 {
  1241. mode = "CRRT"
  1242. }
  1243. if daySchedule[0].Schedule.ModeId == 14 {
  1244. mode = "腹水回输"
  1245. }
  1246. if daySchedule[0].Schedule.ModeId == 19 {
  1247. mode = "IUF+HD"
  1248. }
  1249. if daySchedule[0].Schedule.ModeId == 20 {
  1250. mode = "UF"
  1251. }
  1252. if daySchedule[0].Schedule.ModeId == 21 {
  1253. mode = "HD+"
  1254. }
  1255. if daySchedule[0].Schedule.ModeId == 22 {
  1256. mode = "血浆胆红素吸附+HDF"
  1257. }
  1258. if daySchedule[0].Schedule.ModeId == 23 {
  1259. mode = "血浆胆红素吸附"
  1260. }
  1261. if daySchedule[0].Schedule.ModeId == 24 {
  1262. mode = "I-HDF"
  1263. }
  1264. if daySchedule[0].Schedule.ModeId == 25 {
  1265. mode = "HD高通"
  1266. }
  1267. if daySchedule[0].Schedule.ModeId == 26 {
  1268. mode = "CVVH"
  1269. }
  1270. if daySchedule[0].Schedule.ModeId == 27 {
  1271. mode = "CVVHD"
  1272. }
  1273. if daySchedule[0].Schedule.ModeId == 28 {
  1274. mode = "CVVHDF"
  1275. }
  1276. if daySchedule[0].Schedule.ModeId == 29 {
  1277. mode = "PE"
  1278. }
  1279. if daySchedule[0].Schedule.ModeId == 30 {
  1280. mode = "血浆胆红素吸附+HP"
  1281. }
  1282. if daySchedule[0].Schedule.ModeId == 31 {
  1283. mode = "HPD"
  1284. }
  1285. if daySchedule[0].Schedule.ModeId == 32 {
  1286. mode = "HDP"
  1287. }
  1288. if daySchedule[0].Schedule.ModeId == 33 {
  1289. mode = "HFD"
  1290. }
  1291. if daySchedule[0].Schedule.ModeId == 34 {
  1292. mode = "HDF100"
  1293. }
  1294. if daySchedule[0].Schedule.ModeId == 35 {
  1295. mode = "HDF600"
  1296. }
  1297. if daySchedule[0].Schedule.ModeId == 36 {
  1298. mode = "HDF800"
  1299. }
  1300. if daySchedule[0].Schedule.ModeId == 37 {
  1301. mode = "HDF1000"
  1302. }
  1303. sc["mode"] = mode
  1304. sc["data"] = daySchedule
  1305. } else {
  1306. sc["code"] = 1
  1307. sc["msg"] = "抱歉,您今天没有排版!"
  1308. sc["mode"] = "HD"
  1309. sc["data"] = daySchedule
  1310. }
  1311. }
  1312. // 排队叫号的签到
  1313. go func() {
  1314. ssoDomain := beego.AppConfig.String("call_domain")
  1315. api := ssoDomain + "/index/patientsign/" + strconv.FormatInt(adminUserInfo.Org.Id, 10) + "/" + strconv.FormatInt(id, 10)
  1316. values := make(url.Values)
  1317. http.PostForm(api, values)
  1318. }()
  1319. } else {
  1320. nextSchedule, _ := service.GetNextSchedule(adminUserInfo.Org.Id, endTime, id)
  1321. if len(nextSchedule) <= 0 {
  1322. sc["code"] = 1
  1323. sc["msg"] = "抱歉,您后续没有排版!"
  1324. sc["mode"] = "HD"
  1325. sc["data"] = nextSchedule
  1326. } else {
  1327. if nextSchedule[0].Schedule.ID > 0 {
  1328. sc["code"] = 0
  1329. sc["msg"] = ""
  1330. var mode = "HD"
  1331. if nextSchedule[0].Schedule.ModeId == 1 {
  1332. mode = "HD"
  1333. }
  1334. if nextSchedule[0].Schedule.ModeId == 2 {
  1335. mode = "HDF"
  1336. }
  1337. if nextSchedule[0].Schedule.ModeId == 3 {
  1338. mode = "HD+HP"
  1339. }
  1340. if nextSchedule[0].Schedule.ModeId == 4 {
  1341. mode = "HP"
  1342. }
  1343. if nextSchedule[0].Schedule.ModeId == 5 {
  1344. mode = "HF"
  1345. }
  1346. if nextSchedule[0].Schedule.ModeId == 6 {
  1347. mode = "SCUF"
  1348. }
  1349. if nextSchedule[0].Schedule.ModeId == 7 {
  1350. mode = "IUF"
  1351. }
  1352. if nextSchedule[0].Schedule.ModeId == 8 {
  1353. mode = "HFHD"
  1354. }
  1355. if nextSchedule[0].Schedule.ModeId == 9 {
  1356. mode = "HFHD+HP"
  1357. }
  1358. if nextSchedule[0].Schedule.ModeId == 10 {
  1359. mode = "PHF"
  1360. }
  1361. if nextSchedule[0].Schedule.ModeId == 11 {
  1362. mode = "HFR"
  1363. }
  1364. if nextSchedule[0].Schedule.ModeId == 12 {
  1365. mode = "HDF+HP"
  1366. }
  1367. if nextSchedule[0].Schedule.ModeId == 13 {
  1368. mode = "CRRT"
  1369. }
  1370. if nextSchedule[0].Schedule.ModeId == 14 {
  1371. mode = "腹水回输"
  1372. }
  1373. if nextSchedule[0].Schedule.ModeId == 19 {
  1374. mode = "IUF+HD"
  1375. }
  1376. if nextSchedule[0].Schedule.ModeId == 20 {
  1377. mode = "UF"
  1378. }
  1379. if nextSchedule[0].Schedule.ModeId == 21 {
  1380. mode = "HD+"
  1381. }
  1382. if nextSchedule[0].Schedule.ModeId == 22 {
  1383. mode = "血浆胆红素吸附+HDF"
  1384. }
  1385. if nextSchedule[0].Schedule.ModeId == 23 {
  1386. mode = "血浆胆红素吸附"
  1387. }
  1388. if nextSchedule[0].Schedule.ModeId == 24 {
  1389. mode = "I-HDF"
  1390. }
  1391. if nextSchedule[0].Schedule.ModeId == 25 {
  1392. mode = "HD高通"
  1393. }
  1394. if nextSchedule[0].Schedule.ModeId == 26 {
  1395. mode = "CVVH"
  1396. }
  1397. if nextSchedule[0].Schedule.ModeId == 27 {
  1398. mode = "CVVHD"
  1399. }
  1400. if nextSchedule[0].Schedule.ModeId == 28 {
  1401. mode = "CVVHDF"
  1402. }
  1403. if nextSchedule[0].Schedule.ModeId == 29 {
  1404. mode = "PE"
  1405. }
  1406. if nextSchedule[0].Schedule.ModeId == 30 {
  1407. mode = "血浆胆红素吸附+HP"
  1408. }
  1409. if nextSchedule[0].Schedule.ModeId == 31 {
  1410. mode = "HPD"
  1411. }
  1412. if nextSchedule[0].Schedule.ModeId == 32 {
  1413. mode = "HDP"
  1414. }
  1415. if nextSchedule[0].Schedule.ModeId == 33 {
  1416. mode = "HFD"
  1417. }
  1418. if nextSchedule[0].Schedule.ModeId == 34 {
  1419. mode = "HDF100"
  1420. }
  1421. if nextSchedule[0].Schedule.ModeId == 35 {
  1422. mode = "HDF600"
  1423. }
  1424. if nextSchedule[0].Schedule.ModeId == 36 {
  1425. mode = "HDF800"
  1426. }
  1427. if nextSchedule[0].Schedule.ModeId == 37 {
  1428. mode = "HDF1000"
  1429. }
  1430. sc["mode"] = mode
  1431. sc["data"] = nextSchedule
  1432. } else {
  1433. sc["code"] = 1
  1434. sc["msg"] = "抱歉,您后续没有排版!"
  1435. sc["mode"] = "HD"
  1436. sc["data"] = nextSchedule
  1437. }
  1438. }
  1439. }
  1440. //switch sc["mode"] {
  1441. //case 1:
  1442. // sc["mode"] = "HD"
  1443. // break
  1444. //case 2:
  1445. // sc["mode"] = "HDF"
  1446. // break
  1447. //case 3:
  1448. // sc["mode"] = "HD+HP"
  1449. // break
  1450. //case 4:
  1451. // sc["mode"] = "HP"
  1452. // break
  1453. //case 5:
  1454. // sc["mode"] = "HF"
  1455. // break
  1456. //case 6:
  1457. // sc["mode"] = "SCUF"
  1458. // break
  1459. //case 7:
  1460. // sc["mode"] = "IUF"
  1461. // break
  1462. //case 8:
  1463. // sc["mode"] = "HFHD"
  1464. // break
  1465. //case 9:
  1466. // sc["mode"] = "HFHD+HP"
  1467. // break
  1468. //case 10:
  1469. // sc["mode"] = "PHF"
  1470. // break
  1471. //case 11:
  1472. // sc["mode"] = "HFR"
  1473. // break
  1474. //case 12:
  1475. // sc["mode"] = "HDF+HP"
  1476. // break
  1477. //case 13:
  1478. // sc["mode"] = "CRRT"
  1479. // break
  1480. //case 14:
  1481. // sc["mode"] = "腹水回输"
  1482. // break
  1483. //case 15:
  1484. // sc["mode"] = "HD前置换"
  1485. // break
  1486. //case 16:
  1487. // sc["mode"] = "HD后置换"
  1488. // break
  1489. //case 17:
  1490. // sc["mode"] = "HDF前置换"
  1491. // break
  1492. //case 18:
  1493. // sc["mode"] = "HDF后置换"
  1494. // break
  1495. //default:
  1496. // sc["mode"] = "HD"
  1497. // break
  1498. //}
  1499. // 获取患者透前干体重或者获取患者透前体重
  1500. var dry_weight map[string]interface{}
  1501. dry_weight = make(map[string]interface{})
  1502. var after_dry_weight map[string]interface{}
  1503. after_dry_weight = make(map[string]interface{})
  1504. if dialysistype == 1 {
  1505. lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
  1506. weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
  1507. if err == gorm.ErrRecordNotFound {
  1508. if getLPEErr != nil {
  1509. dry_weight["code"] = 1
  1510. dry_weight["dry_weight"] = nil
  1511. } else {
  1512. if lastPredialysisEvaluation == nil {
  1513. dry_weight["code"] = 1
  1514. dry_weight["dry_weight"] = nil
  1515. } else {
  1516. // 传输的干体重实际为干体重加上衣服重
  1517. dry_weight["code"] = 0
  1518. dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight + lastPredialysisEvaluation.AdditionalWeight
  1519. }
  1520. }
  1521. } else {
  1522. if err != nil {
  1523. dry_weight["code"] = 1
  1524. dry_weight["dry_weight"] = nil
  1525. } else {
  1526. dry_weight["code"] = 0
  1527. if getLPEErr != nil {
  1528. dry_weight["code"] = 0
  1529. dry_weight["dry_weight"] = weight.DryWeight
  1530. } else {
  1531. if lastPredialysisEvaluation == nil {
  1532. dry_weight["code"] = 1
  1533. dry_weight["dry_weight"] = weight.DryWeight
  1534. } else {
  1535. // 传输的干体重实际为干体重加上衣服重
  1536. dry_weight["code"] = 0
  1537. dry_weight["dry_weight"] = weight.DryWeight + lastPredialysisEvaluation.AdditionalWeight
  1538. }
  1539. }
  1540. }
  1541. }
  1542. } else {
  1543. predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminUserInfo.Org.Id, id, startTime)
  1544. if getPEErr != nil {
  1545. dry_weight["code"] = 1
  1546. dry_weight["dry_weight"] = nil
  1547. } else {
  1548. if predialysisEvaluation == nil {
  1549. dry_weight["code"] = 1
  1550. dry_weight["dry_weight"] = nil
  1551. } else {
  1552. dry_weight["code"] = 0
  1553. dry_weight["dry_weight"] = predialysisEvaluation.WeightBefore
  1554. }
  1555. }
  1556. lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, endTime)
  1557. weight, err := service.FindLastDryWeightAdjust(adminUserInfo.Org.Id, id)
  1558. if err == gorm.ErrRecordNotFound {
  1559. if getLPEErr != nil {
  1560. after_dry_weight["code"] = 1
  1561. after_dry_weight["dry_weight"] = nil
  1562. } else {
  1563. if lastPredialysisEvaluation == nil {
  1564. after_dry_weight["code"] = 1
  1565. after_dry_weight["dry_weight"] = nil
  1566. } else {
  1567. // 传输的干体重实际为干体重加上衣服重
  1568. after_dry_weight["code"] = 0
  1569. after_dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight + lastPredialysisEvaluation.AdditionalWeight
  1570. }
  1571. }
  1572. } else {
  1573. if err != nil {
  1574. after_dry_weight["code"] = 1
  1575. after_dry_weight["dry_weight"] = nil
  1576. } else {
  1577. after_dry_weight["code"] = 0
  1578. if getLPEErr != nil {
  1579. after_dry_weight["code"] = 0
  1580. after_dry_weight["dry_weight"] = weight.DryWeight
  1581. } else {
  1582. if lastPredialysisEvaluation == nil {
  1583. after_dry_weight["code"] = 1
  1584. after_dry_weight["dry_weight"] = weight.DryWeight
  1585. } else {
  1586. // 传输的干体重实际为干体重加上衣服重
  1587. after_dry_weight["code"] = 0
  1588. after_dry_weight["dry_weight"] = weight.DryWeight + lastPredialysisEvaluation.AdditionalWeight
  1589. }
  1590. }
  1591. }
  1592. }
  1593. }
  1594. c.ServeSuccessJSON(map[string]interface{}{
  1595. "dialysistype": dialysistype,
  1596. "patient": dialysisinfo,
  1597. "schedule": sc,
  1598. "dryweight": dry_weight,
  1599. "after_dry_weight": after_dry_weight,
  1600. })
  1601. return
  1602. }
  1603. func (c *CheckWeightApiController) GetPatientInfoBeforeDialysis() {
  1604. id, _ := c.GetInt64("patient", 0)
  1605. if id <= 0 {
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1607. return
  1608. }
  1609. adminUserInfo := c.GetMobileAdminUserInfo()
  1610. patient, _ := service.FindPatientByIdWithDiseases(adminUserInfo.Org.Id, id)
  1611. if patient.ID == 0 {
  1612. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1613. return
  1614. }
  1615. var dialysisinfo map[string]interface{}
  1616. dialysisinfo = make(map[string]interface{})
  1617. dialysisinfo["id"] = patient.ID
  1618. dialysisinfo["name"] = patient.Name
  1619. dialysisinfo["dialysis_no"] = patient.DialysisNo
  1620. thisTime := time.Now()
  1621. scheduleDateStart := thisTime.Format("2006-01-02") + " 00:00:00"
  1622. scheduleDateEnd := thisTime.Format("2006-01-02") + " 23:59:59"
  1623. fmt.Println(scheduleDateStart, scheduleDateEnd)
  1624. timeLayout := "2006-01-02 15:04:05"
  1625. loc, _ := time.LoadLocation("Local")
  1626. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  1627. theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
  1628. fmt.Println(theStartTime, theEndTime)
  1629. startTime := theStartTime.Unix()
  1630. endTime := theEndTime.Unix()
  1631. var sc map[string]interface{}
  1632. sc = make(map[string]interface{})
  1633. //一天只有排班一次
  1634. daySchedule, _ := service.GetDaySchedule(adminUserInfo.Org.Id, startTime, endTime, id)
  1635. if daySchedule.ID > 0 {
  1636. switch daySchedule.ModeId {
  1637. case 1:
  1638. sc["mode"] = "HD"
  1639. case 2:
  1640. sc["mode"] = "HDF"
  1641. case 3:
  1642. sc["mode"] = "HD+HP"
  1643. case 4:
  1644. sc["mode"] = "HP"
  1645. case 5:
  1646. sc["mode"] = "HF"
  1647. case 6:
  1648. sc["mode"] = "SCUF"
  1649. case 7:
  1650. sc["mode"] = "IUF"
  1651. case 8:
  1652. sc["mode"] = "HFHD"
  1653. case 9:
  1654. sc["mode"] = "HFHD+HP"
  1655. case 10:
  1656. sc["mode"] = "PHF"
  1657. case 11:
  1658. sc["mode"] = "HFR"
  1659. case 12:
  1660. sc["mode"] = "HDF+HP"
  1661. case 13:
  1662. sc["mode"] = "CRRT"
  1663. case 14:
  1664. sc["mode"] = "腹水回输"
  1665. case 15:
  1666. sc["mode"] = "HD前置换"
  1667. case 16:
  1668. sc["mode"] = "HD后置换"
  1669. case 17:
  1670. sc["mode"] = "HDF前置换"
  1671. case 18:
  1672. sc["mode"] = "HDF后置换"
  1673. default:
  1674. sc["mode"] = "HD"
  1675. }
  1676. sc["code"] = 0
  1677. sc["msg"] = ""
  1678. sc["data"] = daySchedule
  1679. } else {
  1680. sc["code"] = 1
  1681. sc["msg"] = "抱歉,您今天没有排版!"
  1682. sc["mode"] = ""
  1683. sc["data"] = daySchedule
  1684. }
  1685. fmt.Println(sc)
  1686. type dryWeight struct {
  1687. code int
  1688. dry_weight float64
  1689. }
  1690. var dry_weight map[string]interface{}
  1691. dry_weight = make(map[string]interface{})
  1692. lastPredialysisEvaluation, getLPEErr := service.MobileGetLastTimePredialysisEvaluation(adminUserInfo.Org.Id, id, startTime)
  1693. if getLPEErr != nil {
  1694. dry_weight["code"] = 1
  1695. dry_weight["dry_weight"] = nil
  1696. } else {
  1697. if lastPredialysisEvaluation == nil {
  1698. dry_weight["code"] = 1
  1699. dry_weight["dry_weight"] = nil
  1700. } else {
  1701. dry_weight["code"] = 0
  1702. dry_weight["dry_weight"] = lastPredialysisEvaluation.DryWeight
  1703. }
  1704. }
  1705. c.ServeSuccessJSON(map[string]interface{}{
  1706. "patient": dialysisinfo,
  1707. "schedule": sc,
  1708. "dryweight": dry_weight,
  1709. })
  1710. return
  1711. }