check_weight_api_controller.go 69KB

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