check_weight_api_controller.go 70KB

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