dialysis_api_controller_extend.go 18KB

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