dialysis_api_controller_extend.go 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. package mobile_api_controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "fmt"
  8. "github.com/jinzhu/gorm"
  9. "time"
  10. )
  11. // /m/api/monitor/add [post]
  12. // @param patient_id:int
  13. // @param order_id?:int 透析记录 ID
  14. // @param date?:int 日期(10位时间戳)
  15. // @param operate_time?:int 实际测量日期(10位时间戳)
  16. // @param time?:string 时间(hh:mm) 废弃
  17. // @param pulse_frequency?:float 脉率(P)(次/min)
  18. // @param breathing_rated?:float 呼吸频率(R)(次/min)
  19. // @param systolic_bp?:float 收缩压
  20. // @param diastolic_bp?:float 舒张压
  21. // @param bp_type?:int 血压测量类型
  22. // @param blood_flow_volume?:float 血流量(ml/min)
  23. // @param venous_pressure?:float 静脉压
  24. // @param venous_pressure_unit?:string 静脉压单位
  25. // @param arterial_pressure?:float 动脉压
  26. // @param transmembrane_pressure?:float 跨膜压
  27. // @param transmembrane_pressure_unit?:string 跨膜压单位
  28. // @param ultrafiltration_rate?:float 超滤率(ml/h)
  29. // @param ultrafiltration_volume?:float 超滤量(ml)
  30. // @param sodium_concentration?:float 钠浓度(mmol/L)
  31. // @param dialysate_temperature?:float 透析液温度(℃)
  32. // @param replacement_rate?:float 置换率(ml/min)
  33. // @param displacement_quantity?:float 置换量(L)
  34. // @param ktv?:float KT/V(在线)
  35. // @param symptom?:string 症状
  36. // @param dispose?:string 处理
  37. // @param result?:string 结果
  38. // @param monitoring_nurse?:int 监测人
  39. func (this *DialysisAPIController) AddMonitorRecord() {
  40. patientID, _ := this.GetInt64("patient_id")
  41. if patientID <= 0 {
  42. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  43. return
  44. }
  45. orderID, _ := this.GetInt64("order_id")
  46. if orderID < 0 {
  47. orderID = 0
  48. }
  49. date, _ := this.GetInt64("date")
  50. operateTime, _ := this.GetInt64("operate_time")
  51. // recordTime := this.GetString("time")
  52. if date <= 0 || operateTime <= 0 {
  53. date = 0
  54. operateTime = 0
  55. // recordTime = ""
  56. }
  57. fmt.Println(date)
  58. fmt.Println(operateTime)
  59. pulseFrequency, _ := this.GetFloat("pulse_frequency")
  60. breathingRated, _ := this.GetFloat("breathing_rated")
  61. systolicBP, _ := this.GetFloat("systolic_bp")
  62. diastolicBP, _ := this.GetFloat("diastolic_bp")
  63. BPType, _ := this.GetInt("bp_type")
  64. bloodFlowVolume, _ := this.GetFloat("blood_flow_volume")
  65. venousPressure, _ := this.GetFloat("venous_pressure")
  66. venousPressureType,_ := this.GetInt64("venous_pressure_type",1)
  67. arterialPressure, _ := this.GetFloat("arterial_pressure")
  68. arterialPressureType, _ := this.GetInt64("arterial_pressure_type",1)
  69. transmembranePressure, _ := this.GetFloat("transmembrane_pressure",0)
  70. transmembranePressureType,_ := this.GetInt64("transmembrane_pressure_type",1)
  71. ultrafiltrationRate, _ := this.GetFloat("ultrafiltration_rate")
  72. ultrafiltrationVolume, _ := this.GetFloat("ultrafiltration_volume")
  73. sodiumConcentration, _ := this.GetFloat("sodium_concentration")
  74. dialysateTemperature, _ := this.GetFloat("dialysate_temperature")
  75. temperature, _ := this.GetFloat("temperature")
  76. replacementRate, _ := this.GetFloat("replacement_rate")
  77. displacementQuantity, _ := this.GetFloat("displacement_quantity")
  78. ktv, _ := this.GetFloat("ktv")
  79. symptom := this.GetString("symptom")
  80. dispose := this.GetString("dispose")
  81. conductivity, _ := this.GetFloat("conductivity")
  82. displacement_flow_quantity, _ := this.GetFloat("displacement_flow_quantity")
  83. blood_oxygen_saturation := this.GetString("blood_oxygen_saturation")
  84. result := this.GetString("result")
  85. monitoringNurse, _ := this.GetInt64("monitoring_nurse")
  86. heparin, _ := this.GetFloat("heparin")
  87. dialysate_flow, _ := this.GetFloat("dialysate_flow")
  88. adminInfo := this.GetMobileAdminUserInfo()
  89. patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
  90. if getPatientErr != nil {
  91. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  92. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  93. return
  94. } else if patient == nil {
  95. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  96. return
  97. }
  98. record := models.MonitoringRecord{
  99. UserOrgId: adminInfo.Org.Id,
  100. PatientId: patientID,
  101. DialysisOrderId: orderID,
  102. MonitoringDate: date,
  103. OperateTime: operateTime,
  104. // MonitoringTime: recordTime,
  105. PulseFrequency: pulseFrequency,
  106. BreathingRate: breathingRated,
  107. SystolicBloodPressure: systolicBP,
  108. DiastolicBloodPressure: diastolicBP,
  109. BloodPressureType: int64(BPType),
  110. BloodFlowVolume: bloodFlowVolume,
  111. VenousPressure: venousPressure,
  112. VenousPressureType: venousPressureType,
  113. ArterialPressure: arterialPressure,
  114. ArterialPressureType: arterialPressureType,
  115. TransmembranePressure: transmembranePressure,
  116. TransmembranePressureType: transmembranePressureType,
  117. UltrafiltrationRate: ultrafiltrationRate,
  118. UltrafiltrationVolume: ultrafiltrationVolume,
  119. SodiumConcentration: sodiumConcentration,
  120. DialysateTemperature: dialysateTemperature,
  121. Temperature: temperature,
  122. ReplacementRate: replacementRate,
  123. DisplacementQuantity: displacementQuantity,
  124. Ktv: ktv,
  125. Symptom: symptom,
  126. Dispose: dispose,
  127. Result: result,
  128. MonitoringNurse: monitoringNurse,
  129. Status: 1,
  130. CreatedTime: time.Now().Unix(),
  131. UpdatedTime: time.Now().Unix(),
  132. Conductivity: conductivity,
  133. DisplacementFlowQuantity: displacement_flow_quantity,
  134. BloodOxygenSaturation: blood_oxygen_saturation,
  135. Creator: adminInfo.AdminUser.Id,
  136. Modify: 0,
  137. Heparin: heparin,
  138. DialysateFlow: dialysate_flow,
  139. }
  140. err := service.CreateMonitor(&record)
  141. if err != nil {
  142. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
  143. return
  144. }
  145. this.ServeSuccessJSON(map[string]interface{}{
  146. "monitor": record,
  147. })
  148. }
  149. // /m/api/monitor/edit [post]
  150. // @param patient_id:int
  151. // @param order_id?:int 透析记录 ID
  152. // @param date?:int 日期(10位时间戳)
  153. // @param operate_time?:int 实际测量日期(10位时间戳)
  154. // @param time?:string 时间(hh:mm)废弃
  155. // @param pulse_frequency?:float 脉率(P)(次/min)
  156. // @param breathing_rated?:float 呼吸频率(R)(次/min)
  157. // @param systolic_bp?:float 收缩压
  158. // @param diastolic_bp?:float 舒张压
  159. // @param bp_type?:int 血压测量类型
  160. // @param blood_flow_volume?:float 血流量(ml/min)
  161. // @param venous_pressure?:float 静脉压
  162. // @param venous_pressure_unit?:string 静脉压单位
  163. // @param arterial_pressure?:float 动脉压
  164. // @param transmembrane_pressure?:float 跨膜压
  165. // @param transmembrane_pressure_unit?:string 跨膜压单位
  166. // @param ultrafiltration_rate?:float 超滤率(ml/h)
  167. // @param ultrafiltration_volume?:float 超滤量(ml)
  168. // @param sodium_concentration?:float 钠浓度(mmol/L)
  169. // @param dialysate_temperature?:float 透析液温度(℃)
  170. // @param replacement_rate?:float 置换率(ml/min)
  171. // @param displacement_quantity?:float 置换量(L)
  172. // @param ktv?:float KT/V(在线)
  173. // @param symptom?:string 症状
  174. // @param dispose?:string 处理
  175. // @param result?:string 结果
  176. // @param monitoring_nurse?:int 监测人
  177. func (this *DialysisAPIController) EditMonitorRecord() {
  178. patientID, _ := this.GetInt64("patient_id")
  179. if patientID <= 0 {
  180. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  181. return
  182. }
  183. id, _ := this.GetInt64("id")
  184. if id <= 0 {
  185. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  186. return
  187. }
  188. orderID, _ := this.GetInt64("order_id")
  189. if orderID < 0 {
  190. orderID = 0
  191. }
  192. date, _ := this.GetInt64("date")
  193. operateTime, _ := this.GetInt64("operate_time")
  194. if date <= 0 {
  195. date = 0
  196. operateTime = 0
  197. }
  198. pulseFrequency, _ := this.GetFloat("pulse_frequency")
  199. breathingRated, _ := this.GetFloat("breathing_rated")
  200. systolicBP, _ := this.GetFloat("systolic_bp")
  201. diastolicBP, _ := this.GetFloat("diastolic_bp")
  202. BPType, _ := this.GetInt("bp_type")
  203. bloodFlowVolume, _ := this.GetFloat("blood_flow_volume")
  204. venousPressure, _ := this.GetFloat("venous_pressure")
  205. venousPressureType,_ := this.GetInt64("venous_pressure_type",1)
  206. arterialPressure, _ := this.GetFloat("arterial_pressure")
  207. arterialPressureType, _ := this.GetInt64("arterial_pressure",1)
  208. transmembranePressure, _ := this.GetFloat("transmembrane_pressure")
  209. transmembranePressureType,_ := this.GetInt64("transmembrane_pressure_type",1)
  210. ultrafiltrationRate, _ := this.GetFloat("ultrafiltration_rate")
  211. ultrafiltrationVolume, _ := this.GetFloat("ultrafiltration_volume")
  212. sodiumConcentration, _ := this.GetFloat("sodium_concentration")
  213. dialysateTemperature, _ := this.GetFloat("dialysate_temperature")
  214. temperature, _ := this.GetFloat("temperature")
  215. replacementRate, _ := this.GetFloat("replacement_rate")
  216. displacementQuantity, _ := this.GetFloat("displacement_quantity")
  217. ktv, _ := this.GetFloat("ktv")
  218. symptom := this.GetString("symptom")
  219. dispose := this.GetString("dispose")
  220. result := this.GetString("result")
  221. blood_oxygen_saturation := this.GetString("blood_oxygen_saturation")
  222. monitoringNurse, _ := this.GetInt64("monitoring_nurse")
  223. conductivity, _ := this.GetFloat("conductivity")
  224. displacement_flow_quantity, _ := this.GetFloat("displacement_flow_quantity")
  225. heparin, _ := this.GetFloat("heparin")
  226. dialysate_flow, _ := this.GetFloat("dialysate_flow")
  227. adminInfo := this.GetMobileAdminUserInfo()
  228. monitor, err := service.GetMonitor(adminInfo.Org.Id, patientID, id)
  229. if err != nil {
  230. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  231. return
  232. }
  233. if monitor == nil {
  234. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorNotExist)
  235. return
  236. }
  237. monitor.Conductivity = conductivity
  238. monitor.DialysisOrderId = orderID
  239. monitor.MonitoringDate = date
  240. monitor.OperateTime = operateTime
  241. monitor.PulseFrequency = pulseFrequency
  242. monitor.BreathingRate = breathingRated
  243. monitor.SystolicBloodPressure = systolicBP
  244. monitor.DiastolicBloodPressure = diastolicBP
  245. monitor.BloodPressureType = int64(BPType)
  246. monitor.BloodFlowVolume = bloodFlowVolume
  247. monitor.VenousPressure = venousPressure
  248. monitor.VenousPressureType = venousPressureType
  249. monitor.ArterialPressure = arterialPressure
  250. monitor.ArterialPressureType = arterialPressureType
  251. monitor.TransmembranePressure = transmembranePressure
  252. monitor.TransmembranePressureType = transmembranePressureType
  253. monitor.UltrafiltrationRate = ultrafiltrationRate
  254. monitor.UltrafiltrationVolume = ultrafiltrationVolume
  255. monitor.SodiumConcentration = sodiumConcentration
  256. monitor.DialysateTemperature = dialysateTemperature
  257. monitor.Temperature = temperature
  258. monitor.ReplacementRate = replacementRate
  259. monitor.DisplacementQuantity = displacementQuantity
  260. monitor.Ktv = ktv
  261. monitor.Symptom = symptom
  262. monitor.Dispose = dispose
  263. monitor.Result = result
  264. monitor.MonitoringNurse = monitoringNurse
  265. monitor.Status = 1
  266. monitor.UpdatedTime = time.Now().Unix()
  267. monitor.DisplacementFlowQuantity = displacement_flow_quantity
  268. monitor.BloodOxygenSaturation = blood_oxygen_saturation
  269. monitor.Modify = adminInfo.AdminUser.Id
  270. monitor.Heparin = heparin
  271. monitor.DialysateFlow = dialysate_flow
  272. err = service.UpdateMonitor(monitor)
  273. if err != nil {
  274. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)
  275. return
  276. }
  277. this.ServeSuccessJSON(map[string]interface{}{
  278. "monitor": monitor,
  279. })
  280. }
  281. // /m/api/monitor/delete [post]
  282. // @param record_id:int
  283. // @param patient_id:int
  284. func (this *DialysisAPIController) DeleteMonitor() {
  285. recordID, _ := this.GetInt64("record_id")
  286. patientID, _ := this.GetInt64("patient_id")
  287. if recordID <= 0 || patientID <= 0 {
  288. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  289. return
  290. }
  291. adminInfo := this.GetMobileAdminUserInfo()
  292. patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
  293. if getPatientErr != nil {
  294. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  295. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  296. return
  297. } else if patient == nil {
  298. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  299. return
  300. }
  301. monitor, getMonitorErr := service.GetMonitor(adminInfo.Org.Id, patientID, recordID)
  302. if getMonitorErr != nil {
  303. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  304. return
  305. }
  306. err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
  307. if err != nil {
  308. this.ErrorLog("删除透析监测记录失败:%v", err)
  309. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
  310. return
  311. }
  312. this.ServeSuccessJSON(map[string]interface{}{
  313. "record_id": monitor.ID,
  314. })
  315. }
  316. // /m/api/schedule/urgentinit [get]
  317. func (this *DialysisAPIController) UrgentScheduleInitData() {
  318. schedule_type, _ := this.GetInt("type", 0)
  319. adminUserInfo := this.GetMobileAdminUserInfo()
  320. today := utils.ZeroHourTimeOfDay(time.Now())
  321. //获取所有病人且没有上机记录的病人
  322. patients, getPatientsErr := service.MobileGetAllPatientsForUrgentSchedule(adminUserInfo.Org.Id, today.Unix())
  323. if getPatientsErr != nil {
  324. this.ErrorLog("获取所有患者失败:%v", getPatientsErr)
  325. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  326. return
  327. }
  328. modes, getModesErr := service.MobileGetAllTrearmentModesForUrgentSchedule()
  329. if getModesErr != nil {
  330. this.ErrorLog("获取所有治疗模式失败:%v", getModesErr)
  331. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  332. return
  333. }
  334. deviceNumbers, getDeviceNumbersErr := service.GetAllAvaildDeviceNumbers(adminUserInfo.Org.Id, today.Unix(), schedule_type)
  335. if getDeviceNumbersErr != nil {
  336. this.ErrorLog("获取所有床位失败:%v", getDeviceNumbersErr)
  337. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  338. return
  339. }
  340. schedules, getSchedulesErr := service.MobileGetOtherSchedulesForUrgentSchedule(adminUserInfo.Org.Id, today.Unix(), schedule_type)
  341. if getSchedulesErr != nil {
  342. this.ErrorLog("获取所有排班失败:%v", getSchedulesErr)
  343. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  344. return
  345. }
  346. this.ServeSuccessJSON(map[string]interface{}{
  347. "patients": patients,
  348. "modes": modes,
  349. "device_numbers": deviceNumbers,
  350. "schedules": schedules,
  351. })
  352. }
  353. // /m/api/schedule/urgentadd [post]
  354. // @param patient_id:int
  355. // @param schedule_type:int
  356. // @param mode:int
  357. // @param bed:int
  358. func (this *DialysisAPIController) AddUrgentSchedule() {
  359. patientID, _ := this.GetInt64("patient_id")
  360. scheduleType, _ := this.GetInt64("schedule_type")
  361. modeID, _ := this.GetInt64("mode")
  362. bedID, _ := this.GetInt64("bed")
  363. if patientID <= 0 || scheduleType < 1 || scheduleType > 3 || modeID < 1 || modeID > 14 || bedID <= 0 {
  364. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  365. return
  366. }
  367. adminUserInfo := this.GetMobileAdminUserInfo()
  368. patient, getPatientErr := service.GetPatientByID(adminUserInfo.Org.Id, patientID)
  369. if getPatientErr != nil {
  370. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  371. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  372. return
  373. } else if patient == nil {
  374. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  375. return
  376. }
  377. deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.Org.Id, bedID)
  378. if getDeviceNumberErr != nil {
  379. this.ErrorLog("获取床位失败:%v", getDeviceNumberErr)
  380. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  381. return
  382. } else if deviceNumber == nil {
  383. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
  384. return
  385. }
  386. scheduleDate := utils.ZeroHourTimeOfDay(time.Now())
  387. weekday := int64(scheduleDate.Weekday())
  388. if weekday == 0 {
  389. weekday = 7
  390. }
  391. //判断这个人今天是否有排班
  392. daySchedule, dayScheduleErr := service.GetDayScheduleTwo(adminUserInfo.Org.Id, scheduleDate.Unix(), patientID)
  393. //判断当前时段该床位是否有排班
  394. schedule, err := service.GetDayScheduleByBedid(adminUserInfo.Org.Id, scheduleDate.Unix(), bedID, scheduleType)
  395. if dayScheduleErr == gorm.ErrRecordNotFound { //今天没有排班
  396. if err == gorm.ErrRecordNotFound { //空床位
  397. // 创建排班数据
  398. newSchedule := &models.Schedule{
  399. UserOrgId: adminUserInfo.Org.Id,
  400. PartitionId: deviceNumber.ZoneID,
  401. BedId: deviceNumber.ID,
  402. PatientId: patientID,
  403. ScheduleDate: scheduleDate.Unix(),
  404. ScheduleType: scheduleType,
  405. ScheduleWeek: weekday,
  406. ModeId: modeID,
  407. Status: 1,
  408. CreatedTime: time.Now().Unix(),
  409. UpdatedTime: time.Now().Unix(),
  410. }
  411. createErr := service.CreateSchedule(newSchedule)
  412. if createErr != nil {
  413. this.ErrorLog("紧急排班失败:%v", createErr)
  414. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
  415. return
  416. } else {
  417. this.ServeSuccessJSON(map[string]interface{}{
  418. "schedule": newSchedule,
  419. "patient": patient,
  420. })
  421. }
  422. } else if err == nil {
  423. if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //该床位有排班没上机记录
  424. this.ServeFailJSONWithSGJErrorCode(enums.ErrorSchedualcRepeatBed)
  425. } else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //有排班且有上机记录
  426. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  427. return
  428. }
  429. } else if err != nil {
  430. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  431. return
  432. }
  433. } else if dayScheduleErr == nil { //今天有排班
  434. if daySchedule.ID > 0 && daySchedule.DialysisOrder.ID <= 0 { //今天有排班但是没上机
  435. if err == gorm.ErrRecordNotFound { //空床位
  436. // 修改了床位逻辑
  437. daySchedule, _ := service.GetDayScheduleTwo(adminUserInfo.Org.Id, scheduleDate.Unix(), patientID)
  438. if daySchedule.ID > 0 {
  439. daySchedule.PartitionId = deviceNumber.ZoneID
  440. daySchedule.BedId = bedID
  441. daySchedule.ModeId = modeID
  442. daySchedule.ScheduleType = scheduleType
  443. daySchedule.UpdatedTime = time.Now().Unix()
  444. err := service.UpdateSchedule(&daySchedule)
  445. if err != nil {
  446. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  447. return
  448. }
  449. this.ServeSuccessJSON(map[string]interface{}{
  450. "schedule": daySchedule,
  451. "patient": patient,
  452. })
  453. }
  454. } else if err == nil { //该床位被人霸占
  455. if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //霸占该床位的病人有排班没上机记录
  456. this.ServeFailJSONWithSGJErrorCode(enums.ErrorSchedualcRepeatBed)
  457. return
  458. } else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //霸占该床位的病人有排班且有上机记录
  459. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  460. return
  461. }
  462. } else if err != nil {
  463. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  464. return
  465. }
  466. } else if daySchedule.ID > 0 && daySchedule.DialysisOrder.ID > 0 { //今天有排班且上机
  467. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrder)
  468. return
  469. }
  470. }
  471. }