check_weight_api_controller.go 69KB

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