dialysis_record_api_controller.go 53KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  1. package controllers
  2. import (
  3. "XT_New/models"
  4. "encoding/json"
  5. "github.com/jinzhu/gorm"
  6. "math"
  7. "strconv"
  8. "time"
  9. "XT_New/enums"
  10. "XT_New/service"
  11. "XT_New/utils"
  12. "fmt"
  13. "github.com/astaxie/beego"
  14. "net/http"
  15. "net/url"
  16. )
  17. func DialysisRecordAPIControllerRegistRouter() {
  18. beego.Router("/api/dialysis/initdata", &DialysisRecordAPIController{}, "get:RecordInitData")
  19. beego.Router("/api/dialysis/schedules", &DialysisRecordAPIController{}, "get:GetSchedules")
  20. beego.Router("/api/dislysis/schedule", &DialysisRecordAPIController{}, "get:DialysisSchedule")
  21. beego.Router("/api/dislysis/monitor/edit", &DialysisRecordAPIController{}, "post:EditMonitor")
  22. beego.Router("/api/dialysis/start_record", &DialysisRecordAPIController{}, "post:StartDialysis")
  23. beego.Router("/api/dialysis/finish", &DialysisRecordAPIController{}, "post:FinishDialysis")
  24. beego.Router("/api/start_dialysis/modify", &DialysisRecordAPIController{}, "post:ModifyStartDialysis")
  25. beego.Router("/api/finish_dialysis/modify", &DialysisRecordAPIController{}, "post:ModifyFinishDialysis")
  26. }
  27. type DialysisRecordAPIController struct {
  28. BaseAuthAPIController
  29. }
  30. // /api/dialysis/initdata [get]
  31. func (this *DialysisRecordAPIController) RecordInitData() {
  32. adminInfo := this.GetAdminUserInfo()
  33. orgID := adminInfo.CurrentOrgId
  34. now := time.Now()
  35. ymdDate, _ := utils.ParseTimeStringToTime("2006-01-02", now.Format("2006-01-02"))
  36. schedules, getSchedulesErr := service.GetDialysisScheduals(orgID, ymdDate.Unix())
  37. if getSchedulesErr != nil {
  38. this.ErrorLog("获取排班信息失败:%v", getSchedulesErr)
  39. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  40. return
  41. }
  42. zones, getZonesErr := service.GetAllValidDeviceZones(orgID)
  43. if getZonesErr != nil {
  44. this.ErrorLog("获取全部分区失败:%v", getZonesErr)
  45. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  46. return
  47. }
  48. this.ServeSuccessJSON(map[string]interface{}{
  49. "schedules": schedules,
  50. "zones": zones,
  51. })
  52. }
  53. // /api/dialysis/schedules [get]
  54. // @param date:string (yyyy-mm-dd)
  55. func (this *DialysisRecordAPIController) GetSchedules() {
  56. schedualDate := this.GetString("date")
  57. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  58. if parseDateErr != nil {
  59. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  60. return
  61. }
  62. adminInfo := this.GetAdminUserInfo()
  63. orgID := adminInfo.CurrentOrgId
  64. schedules, err := service.GetDialysisScheduals(orgID, date.Unix())
  65. if err != nil {
  66. this.ErrorLog("获取排班信息失败:%v", err)
  67. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  68. } else {
  69. this.ServeSuccessJSON(map[string]interface{}{
  70. "schedules": schedules,
  71. })
  72. }
  73. }
  74. // /api/dislysis/schedule [get]
  75. // @param patient_id:int
  76. // @param date:string (yyyy-MM-dd)
  77. func (this *DialysisRecordAPIController) DialysisSchedule() {
  78. patientID, _ := this.GetInt64("patient_id")
  79. recordDateStr := this.GetString("date")
  80. if patientID <= 0 {
  81. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  82. return
  83. }
  84. if len(recordDateStr) == 0 {
  85. recordDateStr = time.Now().Format("2006-01-02")
  86. }
  87. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  88. if parseDateErr != nil {
  89. this.ErrorLog("日期(%v)解析错误:%v", recordDateStr, parseDateErr)
  90. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  91. return
  92. }
  93. adminInfo := this.GetAdminUserInfo()
  94. patient, getPatientErr := service.MobileGetPatientDetail(adminInfo.CurrentOrgId, patientID)
  95. if getPatientErr != nil {
  96. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  97. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  98. return
  99. } else if patient == nil {
  100. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  101. return
  102. }
  103. schedual, getSchedualErr := service.MobileGetSchedualDetail(adminInfo.CurrentOrgId, patientID, date.Unix())
  104. if getSchedualErr != nil {
  105. this.ErrorLog("获取患者排班信息失败:%v", getSchedualErr)
  106. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  107. return
  108. }
  109. receiverTreatmentAccess, getRTARErr := service.MobileGetReceiverTreatmentAccessRecord(adminInfo.CurrentOrgId, patientID, date.Unix())
  110. if getRTARErr != nil {
  111. this.ErrorLog("获取接诊评估失败:%v", getRTARErr)
  112. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  113. return
  114. }
  115. predialysisEvaluation, getPEErr := service.MobileGetPredialysisEvaluation(adminInfo.CurrentOrgId, patientID, date.Unix())
  116. fmt.Println("predialysisEvaluatiotion", predialysisEvaluation)
  117. if getPEErr != nil {
  118. this.ErrorLog("获取透前评估失败:%v", getPEErr)
  119. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  120. return
  121. }
  122. doctorAdvices, getDoctorAdvicesErr := service.MobileGetDoctorAdvices(adminInfo.CurrentOrgId, patientID, date.Unix())
  123. if getDoctorAdvicesErr != nil {
  124. this.ErrorLog("获取临时医嘱失败:%v", getDoctorAdvicesErr)
  125. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  126. return
  127. }
  128. dialysisOrder, getDialysisOrderErr := service.MobileGetSchedualDialysisRecord(adminInfo.CurrentOrgId, patientID, date.Unix())
  129. if getDialysisOrderErr != nil {
  130. this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
  131. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  132. return
  133. }
  134. doubleCheck, getDoubleCheckErr := service.MobileGetDoubleCheck(adminInfo.CurrentOrgId, patientID, date.Unix())
  135. if getDoubleCheckErr != nil {
  136. this.ErrorLog("获取双人核对记录失败:%v", getDoubleCheckErr)
  137. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  138. return
  139. }
  140. monitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecords(adminInfo.CurrentOrgId, patientID, date.Unix())
  141. if getMonitorRecordsErr != nil {
  142. this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
  143. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  144. return
  145. }
  146. assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminInfo.CurrentOrgId, patientID, date.Unix())
  147. if getAADErr != nil {
  148. this.ErrorLog("获取透后评估失败:%v", getAADErr)
  149. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  150. return
  151. }
  152. treatmentSummary, getTreatmentSummaryErr := service.MobileGetTreatmentSummary(adminInfo.CurrentOrgId, patientID, date.Unix())
  153. if getTreatmentSummaryErr != nil {
  154. this.ErrorLog("获取治疗小结失败:%v", getTreatmentSummaryErr)
  155. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  156. return
  157. }
  158. admins, getAdminsErr := service.GetAllAdminUsers(adminInfo.CurrentOrgId, adminInfo.CurrentAppId)
  159. if getAdminsErr != nil {
  160. this.ErrorLog("获取医护列表失败:%v", getAdminsErr)
  161. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  162. return
  163. }
  164. devices, getDevicesErr := service.GetValidDevicesBy(adminInfo.CurrentOrgId, 0, 0)
  165. if getDevicesErr != nil {
  166. this.ErrorLog("获取设备列表失败:%v", getDevicesErr)
  167. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  168. return
  169. }
  170. deviceNumbers, getDeviceNumbersErr := service.GetAllValidDeviceNumbers(adminInfo.CurrentOrgId)
  171. if getDeviceNumbersErr != nil {
  172. this.ErrorLog("获取床位号列表失败:%v", getDeviceNumbersErr)
  173. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  174. return
  175. }
  176. lastPredialysisEvaluation, getLPEErr := service.GetLastTimePredialysisEvaluation(adminInfo.CurrentOrgId, patientID, date.Unix())
  177. if getLPEErr != nil {
  178. this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
  179. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  180. return
  181. }
  182. var lastMonitorRecord *models.MonitoringRecord
  183. lastMonitorRecord, getLastErr := service.GetLastMonitorRecord(adminInfo.CurrentOrgId, patientID, date.Unix())
  184. if getLastErr != nil {
  185. this.ErrorLog("获取上一次透析的监测记录失败:%v", getLastErr)
  186. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  187. return
  188. }
  189. lastAssessmentAfterDislysis, getLAADErr := service.GetLastTimeAssessmentAfterDislysis(adminInfo.CurrentOrgId, patientID, date.Unix())
  190. if getLAADErr != nil {
  191. this.ErrorLog("获取上一次透后评估失败:%v", getLAADErr)
  192. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  193. return
  194. }
  195. dialysisPrescribe, getDialysisPrescribeErr := service.GetDialysisPrescribe(adminInfo.CurrentOrgId, patientID, date.Unix())
  196. if getDialysisPrescribeErr != nil {
  197. this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
  198. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  199. return
  200. }
  201. dialysisSolution, getDialysisSolutionErr := service.GetDialysisSolution(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
  202. if getDialysisSolutionErr != nil {
  203. this.ErrorLog("获取透析方案失败:%v", getDialysisSolutionErr)
  204. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  205. return
  206. }
  207. lastDialysisPrescribe, getDialysisPrescribeErr := service.GetLastDialysisPrescribeByModeId(adminInfo.CurrentOrgId, patientID, schedual.ModeId)
  208. if getDialysisPrescribeErr != nil {
  209. this.ErrorLog("获取透析处方失败:%v", getDialysisPrescribeErr)
  210. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  211. return
  212. }
  213. systemDialysisPrescribe, getSystemDialysisPrescribeErr := service.GetSystemDialysisPrescribeByModeId(adminInfo.CurrentOrgId, schedual.ModeId)
  214. if getSystemDialysisPrescribeErr != nil {
  215. this.ErrorLog("获取系统透析处方失败:%v", getSystemDialysisPrescribeErr)
  216. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  217. return
  218. }
  219. if getLPEErr != nil {
  220. this.ErrorLog("获取上一次透前评估失败:%v", getLPEErr)
  221. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  222. return
  223. }
  224. lastDryWeightDislysis, getDryErr := service.GetLastDryWeight(adminInfo.CurrentOrgId, patientID)
  225. if getDryErr != nil {
  226. this.ErrorLog("获取最后一条干体重失败:%v", getDryErr)
  227. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  228. return
  229. }
  230. headNurses, _ := service.GetAllSpecialPermissionAdminUsersWithoutStatus(adminInfo.CurrentOrgId, adminInfo.CurrentAppId, models.SpecialPermissionTypeHeadNurse)
  231. _, record := service.FindAutomaticReduceRecordByOrgId(adminInfo.CurrentOrgId)
  232. _, is_open_config := service.FindXTHisRecordByOrgId(adminInfo.CurrentOrgId)
  233. //获取耗材类型
  234. stockType, _ := service.GetStockType(adminInfo.CurrentOrgId)
  235. prepare, _ := service.GetDialyStockOut(adminInfo.CurrentOrgId, date.Unix(), patientID)
  236. var his_advices []*models.HisDoctorAdviceInfo
  237. if is_open_config.IsOpen == 1 {
  238. his_advices, _ = service.GetAllHisDoctorAdvice(adminInfo.CurrentOrgId, patientID, date.Unix())
  239. }
  240. returnData := map[string]interface{}{
  241. "patient": patient,
  242. "schedual": schedual,
  243. "prescription": dialysisPrescribe,
  244. "solution": dialysisSolution,
  245. "receiver_treatment_access": receiverTreatmentAccess,
  246. "predialysis_evaluation": predialysisEvaluation,
  247. "doctor_advices": doctorAdvices,
  248. "double_check": doubleCheck,
  249. "assessment_after_dislysis": assessmentAfterDislysis,
  250. "treatment_summary": treatmentSummary,
  251. "monitor_records": monitorRecords,
  252. "dialysis_order": dialysisOrder,
  253. "doctors": admins,
  254. "config": record,
  255. "devices": devices,
  256. "device_numbers": deviceNumbers,
  257. "lastPredialysisEvaluation": lastPredialysisEvaluation,
  258. "lastMonitorRecord": lastMonitorRecord,
  259. "lastAssessmentAfterDislysis": lastAssessmentAfterDislysis,
  260. "lastDialysisPrescribe": lastDialysisPrescribe,
  261. "lastDryWeightDislysis": lastDryWeightDislysis,
  262. "headNurses": headNurses,
  263. "system_prescribe": systemDialysisPrescribe,
  264. "his_advices": his_advices,
  265. "is_open_config": is_open_config,
  266. "stockType": stockType,
  267. "prepare": prepare,
  268. }
  269. this.ServeSuccessJSON(returnData)
  270. }
  271. type EditMonitorParamObject struct {
  272. ID int64 `json:"id"`
  273. MonitoringDate int64 `json:"monitoring_date"`
  274. OperateTime int64 `json:"operate_time"`
  275. // MonitoringTime string `json:"monitoring_time"`
  276. SystolicBP float64 `json:"systolic_bp"`
  277. DiastolicBP float64 `json:"diastolic_bp"`
  278. PulseFrequency float64 `json:"pulse_frequency"`
  279. BreathingRated float64 `json:"breathing_rated"`
  280. BloodFlowVolume float64 `json:"blood_flow_volume"`
  281. VenousPressure float64 `json:"venous_pressure"`
  282. VenousPressureType int64 `json:"venous_pressure_type"`
  283. TransmembranePressure float64 `json:"transmembrane_pressure"`
  284. TransmembranePressureType int64 `json:"transmembrane_pressure_type"`
  285. UltrafiltrationVolume float64 `json:"ultrafiltration_volume"`
  286. UltrafiltrationRate float64 `json:"ultrafiltration_rate"`
  287. ArterialPressure float64 `json:"arterial_pressure"`
  288. ArterialPressureType int64 `json:"arterial_pressure_type"`
  289. SodiumConcentration float64 `json:"sodium_concentration"`
  290. DialysateTemperature float64 `json:"dialysate_temperature"`
  291. Temperature float64 `json:"temperature"`
  292. ReplacementRate float64 `json:"replacement_rate"`
  293. DisplacementQuantity float64 `json:"displacement_quantity"`
  294. KTV float64 `json:"ktv"`
  295. Symptom string `json:"symptom"`
  296. Dispose string `json:"dispose"`
  297. Result string `json:"result"`
  298. Conductivity float64 `json:"conductivity"`
  299. DisplacementFlowQuantity float64 `json:"displacement_flow_quantity"`
  300. BloodOxygenSaturation string `gorm:"column:blood_oxygen_saturation" json:"blood_oxygen_saturation" form:"blood_oxygen_saturation"`
  301. Heparin float64 `gorm:"column:heparin" json:"heparin" form:"heparin"`
  302. DialysateFlow float64 `gorm:"column:dialysate_flow" json:"dialysate_flow" form:"dialysate_flow"`
  303. Urr string `gorm:"column:urr" json:"urr" form:"urr"`
  304. BloodSugar float64 `gorm:"column:blood_sugar" json:"blood_sugar" form:"blood_sugar"`
  305. }
  306. // /api/dislysis/monitor/edit [post]
  307. // @param patient_id:int 患者id
  308. // @param schedule_date:int 排班日期
  309. // 下面的参数放到 body
  310. // @param id?:int 监测记录ID(id为0时为创建记录,不为0时为修改记录)
  311. // @param monitoring_date:int 排班日期
  312. // @param operate_time:int 实际测量日期
  313. // @param monitoring_time:string (HH:mm) 监测时间 废弃
  314. // @param systolic_bp?:float 收缩压
  315. // @param diastolic_bp?:float 舒张压
  316. // @param pulse_frequency?:float 心率
  317. // @param breathing_rated?:float 呼吸频率
  318. // @param blood_flow_volume?:float 血流量
  319. // @param venous_pressure?:float 静脉压
  320. // @param transmembrane_pressure?:float 跨膜压
  321. // @param ultrafiltration_volume?:float 超滤量
  322. // @param ultrafiltration_rate?:float 超滤率
  323. // @param arterial_pressure?:float 动脉压
  324. // @param sodium_concentration?:float 钠浓度
  325. // @param dialysate_temperature?:float 透析液温度
  326. // @param replacement_rate?:float 置换率
  327. // @param displacement_quantity?:float 置换量
  328. // @param ktv?:float KT/V
  329. // @param symptom?:string 病情变化
  330. // @param dispose?:string 处理
  331. // @param result?:string 结果
  332. func (this *DialysisRecordAPIController) EditMonitor() {
  333. patientID, _ := this.GetInt64("patient_id")
  334. scheduleDate, _ := this.GetInt64("schedule_date")
  335. if patientID <= 0 || scheduleDate <= 0 {
  336. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  337. return
  338. }
  339. var monitorParam EditMonitorParamObject
  340. if parseErr := json.Unmarshal(this.Ctx.Input.RequestBody, &monitorParam); parseErr != nil {
  341. this.ErrorLog("参数解析失败:%v", parseErr)
  342. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  343. return
  344. }
  345. if monitorParam.MonitoringDate != scheduleDate {
  346. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  347. return
  348. }
  349. adminUserInfo := this.GetAdminUserInfo()
  350. schedule, getScheduleErr := service.MobileGetSchedualDetail(adminUserInfo.CurrentOrgId, patientID, scheduleDate)
  351. if getScheduleErr != nil {
  352. this.ErrorLog("获取排班信息失败:%v", getScheduleErr)
  353. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  354. return
  355. } else if schedule == nil {
  356. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeScheduleNotExist)
  357. return
  358. }
  359. // TODO 其实这里合理的逻辑是“透析记录存在的情况下才能添加监测记录的”
  360. dialysisOrder, getDialysisOrderErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, scheduleDate)
  361. if getDialysisOrderErr != nil {
  362. this.ErrorLog("获取透析记录失败:%v", getDialysisOrderErr)
  363. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  364. return
  365. }
  366. orderID := int64(0)
  367. if dialysisOrder != nil {
  368. orderID = dialysisOrder.ID
  369. }
  370. if monitorParam.ID <= 0 { // 新建记录
  371. monitor := models.MonitoringRecord{
  372. UserOrgId: adminUserInfo.CurrentOrgId,
  373. PatientId: patientID,
  374. DialysisOrderId: orderID,
  375. MonitoringDate: monitorParam.MonitoringDate,
  376. OperateTime: monitorParam.OperateTime,
  377. // MonitoringTime: monitorParam.MonitoringTime,
  378. PulseFrequency: monitorParam.PulseFrequency,
  379. BreathingRate: monitorParam.BreathingRated,
  380. SystolicBloodPressure: monitorParam.SystolicBP,
  381. DiastolicBloodPressure: monitorParam.DiastolicBP,
  382. BloodFlowVolume: monitorParam.BloodFlowVolume,
  383. VenousPressure: monitorParam.VenousPressure,
  384. VenousPressureType: monitorParam.VenousPressureType,
  385. ArterialPressure: monitorParam.ArterialPressure,
  386. ArterialPressureType: monitorParam.ArterialPressureType,
  387. TransmembranePressure: monitorParam.TransmembranePressure,
  388. TransmembranePressureType: monitorParam.TransmembranePressureType,
  389. UltrafiltrationRate: monitorParam.UltrafiltrationRate,
  390. UltrafiltrationVolume: monitorParam.UltrafiltrationVolume,
  391. SodiumConcentration: monitorParam.SodiumConcentration,
  392. DialysateTemperature: monitorParam.DialysateTemperature,
  393. Temperature: monitorParam.Temperature,
  394. ReplacementRate: monitorParam.ReplacementRate,
  395. DisplacementQuantity: monitorParam.DisplacementQuantity,
  396. Ktv: monitorParam.KTV,
  397. Symptom: monitorParam.Symptom,
  398. Dispose: monitorParam.Dispose,
  399. Result: monitorParam.Result,
  400. MonitoringNurse: adminUserInfo.AdminUser.Id,
  401. Conductivity: monitorParam.Conductivity,
  402. DisplacementFlowQuantity: monitorParam.DisplacementFlowQuantity,
  403. Status: 1,
  404. CreatedTime: time.Now().Unix(),
  405. UpdatedTime: time.Now().Unix(),
  406. BloodOxygenSaturation: monitorParam.BloodOxygenSaturation,
  407. Creator: adminUserInfo.AdminUser.Id,
  408. Heparin: monitorParam.Heparin,
  409. DialysateFlow: monitorParam.DialysateFlow,
  410. Urr: monitorParam.Urr,
  411. BloodSugar: monitorParam.BloodSugar,
  412. }
  413. createErr := service.CreateMonitor(&monitor)
  414. if createErr != nil {
  415. this.ErrorLog("创建监测记录失败:%v", createErr)
  416. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  417. return
  418. }
  419. this.ServeSuccessJSON(map[string]interface{}{
  420. "monitor": monitor,
  421. })
  422. } else { // 修改记录
  423. monitor, getMonitorErr := service.GetMonitor(adminUserInfo.CurrentOrgId, patientID, monitorParam.ID)
  424. if getMonitorErr != nil {
  425. this.ErrorLog("获取透析监测记录失败:%v", getMonitorErr)
  426. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  427. return
  428. } else if monitor == nil {
  429. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorNotExist)
  430. return
  431. }
  432. //if monitor.MonitoringNurse != adminUserInfo.AdminUser.Id {
  433. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  434. // if getPermissionErr != nil {
  435. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  436. // return
  437. // } else if headNursePermission == nil {
  438. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  439. // return
  440. // }
  441. //}
  442. monitor.OperateTime = monitorParam.OperateTime
  443. monitor.PulseFrequency = monitorParam.PulseFrequency
  444. monitor.BreathingRate = monitorParam.BreathingRated
  445. monitor.SystolicBloodPressure = monitorParam.SystolicBP
  446. monitor.DiastolicBloodPressure = monitorParam.DiastolicBP
  447. monitor.BloodFlowVolume = monitorParam.BloodFlowVolume
  448. monitor.VenousPressure = monitorParam.VenousPressure
  449. monitor.VenousPressureType = monitorParam.VenousPressureType
  450. monitor.ArterialPressure = monitorParam.ArterialPressure
  451. monitor.ArterialPressureType = monitorParam.ArterialPressureType
  452. monitor.TransmembranePressure = monitorParam.TransmembranePressure
  453. monitor.TransmembranePressureType = monitorParam.TransmembranePressureType
  454. monitor.UltrafiltrationRate = monitorParam.UltrafiltrationRate
  455. monitor.UltrafiltrationVolume = monitorParam.UltrafiltrationVolume
  456. monitor.SodiumConcentration = monitorParam.SodiumConcentration
  457. monitor.DialysateTemperature = monitorParam.DialysateTemperature
  458. monitor.Temperature = monitorParam.Temperature
  459. monitor.ReplacementRate = monitorParam.ReplacementRate
  460. monitor.DisplacementQuantity = monitorParam.DisplacementQuantity
  461. monitor.Conductivity = monitorParam.Conductivity
  462. monitor.DisplacementFlowQuantity = monitorParam.DisplacementFlowQuantity
  463. monitor.Ktv = monitorParam.KTV
  464. monitor.Symptom = monitorParam.Symptom
  465. monitor.Dispose = monitorParam.Dispose
  466. monitor.Result = monitorParam.Result
  467. monitor.MonitoringNurse = adminUserInfo.AdminUser.Id
  468. monitor.UpdatedTime = time.Now().Unix()
  469. monitor.Modify = adminUserInfo.AdminUser.Id
  470. monitor.BloodOxygenSaturation = monitorParam.BloodOxygenSaturation
  471. monitor.Heparin = monitorParam.Heparin
  472. monitor.DialysateFlow = monitorParam.DialysateFlow
  473. monitor.Urr = monitorParam.Urr
  474. monitor.BloodSugar = monitorParam.BloodSugar
  475. updateErr := service.UpdateMonitor(monitor)
  476. if updateErr != nil {
  477. this.ErrorLog("修改透析监测记录失败:%v", updateErr)
  478. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  479. return
  480. }
  481. this.ServeSuccessJSON(map[string]interface{}{
  482. "monitor": monitor,
  483. })
  484. }
  485. }
  486. // /api/dialysis/start_record [post]
  487. // @param patient_id:int
  488. // @param date:string 排班时间 (yyyy-mm-dd)
  489. // @param nurse:int 上机护士
  490. // @param bed:int 上机床位号
  491. func (this *DialysisRecordAPIController) StartDialysis() {
  492. patientID, _ := this.GetInt64("patient_id")
  493. recordDateStr := this.GetString("date")
  494. nurseID, _ := this.GetInt64("nurse")
  495. punctureNurseId, _ := this.GetInt64("puncture_nurse")
  496. startDateStr := this.GetString("start_time")
  497. blood_drawing, _ := this.GetInt64("blood_drawing")
  498. schedual_type, _ := this.GetInt64("schedual_type")
  499. washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
  500. change_nurse, _ := this.GetInt64("change_nurse")
  501. bedID, _ := this.GetInt64("bed")
  502. if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
  503. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  504. return
  505. }
  506. recordDate, parseErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  507. if parseErr != nil {
  508. this.ErrorLog("时间解析失败:%v", parseErr)
  509. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  510. return
  511. }
  512. startDate, parseErr := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  513. if parseErr != nil {
  514. this.ErrorLog("时间解析失败:%v", parseErr)
  515. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  516. return
  517. }
  518. adminUserInfo := this.GetAdminUserInfo()
  519. patient, getPatientErr := service.MobileGetPatientById(adminUserInfo.CurrentOrgId, patientID)
  520. if getPatientErr != nil {
  521. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  522. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  523. return
  524. } else if patient == nil {
  525. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  526. return
  527. }
  528. nurse, getNurseErr := service.GetAdminUserByUserID(nurseID)
  529. if getNurseErr != nil {
  530. this.ErrorLog("获取护士失败:%v", getNurseErr)
  531. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  532. return
  533. } else if nurse == nil {
  534. this.ErrorLog("护士不存在")
  535. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  536. return
  537. }
  538. //nurse, getNurseErr = service.GetAdminUserByUserID(punctureNurseId)
  539. //
  540. //if getNurseErr != nil {
  541. // this.ErrorLog("获取护士失败:%v", getNurseErr)
  542. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  543. // return
  544. //} else if nurse == nil {
  545. // this.ErrorLog("护士不存在")
  546. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  547. // return
  548. //}
  549. deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, bedID)
  550. if getDeviceNumberErr != nil {
  551. this.ErrorLog("获取床位号失败:%v", getDeviceNumberErr)
  552. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  553. return
  554. } else if deviceNumber == nil {
  555. this.ErrorLog("床位号不存在")
  556. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  557. return
  558. }
  559. dialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  560. if getRecordErr != nil {
  561. this.ErrorLog("获取透析记录失败:%v", getRecordErr)
  562. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  563. return
  564. } else if dialysisRecord != nil {
  565. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatStart)
  566. return
  567. }
  568. template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  569. scheduleDateStart := startDate.Format("2006-01-02") + " 00:00:00"
  570. scheduleDateEnd := startDate.Format("2006-01-02") + " 23:59:59"
  571. timeLayout := "2006-01-02 15:04:05"
  572. loc, _ := time.LoadLocation("Local")
  573. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  574. theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
  575. schedulestartTime := theStartTime.Unix()
  576. scheduleendTime := theEndTime.Unix()
  577. //查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
  578. schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
  579. //查询该床位是否有人用了
  580. order, order_err := service.GetDialysisOrderByBedId(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
  581. if err == gorm.ErrRecordNotFound { //空床位
  582. // 修改了床位逻辑
  583. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
  584. if daySchedule.ID > 0 {
  585. daySchedule.PartitionId = deviceNumber.ZoneID
  586. daySchedule.BedId = bedID
  587. daySchedule.ScheduleType = schedual_type
  588. daySchedule.UpdatedTime = time.Now().Unix()
  589. err := service.UpdateSchedule(&daySchedule)
  590. if err != nil {
  591. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  592. return
  593. }
  594. }
  595. } else if err == nil {
  596. if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //有排班没上机记录
  597. if order_err == nil {
  598. if order.ID > 0 { //该机位被其他人占用了
  599. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  600. return
  601. } else {
  602. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
  603. if daySchedule.ID > 0 {
  604. daySchedule.PartitionId = deviceNumber.ZoneID
  605. daySchedule.BedId = bedID
  606. daySchedule.ScheduleType = schedual_type
  607. daySchedule.UpdatedTime = time.Now().Unix()
  608. err := service.UpdateSchedule(&daySchedule)
  609. if err != nil {
  610. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  611. return
  612. }
  613. }
  614. }
  615. } else if order_err == gorm.ErrRecordNotFound { //该床位没被占用
  616. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
  617. if daySchedule.ID > 0 {
  618. daySchedule.PartitionId = deviceNumber.ZoneID
  619. daySchedule.BedId = bedID
  620. daySchedule.ScheduleType = schedual_type
  621. daySchedule.UpdatedTime = time.Now().Unix()
  622. err := service.UpdateSchedule(&daySchedule)
  623. if err != nil {
  624. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  625. return
  626. }
  627. }
  628. } else if order_err != nil {
  629. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  630. return
  631. }
  632. } else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //有排班且有上机记录
  633. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  634. return
  635. }
  636. } else if err != nil {
  637. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  638. return
  639. }
  640. dialysisRecord = &models.DialysisOrder{
  641. DialysisDate: recordDate.Unix(),
  642. UserOrgId: adminUserInfo.CurrentOrgId,
  643. PatientId: patientID,
  644. Stage: 1,
  645. BedID: bedID,
  646. StartNurse: nurseID,
  647. Status: 1,
  648. StartTime: startDate.Unix(),
  649. CreatedTime: time.Now().Unix(),
  650. UpdatedTime: time.Now().Unix(),
  651. PunctureNurse: punctureNurseId,
  652. Creator: adminUserInfo.AdminUser.Id,
  653. Modifier: adminUserInfo.AdminUser.Id,
  654. SchedualType: schedual_type,
  655. WashpipeNurse: washpipe_nurse,
  656. ChangeNurse: change_nurse,
  657. }
  658. createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
  659. newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  660. if createErr != nil {
  661. this.ErrorLog("上机失败:%v", createErr)
  662. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  663. return
  664. } else if createErr == nil {
  665. var tempdispose string
  666. // 只针对中能建
  667. if blood_drawing > 0 && adminUserInfo.CurrentOrgId == 9538 { //adminUserInfo.CurrentOrgId == 9538
  668. tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
  669. }
  670. var ultrafiltration_rate float64
  671. _, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.CurrentOrgId)
  672. if prescription.ID > 0 {
  673. if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
  674. totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
  675. if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 {
  676. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
  677. }
  678. // 只针对方济医院
  679. if template.TemplateId == 1 && adminUserInfo.CurrentOrgId != 9849 {
  680. value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
  681. ultrafiltration_rate = value
  682. }
  683. }
  684. }
  685. record := models.MonitoringRecord{
  686. UserOrgId: adminUserInfo.CurrentOrgId,
  687. PatientId: patientID,
  688. DialysisOrderId: dialysisRecord.ID,
  689. MonitoringDate: schedulestartTime,
  690. OperateTime: startDate.Unix(),
  691. // MonitoringTime: recordTime,
  692. MonitoringNurse: nurseID,
  693. Dispose: tempdispose,
  694. UltrafiltrationRate: ultrafiltration_rate,
  695. UltrafiltrationVolume: 0,
  696. Status: 1,
  697. CreatedTime: time.Now().Unix(),
  698. UpdatedTime: time.Now().Unix(),
  699. }
  700. // 如果当天有插入数据,则不再往透析纪录里插入数据
  701. if newdialysisRecord.ID > 0 {
  702. err := service.CreateMonitor(&record)
  703. if err != nil {
  704. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
  705. return
  706. }
  707. }
  708. go func() {
  709. ssoDomain := beego.AppConfig.String("call_domain")
  710. api := ssoDomain + "/index/uppatient"
  711. values := make(url.Values)
  712. values.Set("org_id", strconv.FormatInt(adminUserInfo.CurrentOrgId, 10))
  713. values.Set("admin_user_id", strconv.FormatInt(nurseID, 10))
  714. values.Set("patient_id", strconv.FormatInt(patientID, 10))
  715. values.Set("up_time", strconv.FormatInt(startDate.Unix(), 10))
  716. http.PostForm(api, values)
  717. }()
  718. this.ServeSuccessJSON(map[string]interface{}{
  719. "dialysis_order": dialysisRecord,
  720. "monitor": record,
  721. })
  722. }
  723. }
  724. // /api/dialysis/finish [post]
  725. // @param patient_id:int
  726. // @param date:string 排班时间 (yyyy-mm-dd)
  727. // @param nurse:int 下机护士
  728. func (this *DialysisRecordAPIController) FinishDialysis() {
  729. patientID, _ := this.GetInt64("patient_id")
  730. recordDateStr := this.GetString("date")
  731. nurseID, _ := this.GetInt64("nurse")
  732. end_time := this.GetString("end_time")
  733. if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 {
  734. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  735. return
  736. }
  737. recordDate, parseErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  738. if parseErr != nil {
  739. this.ErrorLog("时间解析失败:%v", parseErr)
  740. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  741. return
  742. }
  743. //if parseEndDateErr != nil {
  744. // this.ErrorLog("时间解析失败:%v", parseEndDateErr)
  745. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  746. // return
  747. //}
  748. adminUserInfo := this.GetAdminUserInfo()
  749. patient, getPatientErr := service.MobileGetPatientById(adminUserInfo.CurrentOrgId, patientID)
  750. if getPatientErr != nil {
  751. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  752. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. } else if patient == nil {
  755. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  756. return
  757. }
  758. nurse, getNurseErr := service.GetAdminUserByUserID(nurseID)
  759. if getNurseErr != nil {
  760. this.ErrorLog("获取护士失败:%v", getNurseErr)
  761. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  762. return
  763. } else if nurse == nil {
  764. this.ErrorLog("护士不存在")
  765. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  766. return
  767. }
  768. dialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  769. if getRecordErr != nil {
  770. this.ErrorLog("获取透析记录失败:%v", getRecordErr)
  771. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. if dialysisRecord.Stage == 2 {
  775. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderNoEND)
  776. return
  777. }
  778. endDate, parseEndDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04", end_time)
  779. if parseEndDateErr != nil {
  780. this.ErrorLog("日期(%v)解析错误:%v", end_time, parseEndDateErr)
  781. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  782. return
  783. }
  784. // 获取当天的第一条透析纪录
  785. fmonitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecordFirst(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  786. if getMonitorRecordsErr != nil {
  787. this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
  788. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  789. return
  790. }
  791. // 获取当前的最后一条透析纪录
  792. endmonitorRecords, getMonitorRecordsErr := service.MobileGetLastMonitorRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  793. if getMonitorRecordsErr != nil {
  794. this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
  795. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  796. return
  797. }
  798. assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  799. if getAADErr != nil {
  800. this.ErrorLog("获取透后评估失败:%v", getAADErr)
  801. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  802. return
  803. }
  804. lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  805. var tempassessmentAfterDislysis models.AssessmentAfterDislysis
  806. if assessmentAfterDislysis != nil {
  807. tempassessmentAfterDislysis = *assessmentAfterDislysis
  808. tempassessmentAfterDislysis.UpdatedTime = time.Now().Unix()
  809. } else {
  810. tempassessmentAfterDislysis.CreatedTime = time.Now().Unix()
  811. tempassessmentAfterDislysis.AssessmentDate = recordDate.Unix()
  812. tempassessmentAfterDislysis.Status = 1
  813. tempassessmentAfterDislysis.PatientId = patientID
  814. tempassessmentAfterDislysis.UserOrgId = adminUserInfo.CurrentOrgId
  815. }
  816. if dialysisRecord.Stage == 1 {
  817. temp_time := (float64(endDate.Unix()) - float64(dialysisRecord.StartTime)) / 3600
  818. value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
  819. fmt.Println(value)
  820. a, b := math.Modf(value)
  821. c, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
  822. hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
  823. minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", c*60), 10, 64)
  824. fmt.Println(hour)
  825. fmt.Println(minute)
  826. tempassessmentAfterDislysis.ActualTreatmentHour = hour
  827. tempassessmentAfterDislysis.ActualTreatmentMinute = minute
  828. }
  829. if fmonitorRecords.ID > 0 && endmonitorRecords.ID > 0 {
  830. tempassessmentAfterDislysis.Temperature = endmonitorRecords.Temperature
  831. tempassessmentAfterDislysis.PulseFrequency = endmonitorRecords.PulseFrequency
  832. tempassessmentAfterDislysis.BreathingRate = endmonitorRecords.BreathingRate
  833. tempassessmentAfterDislysis.SystolicBloodPressure = endmonitorRecords.SystolicBloodPressure
  834. tempassessmentAfterDislysis.DiastolicBloodPressure = endmonitorRecords.DiastolicBloodPressure
  835. tempassessmentAfterDislysis.ActualUltrafiltration = endmonitorRecords.UltrafiltrationVolume
  836. tempassessmentAfterDislysis.ActualDisplacement = endmonitorRecords.DisplacementQuantity
  837. }
  838. if adminUserInfo.CurrentOrgId == 9583 {
  839. //获取最后一条透析处方数据
  840. prescription, parseErr := service.GetLastDialysisPrescriptionByPatientId(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  841. if parseErr != nil {
  842. this.ErrorLog("获取透析处方失败:%v", getMonitorRecordsErr)
  843. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  844. return
  845. }
  846. if prescription.ID > 0 && adminUserInfo.CurrentOrgId == 9583 {
  847. tempassessmentAfterDislysis.ActualUltrafiltration = prescription.TargetUltrafiltration
  848. }
  849. }
  850. if lastAssessmentAfterDislysis != nil {
  851. tempassessmentAfterDislysis.BloodPressureType = lastAssessmentAfterDislysis.BloodPressureType
  852. tempassessmentAfterDislysis.WeighingWay = lastAssessmentAfterDislysis.WeighingWay
  853. tempassessmentAfterDislysis.Cruor = lastAssessmentAfterDislysis.Cruor
  854. tempassessmentAfterDislysis.SymptomAfterDialysis = lastAssessmentAfterDislysis.SymptomAfterDialysis
  855. tempassessmentAfterDislysis.InternalFistula = lastAssessmentAfterDislysis.InternalFistula
  856. tempassessmentAfterDislysis.Catheter = lastAssessmentAfterDislysis.Catheter
  857. tempassessmentAfterDislysis.Complication = lastAssessmentAfterDislysis.Complication
  858. tempassessmentAfterDislysis.DialysisIntakes = lastAssessmentAfterDislysis.DialysisIntakes
  859. tempassessmentAfterDislysis.DialysisIntakesFeed = lastAssessmentAfterDislysis.DialysisIntakesFeed
  860. tempassessmentAfterDislysis.DialysisIntakesTransfusion = lastAssessmentAfterDislysis.DialysisIntakesTransfusion
  861. tempassessmentAfterDislysis.DialysisIntakesBloodTransfusion = lastAssessmentAfterDislysis.DialysisIntakesBloodTransfusion
  862. tempassessmentAfterDislysis.DialysisIntakesWashpipe = lastAssessmentAfterDislysis.DialysisIntakesWashpipe
  863. tempassessmentAfterDislysis.BloodAccessPartId = lastAssessmentAfterDislysis.BloodAccessPartId
  864. tempassessmentAfterDislysis.BloodAccessPartOperaId = lastAssessmentAfterDislysis.BloodAccessPartOperaId
  865. tempassessmentAfterDislysis.PuncturePointOozingBlood = lastAssessmentAfterDislysis.PuncturePointOozingBlood
  866. tempassessmentAfterDislysis.PuncturePointHaematoma = lastAssessmentAfterDislysis.PuncturePointHaematoma
  867. tempassessmentAfterDislysis.InternalFistulaTremorAc = lastAssessmentAfterDislysis.InternalFistulaTremorAc
  868. tempassessmentAfterDislysis.PatientGose = lastAssessmentAfterDislysis.PatientGose
  869. tempassessmentAfterDislysis.InpatientDepartment = lastAssessmentAfterDislysis.InpatientDepartment
  870. tempassessmentAfterDislysis.ObservationContent = lastAssessmentAfterDislysis.ObservationContent
  871. tempassessmentAfterDislysis.ObservationContentOther = lastAssessmentAfterDislysis.ObservationContentOther
  872. tempassessmentAfterDislysis.DryWeight = lastAssessmentAfterDislysis.DryWeight
  873. tempassessmentAfterDislysis.DialysisProcess = lastAssessmentAfterDislysis.DialysisProcess
  874. tempassessmentAfterDislysis.InAdvanceMinute = lastAssessmentAfterDislysis.InAdvanceMinute
  875. tempassessmentAfterDislysis.InAdvanceReason = lastAssessmentAfterDislysis.InAdvanceReason
  876. tempassessmentAfterDislysis.HemostasisMinute = lastAssessmentAfterDislysis.HemostasisMinute
  877. tempassessmentAfterDislysis.HemostasisOpera = lastAssessmentAfterDislysis.HemostasisOpera
  878. tempassessmentAfterDislysis.TremorNoise = lastAssessmentAfterDislysis.TremorNoise
  879. tempassessmentAfterDislysis.DisequilibriumSyndrome = lastAssessmentAfterDislysis.DisequilibriumSyndrome
  880. tempassessmentAfterDislysis.DisequilibriumSyndromeOption = lastAssessmentAfterDislysis.DisequilibriumSyndromeOption
  881. tempassessmentAfterDislysis.ArterialTube = lastAssessmentAfterDislysis.ArterialTube
  882. tempassessmentAfterDislysis.IntravenousTube = lastAssessmentAfterDislysis.IntravenousTube
  883. tempassessmentAfterDislysis.Dialyzer = lastAssessmentAfterDislysis.Dialyzer
  884. tempassessmentAfterDislysis.InAdvanceReasonOther = lastAssessmentAfterDislysis.InAdvanceReasonOther
  885. tempassessmentAfterDislysis.IsEat = lastAssessmentAfterDislysis.IsEat
  886. tempassessmentAfterDislysis.DialysisIntakesUnit = lastAssessmentAfterDislysis.DialysisIntakesUnit
  887. tempassessmentAfterDislysis.CvcA = lastAssessmentAfterDislysis.CvcA
  888. tempassessmentAfterDislysis.CvcV = lastAssessmentAfterDislysis.CvcV
  889. tempassessmentAfterDislysis.Channel = lastAssessmentAfterDislysis.Channel
  890. tempassessmentAfterDislysis.ReturnBlood = lastAssessmentAfterDislysis.ReturnBlood
  891. tempassessmentAfterDislysis.RehydrationVolume = lastAssessmentAfterDislysis.RehydrationVolume
  892. tempassessmentAfterDislysis.DialysisDuring = lastAssessmentAfterDislysis.DialysisDuring
  893. tempassessmentAfterDislysis.StrokeVolume = lastAssessmentAfterDislysis.StrokeVolume
  894. tempassessmentAfterDislysis.BloodFlow = lastAssessmentAfterDislysis.BloodFlow
  895. tempassessmentAfterDislysis.SealingFluidDispose = lastAssessmentAfterDislysis.SealingFluidDispose
  896. tempassessmentAfterDislysis.SealingFluidSpecial = lastAssessmentAfterDislysis.SealingFluidSpecial
  897. }
  898. err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
  899. if err != nil {
  900. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  901. return
  902. }
  903. go func() {
  904. ssoDomain := beego.AppConfig.String("call_domain")
  905. api := ssoDomain + "/index/downpatient"
  906. values := make(url.Values)
  907. values.Set("org_id", strconv.FormatInt(adminUserInfo.CurrentOrgId, 10))
  908. values.Set("admin_user_id", strconv.FormatInt(nurseID, 10))
  909. values.Set("patient_id", strconv.FormatInt(patientID, 10))
  910. http.PostForm(api, values)
  911. }()
  912. updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
  913. if updateErr != nil {
  914. this.ErrorLog("下机失败:%v", updateErr)
  915. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  916. return
  917. } else {
  918. dialysisRecord.Stage = 2
  919. dialysisRecord.FinishNurse = nurseID
  920. dialysisRecord.FinishCreator = adminUserInfo.AdminUser.Id
  921. dialysisRecord.FinishModifier = adminUserInfo.AdminUser.Id
  922. dialysisRecord.EndTime = endDate.Unix()
  923. // 结束时候透析次数加1
  924. service.UpdateSolutionByPatientId(patientID)
  925. this.ServeSuccessJSON(map[string]interface{}{
  926. "dialysis_order": dialysisRecord,
  927. "assessmentAfterDislysis": tempassessmentAfterDislysis,
  928. })
  929. }
  930. }
  931. func (this *DialysisRecordAPIController) ModifyStartDialysis() {
  932. record_id, _ := this.GetInt64("id")
  933. nurseID, _ := this.GetInt64("nurse")
  934. puncture_nurse, _ := this.GetInt64("puncture_nurse")
  935. bedID, _ := this.GetInt64("bed")
  936. start_time := this.GetString("start_time")
  937. washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
  938. schedual_type, _ := this.GetInt64("schedual_type")
  939. change_nurse, _ := this.GetInt64("change_nurse")
  940. if record_id == 0 {
  941. this.ErrorLog("id:%v", record_id)
  942. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  943. return
  944. }
  945. startDate, parseStartDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04", start_time)
  946. if parseStartDateErr != nil {
  947. this.ErrorLog("时间解析失败:%v", parseStartDateErr)
  948. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  949. return
  950. }
  951. adminUserInfo := this.GetAdminUserInfo()
  952. nurse, getNurseErr := service.GetAdminUserByUserID(nurseID)
  953. if getNurseErr != nil {
  954. this.ErrorLog("获取护士失败:%v", getNurseErr)
  955. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  956. return
  957. } else if nurse == nil {
  958. this.ErrorLog("护士不存在")
  959. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  960. return
  961. }
  962. //nurse, getNurseErr = service.GetAdminUserByUserID(puncture_nurse)
  963. //if getNurseErr != nil {
  964. // this.ErrorLog("获取护士失败:%v", getNurseErr)
  965. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  966. // return
  967. //} else if nurse == nil {
  968. // this.ErrorLog("护士不存在")
  969. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  970. // return
  971. //}
  972. deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, bedID)
  973. if getDeviceNumberErr != nil {
  974. this.ErrorLog("获取床位号失败:%v", getDeviceNumberErr)
  975. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  976. return
  977. } else if deviceNumber == nil {
  978. this.ErrorLog("床位号不存在")
  979. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  980. return
  981. }
  982. _, tempDialysisRecord := service.FindDialysisOrderById(record_id)
  983. //if tempDialysisRecord.Creator != adminUserInfo.AdminUser.Id {
  984. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  985. // if getPermissionErr != nil {
  986. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  987. // return
  988. // } else if headNursePermission == nil {
  989. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  990. // return
  991. // }
  992. //}
  993. scheduleDateStart := startDate.Format("2006-01-02") + " 00:00:00"
  994. scheduleDateEnd := startDate.Format("2006-01-02") + " 23:59:59"
  995. timeLayout := "2006-01-02 15:04:05"
  996. loc, _ := time.LoadLocation("Local")
  997. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  998. theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
  999. schedulestartTime := theStartTime.Unix()
  1000. scheduleendTime := theEndTime.Unix()
  1001. //查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
  1002. schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
  1003. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, tempDialysisRecord.PatientId)
  1004. if daySchedule.BedId != bedID || daySchedule.ScheduleType != schedual_type {
  1005. if err == gorm.ErrRecordNotFound { //空床位
  1006. // 修改了床位逻辑
  1007. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, tempDialysisRecord.PatientId)
  1008. if daySchedule.ID > 0 {
  1009. daySchedule.BedId = bedID
  1010. daySchedule.PartitionId = deviceNumber.ZoneID
  1011. daySchedule.ScheduleType = schedual_type
  1012. daySchedule.UpdatedTime = time.Now().Unix()
  1013. err := service.UpdateSchedule(&daySchedule)
  1014. if err != nil {
  1015. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1016. return
  1017. }
  1018. }
  1019. } else if err == nil {
  1020. if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //有排班没上机记录
  1021. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, tempDialysisRecord.PatientId)
  1022. if daySchedule.ID > 0 {
  1023. daySchedule.BedId = bedID
  1024. daySchedule.PartitionId = deviceNumber.ZoneID
  1025. daySchedule.ScheduleType = schedual_type
  1026. daySchedule.UpdatedTime = time.Now().Unix()
  1027. err := service.UpdateSchedule(&daySchedule)
  1028. if err != nil {
  1029. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. }
  1033. } else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //有排班且有上机记录
  1034. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  1035. return
  1036. }
  1037. } else if err != nil {
  1038. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. }
  1042. dialysisRecord := &models.DialysisOrder{
  1043. ID: record_id,
  1044. UserOrgId: adminUserInfo.CurrentOrgId,
  1045. BedID: bedID,
  1046. StartNurse: nurseID,
  1047. StartTime: startDate.Unix(),
  1048. PunctureNurse: puncture_nurse,
  1049. Creator: adminUserInfo.AdminUser.Id,
  1050. Modifier: adminUserInfo.AdminUser.Id,
  1051. SchedualType: schedual_type,
  1052. WashpipeNurse: washpipe_nurse,
  1053. ChangeNurse: change_nurse,
  1054. }
  1055. updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
  1056. if updateErr != nil {
  1057. this.ErrorLog("修改上机失败:%v", updateErr)
  1058. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1059. return
  1060. }
  1061. if updateErr == nil {
  1062. if tempDialysisRecord.Stage == 2 {
  1063. temp_time := (float64(tempDialysisRecord.EndTime) - float64(startDate.Unix())) / 3600
  1064. value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
  1065. fmt.Println(value)
  1066. a, b := math.Modf(value)
  1067. tempMinute, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
  1068. hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
  1069. minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
  1070. updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecord.PatientId, tempDialysisRecord.UserOrgId, tempDialysisRecord.DialysisDate, hour, minute)
  1071. if updateAssessmentErr != nil {
  1072. utils.ErrorLog("%v", updateAssessmentErr)
  1073. }
  1074. after, _ := service.FindAssessmentAfterDislysisById(tempDialysisRecord.UserOrgId, tempDialysisRecord.PatientId, tempDialysisRecord.DialysisDate)
  1075. _, dialysisRecords := service.FindDialysisOrderById(record_id)
  1076. this.ServeSuccessJSON(map[string]interface{}{
  1077. "dialysis_order": dialysisRecords,
  1078. "after": after,
  1079. })
  1080. } else {
  1081. _, dialysisRecords := service.FindDialysisOrderById(record_id)
  1082. this.ServeSuccessJSON(map[string]interface{}{
  1083. "dialysis_order": dialysisRecords,
  1084. })
  1085. }
  1086. }
  1087. }
  1088. func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
  1089. record_id, _ := c.GetInt64("id")
  1090. nurseID, _ := c.GetInt64("nurse")
  1091. end_time := c.GetString("end_time")
  1092. if record_id <= 0 || nurseID <= 0 {
  1093. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1094. return
  1095. }
  1096. adminUserInfo := c.GetAdminUserInfo()
  1097. nurse, getNurseErr := service.GetAdminUserByUserID(nurseID)
  1098. if getNurseErr != nil {
  1099. c.ErrorLog("获取护士失败:%v", getNurseErr)
  1100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1101. return
  1102. } else if nurse == nil {
  1103. c.ErrorLog("护士不存在")
  1104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1105. return
  1106. }
  1107. endDate, parseEndDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04", end_time)
  1108. if parseEndDateErr != nil {
  1109. c.ErrorLog("日期(%v)解析错误:%v", end_time, parseEndDateErr)
  1110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1111. return
  1112. }
  1113. _, tempDialysisRecords := service.FindDialysisOrderById(record_id)
  1114. //if tempDialysisRecords.FinishCreator != adminUserInfo.AdminUser.Id {
  1115. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  1116. // if getPermissionErr != nil {
  1117. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1118. // return
  1119. // } else if headNursePermission == nil {
  1120. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  1121. // return
  1122. // }
  1123. //}
  1124. dialysisRecord := &models.DialysisOrder{
  1125. ID: record_id,
  1126. UserOrgId: adminUserInfo.CurrentOrgId,
  1127. EndTime: endDate.Unix(),
  1128. FinishNurse: nurseID,
  1129. FinishModifier: adminUserInfo.AdminUser.Id,
  1130. }
  1131. updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
  1132. if updateErr != nil {
  1133. c.ErrorLog("修改下机失败:%v", updateErr)
  1134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1135. return
  1136. }
  1137. if updateErr == nil {
  1138. temp_time := (float64(endDate.Unix()) - float64(tempDialysisRecords.StartTime)) / 3600
  1139. value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
  1140. fmt.Println(value)
  1141. a, b := math.Modf(value)
  1142. tempMinute, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
  1143. hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
  1144. minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
  1145. updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecords.PatientId, tempDialysisRecords.UserOrgId, tempDialysisRecords.DialysisDate, hour, minute)
  1146. if updateAssessmentErr != nil {
  1147. utils.ErrorLog("%v", updateAssessmentErr)
  1148. }
  1149. }
  1150. after, _ := service.FindAssessmentAfterDislysisById(tempDialysisRecords.UserOrgId, tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate)
  1151. _, dialysisRecords := service.FindDialysisOrderById(record_id)
  1152. c.ServeSuccessJSON(map[string]interface{}{
  1153. "dialysis_order": dialysisRecords,
  1154. "after": after,
  1155. })
  1156. }