dialysis_record_api_controller.go 54KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309
  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. difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
  502. new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
  503. bedID, _ := this.GetInt64("bed")
  504. if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 || bedID <= 0 {
  505. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  506. return
  507. }
  508. recordDate, parseErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  509. if parseErr != nil {
  510. this.ErrorLog("时间解析失败:%v", parseErr)
  511. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  512. return
  513. }
  514. startDate, parseErr := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  515. if parseErr != nil {
  516. this.ErrorLog("时间解析失败:%v", parseErr)
  517. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  518. return
  519. }
  520. adminUserInfo := this.GetAdminUserInfo()
  521. patient, getPatientErr := service.MobileGetPatientById(adminUserInfo.CurrentOrgId, patientID)
  522. if getPatientErr != nil {
  523. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  524. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  525. return
  526. } else if patient == nil {
  527. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  528. return
  529. }
  530. nurse, getNurseErr := service.GetAdminUserByUserID(nurseID)
  531. if getNurseErr != nil {
  532. this.ErrorLog("获取护士失败:%v", getNurseErr)
  533. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  534. return
  535. } else if nurse == nil {
  536. this.ErrorLog("护士不存在")
  537. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  538. return
  539. }
  540. //nurse, getNurseErr = service.GetAdminUserByUserID(punctureNurseId)
  541. //
  542. //if getNurseErr != nil {
  543. // this.ErrorLog("获取护士失败:%v", getNurseErr)
  544. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  545. // return
  546. //} else if nurse == nil {
  547. // this.ErrorLog("护士不存在")
  548. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  549. // return
  550. //}
  551. deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, bedID)
  552. if getDeviceNumberErr != nil {
  553. this.ErrorLog("获取床位号失败:%v", getDeviceNumberErr)
  554. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  555. return
  556. } else if deviceNumber == nil {
  557. this.ErrorLog("床位号不存在")
  558. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  559. return
  560. }
  561. dialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  562. if getRecordErr != nil {
  563. this.ErrorLog("获取透析记录失败:%v", getRecordErr)
  564. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  565. return
  566. } else if dialysisRecord != nil {
  567. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatStart)
  568. return
  569. }
  570. template, _ := service.GetOrgInfoTemplate(adminUserInfo.CurrentOrgId)
  571. scheduleDateStart := startDate.Format("2006-01-02") + " 00:00:00"
  572. scheduleDateEnd := startDate.Format("2006-01-02") + " 23:59:59"
  573. timeLayout := "2006-01-02 15:04:05"
  574. loc, _ := time.LoadLocation("Local")
  575. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  576. theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
  577. schedulestartTime := theStartTime.Unix()
  578. scheduleendTime := theEndTime.Unix()
  579. //查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
  580. schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
  581. //查询该床位是否有人用了
  582. order, order_err := service.GetDialysisOrderByBedId(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
  583. if err == gorm.ErrRecordNotFound { //空床位
  584. // 修改了床位逻辑
  585. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
  586. if daySchedule.ID > 0 {
  587. daySchedule.PartitionId = deviceNumber.ZoneID
  588. daySchedule.BedId = bedID
  589. daySchedule.ScheduleType = schedual_type
  590. daySchedule.UpdatedTime = time.Now().Unix()
  591. err := service.UpdateSchedule(&daySchedule)
  592. if err != nil {
  593. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  594. return
  595. }
  596. }
  597. } else if err == nil {
  598. if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //有排班没上机记录
  599. if order_err == nil {
  600. if order.ID > 0 { //该机位被其他人占用了
  601. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  602. return
  603. } else {
  604. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
  605. if daySchedule.ID > 0 {
  606. daySchedule.PartitionId = deviceNumber.ZoneID
  607. daySchedule.BedId = bedID
  608. daySchedule.ScheduleType = schedual_type
  609. daySchedule.UpdatedTime = time.Now().Unix()
  610. err := service.UpdateSchedule(&daySchedule)
  611. if err != nil {
  612. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  613. return
  614. }
  615. }
  616. }
  617. } else if order_err == gorm.ErrRecordNotFound { //该床位没被占用
  618. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, patientID)
  619. if daySchedule.ID > 0 {
  620. daySchedule.PartitionId = deviceNumber.ZoneID
  621. daySchedule.BedId = bedID
  622. daySchedule.ScheduleType = schedual_type
  623. daySchedule.UpdatedTime = time.Now().Unix()
  624. err := service.UpdateSchedule(&daySchedule)
  625. if err != nil {
  626. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  627. return
  628. }
  629. }
  630. } else if order_err != nil {
  631. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  632. return
  633. }
  634. } else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //有排班且有上机记录
  635. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  636. return
  637. }
  638. } else if err != nil {
  639. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  640. return
  641. }
  642. dialysisRecord = &models.DialysisOrder{
  643. DialysisDate: recordDate.Unix(),
  644. UserOrgId: adminUserInfo.CurrentOrgId,
  645. PatientId: patientID,
  646. Stage: 1,
  647. BedID: bedID,
  648. StartNurse: nurseID,
  649. Status: 1,
  650. StartTime: startDate.Unix(),
  651. CreatedTime: time.Now().Unix(),
  652. UpdatedTime: time.Now().Unix(),
  653. PunctureNurse: punctureNurseId,
  654. Creator: adminUserInfo.AdminUser.Id,
  655. Modifier: adminUserInfo.AdminUser.Id,
  656. SchedualType: schedual_type,
  657. WashpipeNurse: washpipe_nurse,
  658. ChangeNurse: change_nurse,
  659. DifficultPunctureNurse: difficult_puncture_nurse,
  660. NewFistulaNurse: new_fistula_nurse,
  661. }
  662. createErr := service.MobileCreateDialysisOrder(adminUserInfo.CurrentOrgId, patientID, dialysisRecord)
  663. newdialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  664. if createErr != nil {
  665. this.ErrorLog("上机失败:%v", createErr)
  666. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  667. return
  668. } else if createErr == nil {
  669. var tempdispose string
  670. // 只针对中能建
  671. if blood_drawing > 0 && adminUserInfo.CurrentOrgId == 9538 { //adminUserInfo.CurrentOrgId == 9538
  672. tempdispose = "引血" + strconv.FormatInt(blood_drawing, 10) + "ml/min"
  673. }
  674. var ultrafiltration_rate float64
  675. _, prescription := service.FindDialysisPrescriptionByReordDate(patientID, schedulestartTime, adminUserInfo.CurrentOrgId)
  676. if prescription.ID > 0 {
  677. if prescription.TargetUltrafiltration > 0 && prescription.DialysisDurationHour > 0 {
  678. totalMin := prescription.DialysisDurationHour*60 + prescription.DialysisDurationMinute
  679. if template.TemplateId == 6 || template.TemplateId == 20 || template.TemplateId == 22 || template.TemplateId == 32 {
  680. ultrafiltration_rate = math.Floor(prescription.TargetUltrafiltration / float64(totalMin) * 60 * 1000)
  681. }
  682. // 只针对方济医院
  683. if template.TemplateId == 1 && adminUserInfo.CurrentOrgId != 9849 {
  684. value, _ := strconv.ParseFloat(fmt.Sprintf("%.3f", prescription.TargetUltrafiltration/float64(totalMin)*60), 6)
  685. ultrafiltration_rate = value
  686. }
  687. }
  688. }
  689. record := models.MonitoringRecord{
  690. UserOrgId: adminUserInfo.CurrentOrgId,
  691. PatientId: patientID,
  692. DialysisOrderId: dialysisRecord.ID,
  693. MonitoringDate: schedulestartTime,
  694. OperateTime: startDate.Unix(),
  695. // MonitoringTime: recordTime,
  696. MonitoringNurse: nurseID,
  697. Dispose: tempdispose,
  698. UltrafiltrationRate: ultrafiltration_rate,
  699. UltrafiltrationVolume: 0,
  700. Status: 1,
  701. CreatedTime: time.Now().Unix(),
  702. UpdatedTime: time.Now().Unix(),
  703. }
  704. // 如果当天有插入数据,则不再往透析纪录里插入数据
  705. if newdialysisRecord.ID > 0 {
  706. err := service.CreateMonitor(&record)
  707. if err != nil {
  708. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
  709. return
  710. }
  711. }
  712. go func() {
  713. ssoDomain := beego.AppConfig.String("call_domain")
  714. api := ssoDomain + "/index/uppatient"
  715. values := make(url.Values)
  716. values.Set("org_id", strconv.FormatInt(adminUserInfo.CurrentOrgId, 10))
  717. values.Set("admin_user_id", strconv.FormatInt(nurseID, 10))
  718. values.Set("patient_id", strconv.FormatInt(patientID, 10))
  719. values.Set("up_time", strconv.FormatInt(startDate.Unix(), 10))
  720. http.PostForm(api, values)
  721. }()
  722. this.ServeSuccessJSON(map[string]interface{}{
  723. "dialysis_order": dialysisRecord,
  724. "monitor": record,
  725. })
  726. }
  727. }
  728. // /api/dialysis/finish [post]
  729. // @param patient_id:int
  730. // @param date:string 排班时间 (yyyy-mm-dd)
  731. // @param nurse:int 下机护士
  732. func (this *DialysisRecordAPIController) FinishDialysis() {
  733. patientID, _ := this.GetInt64("patient_id")
  734. recordDateStr := this.GetString("date")
  735. nurseID, _ := this.GetInt64("nurse")
  736. end_time := this.GetString("end_time")
  737. if patientID <= 0 || len(recordDateStr) == 0 || nurseID <= 0 {
  738. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  739. return
  740. }
  741. recordDate, parseErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  742. if parseErr != nil {
  743. this.ErrorLog("时间解析失败:%v", parseErr)
  744. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  745. return
  746. }
  747. //if parseEndDateErr != nil {
  748. // this.ErrorLog("时间解析失败:%v", parseEndDateErr)
  749. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  750. // return
  751. //}
  752. adminUserInfo := this.GetAdminUserInfo()
  753. patient, getPatientErr := service.MobileGetPatientById(adminUserInfo.CurrentOrgId, patientID)
  754. if getPatientErr != nil {
  755. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  756. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  757. return
  758. } else if patient == nil {
  759. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  760. return
  761. }
  762. nurse, getNurseErr := service.GetAdminUserByUserID(nurseID)
  763. if getNurseErr != nil {
  764. this.ErrorLog("获取护士失败:%v", getNurseErr)
  765. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. } else if nurse == nil {
  768. this.ErrorLog("护士不存在")
  769. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  770. return
  771. }
  772. dialysisRecord, getRecordErr := service.MobileGetDialysisRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  773. if getRecordErr != nil {
  774. this.ErrorLog("获取透析记录失败:%v", getRecordErr)
  775. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  776. return
  777. }
  778. if dialysisRecord.Stage == 2 {
  779. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderNoEND)
  780. return
  781. }
  782. endDate, parseEndDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04", end_time)
  783. if parseEndDateErr != nil {
  784. this.ErrorLog("日期(%v)解析错误:%v", end_time, parseEndDateErr)
  785. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  786. return
  787. }
  788. // 获取当天的第一条透析纪录
  789. fmonitorRecords, getMonitorRecordsErr := service.MobileGetMonitorRecordFirst(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  790. if getMonitorRecordsErr != nil {
  791. this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
  792. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  793. return
  794. }
  795. // 获取当前的最后一条透析纪录
  796. endmonitorRecords, getMonitorRecordsErr := service.MobileGetLastMonitorRecord(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  797. if getMonitorRecordsErr != nil {
  798. this.ErrorLog("获取透析监测记录失败:%v", getMonitorRecordsErr)
  799. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  800. return
  801. }
  802. assessmentAfterDislysis, getAADErr := service.MobileGetAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  803. if getAADErr != nil {
  804. this.ErrorLog("获取透后评估失败:%v", getAADErr)
  805. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  806. return
  807. }
  808. lastAssessmentAfterDislysis, _ := service.MobileGetLastTimeAssessmentAfterDislysis(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  809. var tempassessmentAfterDislysis models.AssessmentAfterDislysis
  810. if assessmentAfterDislysis != nil {
  811. tempassessmentAfterDislysis = *assessmentAfterDislysis
  812. tempassessmentAfterDislysis.UpdatedTime = time.Now().Unix()
  813. } else {
  814. tempassessmentAfterDislysis.CreatedTime = time.Now().Unix()
  815. tempassessmentAfterDislysis.AssessmentDate = recordDate.Unix()
  816. tempassessmentAfterDislysis.Status = 1
  817. tempassessmentAfterDislysis.PatientId = patientID
  818. tempassessmentAfterDislysis.UserOrgId = adminUserInfo.CurrentOrgId
  819. }
  820. if dialysisRecord.Stage == 1 {
  821. temp_time := (float64(endDate.Unix()) - float64(dialysisRecord.StartTime)) / 3600
  822. value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
  823. fmt.Println(value)
  824. a, b := math.Modf(value)
  825. c, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
  826. hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
  827. minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", c*60), 10, 64)
  828. fmt.Println(hour)
  829. fmt.Println(minute)
  830. tempassessmentAfterDislysis.ActualTreatmentHour = hour
  831. tempassessmentAfterDislysis.ActualTreatmentMinute = minute
  832. }
  833. if fmonitorRecords.ID > 0 && endmonitorRecords.ID > 0 {
  834. tempassessmentAfterDislysis.Temperature = endmonitorRecords.Temperature
  835. tempassessmentAfterDislysis.PulseFrequency = endmonitorRecords.PulseFrequency
  836. tempassessmentAfterDislysis.BreathingRate = endmonitorRecords.BreathingRate
  837. tempassessmentAfterDislysis.SystolicBloodPressure = endmonitorRecords.SystolicBloodPressure
  838. tempassessmentAfterDislysis.DiastolicBloodPressure = endmonitorRecords.DiastolicBloodPressure
  839. tempassessmentAfterDislysis.ActualUltrafiltration = endmonitorRecords.UltrafiltrationVolume
  840. tempassessmentAfterDislysis.ActualDisplacement = endmonitorRecords.DisplacementQuantity
  841. }
  842. if adminUserInfo.CurrentOrgId == 9583 {
  843. //获取最后一条透析处方数据
  844. prescription, parseErr := service.GetLastDialysisPrescriptionByPatientId(adminUserInfo.CurrentOrgId, patientID, recordDate.Unix())
  845. if parseErr != nil {
  846. this.ErrorLog("获取透析处方失败:%v", getMonitorRecordsErr)
  847. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  848. return
  849. }
  850. if prescription.ID > 0 && adminUserInfo.CurrentOrgId == 9583 {
  851. tempassessmentAfterDislysis.ActualUltrafiltration = prescription.TargetUltrafiltration
  852. }
  853. }
  854. if lastAssessmentAfterDislysis != nil {
  855. tempassessmentAfterDislysis.BloodPressureType = lastAssessmentAfterDislysis.BloodPressureType
  856. tempassessmentAfterDislysis.WeighingWay = lastAssessmentAfterDislysis.WeighingWay
  857. tempassessmentAfterDislysis.Cruor = lastAssessmentAfterDislysis.Cruor
  858. tempassessmentAfterDislysis.SymptomAfterDialysis = lastAssessmentAfterDislysis.SymptomAfterDialysis
  859. tempassessmentAfterDislysis.InternalFistula = lastAssessmentAfterDislysis.InternalFistula
  860. tempassessmentAfterDislysis.Catheter = lastAssessmentAfterDislysis.Catheter
  861. tempassessmentAfterDislysis.Complication = lastAssessmentAfterDislysis.Complication
  862. tempassessmentAfterDislysis.DialysisIntakes = lastAssessmentAfterDislysis.DialysisIntakes
  863. tempassessmentAfterDislysis.DialysisIntakesFeed = lastAssessmentAfterDislysis.DialysisIntakesFeed
  864. tempassessmentAfterDislysis.DialysisIntakesTransfusion = lastAssessmentAfterDislysis.DialysisIntakesTransfusion
  865. tempassessmentAfterDislysis.DialysisIntakesBloodTransfusion = lastAssessmentAfterDislysis.DialysisIntakesBloodTransfusion
  866. tempassessmentAfterDislysis.DialysisIntakesWashpipe = lastAssessmentAfterDislysis.DialysisIntakesWashpipe
  867. tempassessmentAfterDislysis.BloodAccessPartId = lastAssessmentAfterDislysis.BloodAccessPartId
  868. tempassessmentAfterDislysis.BloodAccessPartOperaId = lastAssessmentAfterDislysis.BloodAccessPartOperaId
  869. tempassessmentAfterDislysis.PuncturePointOozingBlood = lastAssessmentAfterDislysis.PuncturePointOozingBlood
  870. tempassessmentAfterDislysis.PuncturePointHaematoma = lastAssessmentAfterDislysis.PuncturePointHaematoma
  871. tempassessmentAfterDislysis.InternalFistulaTremorAc = lastAssessmentAfterDislysis.InternalFistulaTremorAc
  872. tempassessmentAfterDislysis.PatientGose = lastAssessmentAfterDislysis.PatientGose
  873. tempassessmentAfterDislysis.InpatientDepartment = lastAssessmentAfterDislysis.InpatientDepartment
  874. tempassessmentAfterDislysis.ObservationContent = lastAssessmentAfterDislysis.ObservationContent
  875. tempassessmentAfterDislysis.ObservationContentOther = lastAssessmentAfterDislysis.ObservationContentOther
  876. tempassessmentAfterDislysis.DryWeight = lastAssessmentAfterDislysis.DryWeight
  877. tempassessmentAfterDislysis.DialysisProcess = lastAssessmentAfterDislysis.DialysisProcess
  878. tempassessmentAfterDislysis.InAdvanceMinute = lastAssessmentAfterDislysis.InAdvanceMinute
  879. tempassessmentAfterDislysis.InAdvanceReason = lastAssessmentAfterDislysis.InAdvanceReason
  880. tempassessmentAfterDislysis.HemostasisMinute = lastAssessmentAfterDislysis.HemostasisMinute
  881. tempassessmentAfterDislysis.HemostasisOpera = lastAssessmentAfterDislysis.HemostasisOpera
  882. tempassessmentAfterDislysis.TremorNoise = lastAssessmentAfterDislysis.TremorNoise
  883. tempassessmentAfterDislysis.DisequilibriumSyndrome = lastAssessmentAfterDislysis.DisequilibriumSyndrome
  884. tempassessmentAfterDislysis.DisequilibriumSyndromeOption = lastAssessmentAfterDislysis.DisequilibriumSyndromeOption
  885. tempassessmentAfterDislysis.ArterialTube = lastAssessmentAfterDislysis.ArterialTube
  886. tempassessmentAfterDislysis.IntravenousTube = lastAssessmentAfterDislysis.IntravenousTube
  887. tempassessmentAfterDislysis.Dialyzer = lastAssessmentAfterDislysis.Dialyzer
  888. tempassessmentAfterDislysis.InAdvanceReasonOther = lastAssessmentAfterDislysis.InAdvanceReasonOther
  889. tempassessmentAfterDislysis.IsEat = lastAssessmentAfterDislysis.IsEat
  890. tempassessmentAfterDislysis.DialysisIntakesUnit = lastAssessmentAfterDislysis.DialysisIntakesUnit
  891. tempassessmentAfterDislysis.CvcA = lastAssessmentAfterDislysis.CvcA
  892. tempassessmentAfterDislysis.CvcV = lastAssessmentAfterDislysis.CvcV
  893. tempassessmentAfterDislysis.Channel = lastAssessmentAfterDislysis.Channel
  894. tempassessmentAfterDislysis.ReturnBlood = lastAssessmentAfterDislysis.ReturnBlood
  895. tempassessmentAfterDislysis.RehydrationVolume = lastAssessmentAfterDislysis.RehydrationVolume
  896. tempassessmentAfterDislysis.DialysisDuring = lastAssessmentAfterDislysis.DialysisDuring
  897. tempassessmentAfterDislysis.StrokeVolume = lastAssessmentAfterDislysis.StrokeVolume
  898. tempassessmentAfterDislysis.BloodFlow = lastAssessmentAfterDislysis.BloodFlow
  899. tempassessmentAfterDislysis.SealingFluidDispose = lastAssessmentAfterDislysis.SealingFluidDispose
  900. tempassessmentAfterDislysis.SealingFluidSpecial = lastAssessmentAfterDislysis.SealingFluidSpecial
  901. }
  902. err := service.UpdateAssessmentAfterDislysisRecord(&tempassessmentAfterDislysis)
  903. if err != nil {
  904. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  905. return
  906. }
  907. go func() {
  908. ssoDomain := beego.AppConfig.String("call_domain")
  909. api := ssoDomain + "/index/downpatient"
  910. values := make(url.Values)
  911. values.Set("org_id", strconv.FormatInt(adminUserInfo.CurrentOrgId, 10))
  912. values.Set("admin_user_id", strconv.FormatInt(nurseID, 10))
  913. values.Set("patient_id", strconv.FormatInt(patientID, 10))
  914. http.PostForm(api, values)
  915. }()
  916. updateErr := service.ModifyDialysisRecord(dialysisRecord.ID, nurseID, endDate.Unix(), adminUserInfo.AdminUser.Id)
  917. if updateErr != nil {
  918. this.ErrorLog("下机失败:%v", updateErr)
  919. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  920. return
  921. } else {
  922. dialysisRecord.Stage = 2
  923. dialysisRecord.FinishNurse = nurseID
  924. dialysisRecord.FinishCreator = adminUserInfo.AdminUser.Id
  925. dialysisRecord.FinishModifier = adminUserInfo.AdminUser.Id
  926. dialysisRecord.EndTime = endDate.Unix()
  927. // 结束时候透析次数加1
  928. service.UpdateSolutionByPatientId(patientID)
  929. this.ServeSuccessJSON(map[string]interface{}{
  930. "dialysis_order": dialysisRecord,
  931. "assessmentAfterDislysis": tempassessmentAfterDislysis,
  932. })
  933. }
  934. }
  935. func (this *DialysisRecordAPIController) ModifyStartDialysis() {
  936. record_id, _ := this.GetInt64("id")
  937. nurseID, _ := this.GetInt64("nurse")
  938. puncture_nurse, _ := this.GetInt64("puncture_nurse")
  939. bedID, _ := this.GetInt64("bed")
  940. start_time := this.GetString("start_time")
  941. washpipe_nurse, _ := this.GetInt64("washpipe_nurse")
  942. schedual_type, _ := this.GetInt64("schedual_type")
  943. change_nurse, _ := this.GetInt64("change_nurse")
  944. difficult_puncture_nurse, _ := this.GetInt64("difficult_puncture_nurse")
  945. new_fistula_nurse, _ := this.GetInt64("new_fistula_nurse")
  946. if record_id == 0 {
  947. this.ErrorLog("id:%v", record_id)
  948. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  949. return
  950. }
  951. startDate, parseStartDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04", start_time)
  952. if parseStartDateErr != nil {
  953. this.ErrorLog("时间解析失败:%v", parseStartDateErr)
  954. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  955. return
  956. }
  957. adminUserInfo := this.GetAdminUserInfo()
  958. nurse, getNurseErr := service.GetAdminUserByUserID(nurseID)
  959. if getNurseErr != nil {
  960. this.ErrorLog("获取护士失败:%v", getNurseErr)
  961. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  962. return
  963. } else if nurse == nil {
  964. this.ErrorLog("护士不存在")
  965. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  966. return
  967. }
  968. //nurse, getNurseErr = service.GetAdminUserByUserID(puncture_nurse)
  969. //if getNurseErr != nil {
  970. // this.ErrorLog("获取护士失败:%v", getNurseErr)
  971. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  972. // return
  973. //} else if nurse == nil {
  974. // this.ErrorLog("护士不存在")
  975. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  976. // return
  977. //}
  978. deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.CurrentOrgId, bedID)
  979. if getDeviceNumberErr != nil {
  980. this.ErrorLog("获取床位号失败:%v", getDeviceNumberErr)
  981. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  982. return
  983. } else if deviceNumber == nil {
  984. this.ErrorLog("床位号不存在")
  985. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  986. return
  987. }
  988. _, tempDialysisRecord := service.FindDialysisOrderById(record_id)
  989. //if tempDialysisRecord.Creator != adminUserInfo.AdminUser.Id {
  990. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  991. // if getPermissionErr != nil {
  992. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  993. // return
  994. // } else if headNursePermission == nil {
  995. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  996. // return
  997. // }
  998. //}
  999. scheduleDateStart := startDate.Format("2006-01-02") + " 00:00:00"
  1000. scheduleDateEnd := startDate.Format("2006-01-02") + " 23:59:59"
  1001. timeLayout := "2006-01-02 15:04:05"
  1002. loc, _ := time.LoadLocation("Local")
  1003. theStartTime, _ := time.ParseInLocation(timeLayout, scheduleDateStart, loc)
  1004. theEndTime, _ := time.ParseInLocation(timeLayout, scheduleDateEnd, loc)
  1005. schedulestartTime := theStartTime.Unix()
  1006. scheduleendTime := theEndTime.Unix()
  1007. //查询更改的机号,是否有人用了,如果只是排班了,但是没上机,直接替换,如果排班且上机了,就提示他无法上机
  1008. schedule, err := service.GetDayScheduleByBedid(adminUserInfo.CurrentOrgId, schedulestartTime, bedID, schedual_type)
  1009. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, tempDialysisRecord.PatientId)
  1010. if daySchedule.BedId != bedID || daySchedule.ScheduleType != schedual_type {
  1011. if err == gorm.ErrRecordNotFound { //空床位
  1012. // 修改了床位逻辑
  1013. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, tempDialysisRecord.PatientId)
  1014. if daySchedule.ID > 0 {
  1015. daySchedule.BedId = bedID
  1016. daySchedule.PartitionId = deviceNumber.ZoneID
  1017. daySchedule.ScheduleType = schedual_type
  1018. daySchedule.UpdatedTime = time.Now().Unix()
  1019. err := service.UpdateSchedule(&daySchedule)
  1020. if err != nil {
  1021. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1022. return
  1023. }
  1024. }
  1025. } else if err == nil {
  1026. if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //有排班没上机记录
  1027. daySchedule, _ := service.GetDaySchedule(adminUserInfo.CurrentOrgId, schedulestartTime, scheduleendTime, tempDialysisRecord.PatientId)
  1028. if daySchedule.ID > 0 {
  1029. daySchedule.BedId = bedID
  1030. daySchedule.PartitionId = deviceNumber.ZoneID
  1031. daySchedule.ScheduleType = schedual_type
  1032. daySchedule.UpdatedTime = time.Now().Unix()
  1033. err := service.UpdateSchedule(&daySchedule)
  1034. if err != nil {
  1035. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1036. return
  1037. }
  1038. }
  1039. } else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //有排班且有上机记录
  1040. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  1041. return
  1042. }
  1043. } else if err != nil {
  1044. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1045. return
  1046. }
  1047. }
  1048. dialysisRecord := &models.DialysisOrder{
  1049. ID: record_id,
  1050. UserOrgId: adminUserInfo.CurrentOrgId,
  1051. BedID: bedID,
  1052. StartNurse: nurseID,
  1053. StartTime: startDate.Unix(),
  1054. PunctureNurse: puncture_nurse,
  1055. Creator: adminUserInfo.AdminUser.Id,
  1056. Modifier: adminUserInfo.AdminUser.Id,
  1057. SchedualType: schedual_type,
  1058. WashpipeNurse: washpipe_nurse,
  1059. ChangeNurse: change_nurse,
  1060. DifficultPunctureNurse: difficult_puncture_nurse,
  1061. NewFistulaNurse: new_fistula_nurse,
  1062. }
  1063. updateErr := service.ModifyStartDialysisOrder(dialysisRecord)
  1064. if updateErr != nil {
  1065. this.ErrorLog("修改上机失败:%v", updateErr)
  1066. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1067. return
  1068. }
  1069. if updateErr == nil {
  1070. if tempDialysisRecord.Stage == 2 {
  1071. temp_time := (float64(tempDialysisRecord.EndTime) - float64(startDate.Unix())) / 3600
  1072. value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
  1073. fmt.Println(value)
  1074. a, b := math.Modf(value)
  1075. tempMinute, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
  1076. hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
  1077. minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
  1078. updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecord.PatientId, tempDialysisRecord.UserOrgId, tempDialysisRecord.DialysisDate, hour, minute)
  1079. if updateAssessmentErr != nil {
  1080. utils.ErrorLog("%v", updateAssessmentErr)
  1081. }
  1082. after, _ := service.FindAssessmentAfterDislysisById(tempDialysisRecord.UserOrgId, tempDialysisRecord.PatientId, tempDialysisRecord.DialysisDate)
  1083. _, dialysisRecords := service.FindDialysisOrderById(record_id)
  1084. this.ServeSuccessJSON(map[string]interface{}{
  1085. "dialysis_order": dialysisRecords,
  1086. "after": after,
  1087. })
  1088. } else {
  1089. _, dialysisRecords := service.FindDialysisOrderById(record_id)
  1090. this.ServeSuccessJSON(map[string]interface{}{
  1091. "dialysis_order": dialysisRecords,
  1092. })
  1093. }
  1094. }
  1095. }
  1096. func (c *DialysisRecordAPIController) ModifyFinishDialysis() {
  1097. record_id, _ := c.GetInt64("id")
  1098. nurseID, _ := c.GetInt64("nurse")
  1099. end_time := c.GetString("end_time")
  1100. if record_id <= 0 || nurseID <= 0 {
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1102. return
  1103. }
  1104. adminUserInfo := c.GetAdminUserInfo()
  1105. nurse, getNurseErr := service.GetAdminUserByUserID(nurseID)
  1106. if getNurseErr != nil {
  1107. c.ErrorLog("获取护士失败:%v", getNurseErr)
  1108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1109. return
  1110. } else if nurse == nil {
  1111. c.ErrorLog("护士不存在")
  1112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1113. return
  1114. }
  1115. endDate, parseEndDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04", end_time)
  1116. if parseEndDateErr != nil {
  1117. c.ErrorLog("日期(%v)解析错误:%v", end_time, parseEndDateErr)
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1119. return
  1120. }
  1121. _, tempDialysisRecords := service.FindDialysisOrderById(record_id)
  1122. //if tempDialysisRecords.FinishCreator != adminUserInfo.AdminUser.Id {
  1123. // headNursePermission, getPermissionErr := service.GetAdminUserSpecialPermission(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId, adminUserInfo.AdminUser.Id, models.SpecialPermissionTypeHeadNurse)
  1124. // if getPermissionErr != nil {
  1125. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1126. // return
  1127. // } else if headNursePermission == nil {
  1128. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisPermissionDeniedModify)
  1129. // return
  1130. // }
  1131. //}
  1132. dialysisRecord := &models.DialysisOrder{
  1133. ID: record_id,
  1134. UserOrgId: adminUserInfo.CurrentOrgId,
  1135. EndTime: endDate.Unix(),
  1136. FinishNurse: nurseID,
  1137. FinishModifier: adminUserInfo.AdminUser.Id,
  1138. }
  1139. updateErr := service.ModifyFinishDialysisOrder(dialysisRecord)
  1140. if updateErr != nil {
  1141. c.ErrorLog("修改下机失败:%v", updateErr)
  1142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1143. return
  1144. }
  1145. if updateErr == nil {
  1146. temp_time := (float64(endDate.Unix()) - float64(tempDialysisRecords.StartTime)) / 3600
  1147. value, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", temp_time), 64)
  1148. fmt.Println(value)
  1149. a, b := math.Modf(value)
  1150. tempMinute, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", b), 64)
  1151. hour, _ := strconv.ParseInt(fmt.Sprintf("%.0f", a), 10, 64)
  1152. minute, _ := strconv.ParseInt(fmt.Sprintf("%.0f", tempMinute*60), 10, 64)
  1153. updateAssessmentErr := service.UpdateAssessmentAfterDate(tempDialysisRecords.PatientId, tempDialysisRecords.UserOrgId, tempDialysisRecords.DialysisDate, hour, minute)
  1154. if updateAssessmentErr != nil {
  1155. utils.ErrorLog("%v", updateAssessmentErr)
  1156. }
  1157. }
  1158. after, _ := service.FindAssessmentAfterDislysisById(tempDialysisRecords.UserOrgId, tempDialysisRecords.PatientId, tempDialysisRecords.DialysisDate)
  1159. _, dialysisRecords := service.FindDialysisOrderById(record_id)
  1160. c.ServeSuccessJSON(map[string]interface{}{
  1161. "dialysis_order": dialysisRecords,
  1162. "after": after,
  1163. })
  1164. }