dialysis_api_controller_extend.go 39KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946
  1. package mobile_api_controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "strconv"
  6. "time"
  7. "XT_New/enums"
  8. "XT_New/models"
  9. "XT_New/service"
  10. "XT_New/utils"
  11. "github.com/jinzhu/gorm"
  12. )
  13. // /m/api/monitor/add [post]
  14. // @param patient_id:int
  15. // @param order_id?:int 透析记录 ID
  16. // @param date?:int 日期(10位时间戳)
  17. // @param operate_time?:int 实际测量日期(10位时间戳)
  18. // @param time?:string 时间(hh:mm) 废弃
  19. // @param pulse_frequency?:float 脉率(P)(次/min)
  20. // @param breathing_rated?:float 呼吸频率(R)(次/min)
  21. // @param systolic_bp?:float 收缩压
  22. // @param diastolic_bp?:float 舒张压
  23. // @param bp_type?:int 血压测量类型
  24. // @param blood_flow_volume?:float 血流量(ml/min)
  25. // @param venous_pressure?:float 静脉压
  26. // @param venous_pressure_unit?:string 静脉压单位
  27. // @param arterial_pressure?:float 动脉压
  28. // @param transmembrane_pressure?:float 跨膜压
  29. // @param transmembrane_pressure_unit?:string 跨膜压单位
  30. // @param ultrafiltration_rate?:float 超滤率(ml/h)
  31. // @param ultrafiltration_volume?:float 超滤量(ml)
  32. // @param sodium_concentration?:float 钠浓度(mmol/L)
  33. // @param dialysate_temperature?:float 透析液温度(℃)
  34. // @param replacement_rate?:float 置换率(ml/min)
  35. // @param displacement_quantity?:float 置换量(L)
  36. // @param ktv?:float KT/V(在线)
  37. // @param symptom?:string 症状
  38. // @param dispose?:string 处理
  39. // @param result?:string 结果
  40. // @param monitoring_nurse?:int 监测人
  41. func (this *DialysisAPIController) AddMonitorRecord() {
  42. patientID, _ := this.GetInt64("patient_id")
  43. if patientID <= 0 {
  44. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  45. return
  46. }
  47. orderID, _ := this.GetInt64("order_id")
  48. if orderID < 0 {
  49. orderID = 0
  50. }
  51. date, _ := this.GetInt64("date")
  52. operateTime, _ := this.GetInt64("operate_time")
  53. // recordTime := this.GetString("time")
  54. if date <= 0 || operateTime <= 0 {
  55. date = 0
  56. operateTime = 0
  57. // recordTime = ""
  58. }
  59. fmt.Println(date)
  60. fmt.Println(operateTime)
  61. pulseFrequency, _ := this.GetFloat("pulse_frequency")
  62. //breathingRated, _ := this.GetFloat("breathing_rated")
  63. breathingRated := this.GetString("breathing_rated")
  64. systolicBP, _ := this.GetFloat("systolic_bp")
  65. diastolicBP, _ := this.GetFloat("diastolic_bp")
  66. BPType, _ := this.GetInt("bp_type")
  67. bloodFlowVolume, _ := this.GetFloat("blood_flow_volume")
  68. venousPressure, _ := this.GetFloat("venous_pressure")
  69. venousPressureType, _ := this.GetInt64("venous_pressure_type", 1)
  70. arterialPressure, _ := this.GetFloat("arterial_pressure")
  71. arterialPressureType, _ := this.GetInt64("arterial_pressure_type", 1)
  72. transmembranePressure, _ := this.GetFloat("transmembrane_pressure", 0)
  73. transmembranePressureType, _ := this.GetInt64("transmembrane_pressure_type", 1)
  74. ultrafiltrationRate, _ := this.GetFloat("ultrafiltration_rate")
  75. ultrafiltrationVolume, _ := this.GetFloat("ultrafiltration_volume")
  76. sodiumConcentration, _ := this.GetFloat("sodium_concentration")
  77. dialysateTemperature, _ := this.GetFloat("dialysate_temperature")
  78. temperature, _ := this.GetFloat("temperature")
  79. replacementRate, _ := this.GetFloat("replacement_rate")
  80. displacementQuantity, _ := this.GetFloat("displacement_quantity")
  81. ktv, _ := this.GetFloat("ktv")
  82. symptom := this.GetString("symptom")
  83. dispose := this.GetString("dispose")
  84. conductivity, _ := this.GetFloat("conductivity")
  85. displacement_flow_quantity, _ := this.GetFloat("displacement_flow_quantity")
  86. blood_oxygen_saturation := this.GetString("blood_oxygen_saturation")
  87. result := this.GetString("result")
  88. monitoringNurse, _ := this.GetInt64("monitoring_nurse")
  89. heparin, _ := this.GetFloat("heparin")
  90. dialysate_flow, _ := this.GetFloat("dialysate_flow")
  91. urr := this.GetString("urr")
  92. blood_sugar, _ := this.GetFloat("blood_sugar")
  93. monitor_anticoagulant, _ := this.GetInt64("monitor_anticoagulant")
  94. monitor_anticoagulant_value := this.GetString("monitor_anticoagulant_value")
  95. heparin_amount, _ := this.GetFloat("heparin_amount")
  96. blood_pressure_monitoring_site, _ := this.GetInt64("blood_pressure_monitoring_site")
  97. complication, _ := this.GetInt64("complication")
  98. accumulated_blood_volume, _ := this.GetFloat("accumulated_blood_volume")
  99. blood_temperature, _ := this.GetFloat("blood_temperature")
  100. urea_monitoring, _ := this.GetFloat("urea_monitoring")
  101. blood_thickness, _ := this.GetFloat("blood_thickness")
  102. blood_monitor, _ := this.GetFloat("blood_monitor")
  103. dehydration, _ := this.GetFloat("dehydration")
  104. filter_pressure := this.GetString("filter_pressure")
  105. replacement_speed, _ := this.GetFloat("replacement_speed")
  106. dicarbonate, _ := this.GetFloat("dicarbonate")
  107. is_pressure := this.GetString("is_pressure")
  108. heparin_one := this.GetString("heparin_one")
  109. ultrafiltration_rate_one := this.GetString("ultrafiltration_rate_one")
  110. monitor_diastolic_blood_pressure_one := this.GetString("monitor_diastolic_blood_pressure_one")
  111. monitor_systolic_blood_pressure_one := this.GetString("monitor_systolic_blood_pressure_one")
  112. monitor_pulse_frequency_one := this.GetString("monitor_pulse_frequency_one")
  113. blood_flow_volume_one := this.GetString("blood_flow_volume_one")
  114. venous_pressure_one := this.GetString("venous_pressure_one")
  115. arterial_pressure_one := this.GetString("arterial_pressure_one")
  116. transmembrane_pressure_one := this.GetString("transmembrane_pressure_one")
  117. ultrafiltration_volume_one := this.GetString("ultrafiltration_volume_one")
  118. sodium_concentration_one := this.GetString("sodium_concentration_one")
  119. dialysate_temperature_one := this.GetString("dialysate_temperature_one")
  120. replacement_rate_one := this.GetString("replacement_rate_one")
  121. displacement_quantity_one := this.GetString("displacement_quantity_one")
  122. ktv_one := this.GetString("ktv_one")
  123. urr_one := this.GetString("urr_one")
  124. conductivity_one := this.GetString("conductivity_one")
  125. displacement_flow_quantity_one := this.GetString("displacement_flow_quantity_one")
  126. blood_oxygen_saturation_one := this.GetString("blood_oxygen_saturation_one")
  127. dialysate_flow_one := this.GetString("dialysate_flow_one")
  128. blood_sugar_one := this.GetString("blood_sugar_one")
  129. monitor_temperature_one := this.GetString("monitor_temperature_one")
  130. pulse_frequency_one := this.GetString("pulse_frequency_one")
  131. blood_temperature_one := this.GetString("blood_temperature_one")
  132. urea_monitoring_one := this.GetString("urea_monitoring_one")
  133. blood_thickness_one := this.GetString("blood_thickness_one")
  134. blood_monitor_one := this.GetString("blood_monitor_one")
  135. replacement_speed_one := this.GetString("replacement_speed_one")
  136. dicarbonate_one := this.GetString("dicarbonate_one")
  137. accumulated_blood_volume_one := this.GetString("accumulated_blood_volume_one")
  138. adminInfo := this.GetMobileAdminUserInfo()
  139. patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
  140. if getPatientErr != nil {
  141. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  142. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  143. return
  144. } else if patient == nil {
  145. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  146. return
  147. }
  148. // 查询信息规挡的设置天数
  149. infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
  150. if infor.ID > 0 && infor.WeekDay > 0 {
  151. var cha_time int64
  152. timeNowStr := time.Now().Format("2006-01-02")
  153. timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
  154. //今日的日期减去设置的日期
  155. cha_time = timeNewDate.Unix() - infor.WeekDay*86400
  156. if cha_time >= date {
  157. //查询审核是否允许
  158. infor, _ := service.GetDialysisInformationByRecordDate(patientID, date, adminInfo.Org.Id, 7)
  159. //申请状态不允许的情况 拒绝修改
  160. if infor.ApplicationStatus != 1 {
  161. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
  162. return
  163. }
  164. }
  165. }
  166. record := models.MonitoringRecord{
  167. UserOrgId: adminInfo.Org.Id,
  168. PatientId: patientID,
  169. DialysisOrderId: orderID,
  170. MonitoringDate: date,
  171. OperateTime: operateTime,
  172. // MonitoringTime: recordTime,
  173. PulseFrequency: pulseFrequency,
  174. BreathingRate: breathingRated,
  175. SystolicBloodPressure: systolicBP,
  176. DiastolicBloodPressure: diastolicBP,
  177. BloodPressureType: int64(BPType),
  178. BloodFlowVolume: bloodFlowVolume,
  179. VenousPressure: venousPressure,
  180. VenousPressureType: venousPressureType,
  181. ArterialPressure: arterialPressure,
  182. ArterialPressureType: arterialPressureType,
  183. TransmembranePressure: transmembranePressure,
  184. TransmembranePressureType: transmembranePressureType,
  185. UltrafiltrationRate: ultrafiltrationRate,
  186. UltrafiltrationVolume: ultrafiltrationVolume,
  187. SodiumConcentration: sodiumConcentration,
  188. DialysateTemperature: dialysateTemperature,
  189. Temperature: temperature,
  190. ReplacementRate: replacementRate,
  191. DisplacementQuantity: displacementQuantity,
  192. Ktv: ktv,
  193. Symptom: symptom,
  194. Dispose: dispose,
  195. Result: result,
  196. MonitoringNurse: monitoringNurse,
  197. Status: 1,
  198. CreatedTime: time.Now().Unix(),
  199. UpdatedTime: time.Now().Unix(),
  200. Conductivity: conductivity,
  201. DisplacementFlowQuantity: displacement_flow_quantity,
  202. BloodOxygenSaturation: blood_oxygen_saturation,
  203. Creator: adminInfo.AdminUser.Id,
  204. Modify: 0,
  205. Heparin: heparin,
  206. DialysateFlow: dialysate_flow,
  207. Urr: urr,
  208. BloodSugar: blood_sugar,
  209. MonitorAnticoagulant: monitor_anticoagulant,
  210. MonitorAnticoagulantValue: monitor_anticoagulant_value,
  211. BloodPressureMonitoringSite: blood_pressure_monitoring_site,
  212. Complication: complication,
  213. AccumulatedBloodVolume: accumulated_blood_volume,
  214. BloodTemperature: blood_temperature,
  215. UreaMonitoring: urea_monitoring,
  216. BloodThickness: blood_thickness,
  217. BloodMonitor: blood_monitor,
  218. HeparinAmount: heparin_amount,
  219. Dehydration: dehydration,
  220. FilterPressure: filter_pressure,
  221. Dicarbonate: dicarbonate,
  222. ReplacementSpeed: replacement_speed,
  223. IsPressure: is_pressure,
  224. HeparinOne: heparin_one,
  225. UltrafiltrationRateOne: ultrafiltration_rate_one,
  226. MonitorDiastolicBloodPressureOne: monitor_diastolic_blood_pressure_one,
  227. MonitorSystolicBloodPressureOne: monitor_systolic_blood_pressure_one,
  228. MonitorPulseFrequencyOne: monitor_pulse_frequency_one,
  229. BloodFlowVolumeOne: blood_flow_volume_one,
  230. VenousPressureOne: venous_pressure_one,
  231. ArterialPressureOne: arterial_pressure_one,
  232. TransmembranePressureOne: transmembrane_pressure_one,
  233. UltrafiltrationVolumeOne: ultrafiltration_volume_one,
  234. SodiumConcentrationOne: sodium_concentration_one,
  235. DialysateTemperatureOne: dialysate_temperature_one,
  236. ReplacementRateOne: replacement_rate_one,
  237. DisplacementFlowQuantityOne: displacement_flow_quantity_one,
  238. KtvOne: ktv_one,
  239. UrrOne: urr_one,
  240. ConductivityOne: conductivity_one,
  241. DisplacementQuantityOne: displacement_quantity_one,
  242. BloodOxygenSaturationOne: blood_oxygen_saturation_one,
  243. DialysateFlowOne: dialysate_flow_one,
  244. BloodSugarOne: blood_sugar_one,
  245. MonitorTemperatureOne: monitor_temperature_one,
  246. PulseFrequencyOne: pulse_frequency_one,
  247. BloodTemperatureOne: blood_temperature_one,
  248. UreaMonitoringOne: urea_monitoring_one,
  249. BloodThicknessOne: blood_thickness_one,
  250. BloodMonitorOne: blood_monitor_one,
  251. ReplacementSpeedOne: replacement_speed_one,
  252. DicarbonateOne: dicarbonate_one,
  253. AccumulatedBloodVolumeOne: accumulated_blood_volume_one,
  254. }
  255. err := service.CreateMonitor(&record)
  256. //记录日志
  257. byterequest, _ := json.Marshal(record)
  258. monitorRecordLog := models.XtMonitorRecordLog{
  259. RecordDate: record.MonitoringDate,
  260. PatientId: record.PatientId,
  261. Module: 1,
  262. AdminUserId: adminInfo.AdminUser.Id,
  263. Ctime: time.Now().Unix(),
  264. Mtime: 0,
  265. Status: 1,
  266. UserOrgId: record.UserOrgId,
  267. ErrLog: string(byterequest),
  268. Source: "手机端新增血压",
  269. }
  270. service.CreateMonitorRecordLog(monitorRecordLog)
  271. finish := models.XtDialysisFinish{
  272. IsFinish: 1,
  273. UserOrgId: record.UserOrgId,
  274. Status: 1,
  275. Ctime: time.Now().Unix(),
  276. Mtime: 0,
  277. Module: 7,
  278. RecordDate: record.MonitoringDate,
  279. Sourse: 1,
  280. PatientId: patientID,
  281. }
  282. dialysisFinish, err := service.GetDialysisFinish(record.UserOrgId, record.MonitoringDate, 7, patientID)
  283. if dialysisFinish.ID == 0 {
  284. service.CreateDialysisFinish(finish)
  285. }
  286. key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
  287. redis := service.RedisClient()
  288. //清空key 值
  289. redis.Set(key, "", time.Second)
  290. keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_record_list_all"
  291. redis.Set(keyOne, "", time.Second)
  292. defer redis.Close()
  293. if err != nil {
  294. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorCreate)
  295. return
  296. }
  297. this.ServeSuccessJSON(map[string]interface{}{
  298. "monitor": record,
  299. })
  300. }
  301. // /m/api/monitor/edit [post]
  302. // @param patient_id:int
  303. // @param order_id?:int 透析记录 ID
  304. // @param date?:int 日期(10位时间戳)
  305. // @param operate_time?:int 实际测量日期(10位时间戳)
  306. // @param time?:string 时间(hh:mm)废弃
  307. // @param pulse_frequency?:float 脉率(P)(次/min)
  308. // @param breathing_rated?:float 呼吸频率(R)(次/min)
  309. // @param systolic_bp?:float 收缩压
  310. // @param diastolic_bp?:float 舒张压
  311. // @param bp_type?:int 血压测量类型
  312. // @param blood_flow_volume?:float 血流量(ml/min)
  313. // @param venous_pressure?:float 静脉压
  314. // @param venous_pressure_unit?:string 静脉压单位
  315. // @param arterial_pressure?:float 动脉压
  316. // @param transmembrane_pressure?:float 跨膜压
  317. // @param transmembrane_pressure_unit?:string 跨膜压单位
  318. // @param ultrafiltration_rate?:float 超滤率(ml/h)
  319. // @param ultrafiltration_volume?:float 超滤量(ml)
  320. // @param sodium_concentration?:float 钠浓度(mmol/L)
  321. // @param dialysate_temperature?:float 透析液温度(℃)
  322. // @param replacement_rate?:float 置换率(ml/min)
  323. // @param displacement_quantity?:float 置换量(L)
  324. // @param ktv?:float KT/V(在线)
  325. // @param symptom?:string 症状
  326. // @param dispose?:string 处理
  327. // @param result?:string 结果
  328. // @param monitoring_nurse?:int 监测人
  329. func (this *DialysisAPIController) EditMonitorRecord() {
  330. patientID, _ := this.GetInt64("patient_id")
  331. if patientID <= 0 {
  332. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  333. return
  334. }
  335. id, _ := this.GetInt64("id")
  336. if id <= 0 {
  337. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  338. return
  339. }
  340. orderID, _ := this.GetInt64("order_id")
  341. if orderID < 0 {
  342. orderID = 0
  343. }
  344. date, _ := this.GetInt64("date")
  345. operateTime, _ := this.GetInt64("operate_time")
  346. if date <= 0 {
  347. date = 0
  348. operateTime = 0
  349. }
  350. pulseFrequency, _ := this.GetFloat("pulse_frequency")
  351. //breathingRated, _ := this.GetFloat("breathing_rated")
  352. breathingRated := this.GetString("breathing_rated")
  353. systolicBP, _ := this.GetFloat("systolic_bp")
  354. diastolicBP, _ := this.GetFloat("diastolic_bp")
  355. BPType, _ := this.GetInt("bp_type")
  356. bloodFlowVolume, _ := this.GetFloat("blood_flow_volume")
  357. venousPressure, _ := this.GetFloat("venous_pressure")
  358. venousPressureType, _ := this.GetInt64("venous_pressure_type", 1)
  359. arterialPressure, _ := this.GetFloat("arterial_pressure")
  360. arterialPressureType, _ := this.GetInt64("arterial_pressure", 1)
  361. transmembranePressure, _ := this.GetFloat("transmembrane_pressure")
  362. transmembranePressureType, _ := this.GetInt64("transmembrane_pressure_type", 1)
  363. ultrafiltrationRate, _ := this.GetFloat("ultrafiltration_rate")
  364. ultrafiltrationVolume, _ := this.GetFloat("ultrafiltration_volume")
  365. sodiumConcentration, _ := this.GetFloat("sodium_concentration")
  366. dialysateTemperature, _ := this.GetFloat("dialysate_temperature")
  367. temperature, _ := this.GetFloat("temperature")
  368. replacementRate, _ := this.GetFloat("replacement_rate")
  369. displacementQuantity, _ := this.GetFloat("displacement_quantity")
  370. ktv, _ := this.GetFloat("ktv")
  371. symptom := this.GetString("symptom")
  372. dispose := this.GetString("dispose")
  373. result := this.GetString("result")
  374. blood_oxygen_saturation := this.GetString("blood_oxygen_saturation")
  375. monitoringNurse, _ := this.GetInt64("monitoring_nurse")
  376. conductivity, _ := this.GetFloat("conductivity")
  377. displacement_flow_quantity, _ := this.GetFloat("displacement_flow_quantity")
  378. heparin, _ := this.GetFloat("heparin")
  379. dialysate_flow, _ := this.GetFloat("dialysate_flow")
  380. urr := this.GetString("urr")
  381. blood_sugar, _ := this.GetFloat("blood_sugar")
  382. adminInfo := this.GetMobileAdminUserInfo()
  383. monitor_anticoagulant, _ := this.GetInt64("monitor_anticoagulant")
  384. monitor_anticoagulant_value := this.GetString("monitor_anticoagulant_value")
  385. blood_pressure_monitoring_site, _ := this.GetInt64("blood_pressure_monitoring_site")
  386. complication, _ := this.GetInt64("complication")
  387. accumulated_blood_volume, _ := this.GetFloat("accumulated_blood_volume")
  388. blood_temperature, _ := this.GetFloat("blood_temperature")
  389. urea_monitoring, _ := this.GetFloat("urea_monitoring")
  390. blood_thickness, _ := this.GetFloat("blood_thickness")
  391. blood_monitor, _ := this.GetFloat("blood_monitor")
  392. heparin_amount, _ := this.GetFloat("heparin_amount")
  393. dehydration, _ := this.GetFloat("dehydration")
  394. filter_pressure := this.GetString("filter_pressure")
  395. replacement_speed, _ := this.GetFloat("replacement_speed")
  396. dicarbonate, _ := this.GetFloat("dicarbonate")
  397. is_pressure := this.GetString("is_pressure")
  398. ultrafiltration_rate_one := this.GetString("ultrafiltration_rate_one")
  399. heparin_one := this.GetString("heparin_one")
  400. monitor_diastolic_blood_pressure_one := this.GetString("monitor_diastolic_blood_pressure_one")
  401. monitor_systolic_blood_pressure_one := this.GetString("monitor_systolic_blood_pressure_one")
  402. monitor_pulse_frequency_one := this.GetString("monitor_pulse_frequency_one")
  403. blood_flow_volume_one := this.GetString("blood_flow_volume_one")
  404. venous_pressure_one := this.GetString("venous_pressure_one")
  405. arterial_pressure_one := this.GetString("arterial_pressure_one")
  406. transmembrane_pressure_one := this.GetString("transmembrane_pressure_one")
  407. ultrafiltration_volume_one := this.GetString("ultrafiltration_volume_one")
  408. sodium_concentration_one := this.GetString("sodium_concentration_one")
  409. dialysate_temperature_one := this.GetString("dialysate_temperature_one")
  410. replacement_rate_one := this.GetString("replacement_rate_one")
  411. displacement_quantity_one := this.GetString("displacement_quantity_one")
  412. ktv_one := this.GetString("ktv_one")
  413. urr_one := this.GetString("urr_one")
  414. conductivity_one := this.GetString("conductivity_one")
  415. displacement_flow_quantity_one := this.GetString("displacement_flow_quantity_one")
  416. blood_oxygen_saturation_one := this.GetString("blood_oxygen_saturation_one")
  417. dialysate_flow_one := this.GetString("dialysate_flow_one")
  418. blood_sugar_one := this.GetString("blood_sugar_one")
  419. monitor_temperature_one := this.GetString("monitor_temperature_one")
  420. pulse_frequency_one := this.GetString("pulse_frequency_one")
  421. blood_temperature_one := this.GetString("blood_temperature_one")
  422. urea_monitoring_one := this.GetString("urea_monitoring_one")
  423. blood_thickness_one := this.GetString("blood_thickness_one")
  424. blood_monitor_one := this.GetString("blood_monitor_one")
  425. replacement_speed_one := this.GetString("replacement_speed_one")
  426. dicarbonate_one := this.GetString("dicarbonate_one")
  427. accumulated_blood_volume_one := this.GetString("accumulated_blood_volume_one")
  428. monitor, err := service.GetMonitor(adminInfo.Org.Id, patientID, id)
  429. if err != nil {
  430. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  431. return
  432. }
  433. if monitor == nil {
  434. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorNotExist)
  435. return
  436. }
  437. monitor.Conductivity = conductivity
  438. monitor.DialysisOrderId = orderID
  439. monitor.MonitoringDate = date
  440. monitor.OperateTime = operateTime
  441. monitor.PulseFrequency = pulseFrequency
  442. monitor.BreathingRate = breathingRated
  443. monitor.SystolicBloodPressure = systolicBP
  444. monitor.DiastolicBloodPressure = diastolicBP
  445. monitor.BloodPressureType = int64(BPType)
  446. monitor.BloodFlowVolume = bloodFlowVolume
  447. monitor.VenousPressure = venousPressure
  448. monitor.VenousPressureType = venousPressureType
  449. monitor.ArterialPressure = arterialPressure
  450. monitor.ArterialPressureType = arterialPressureType
  451. monitor.TransmembranePressure = transmembranePressure
  452. monitor.TransmembranePressureType = transmembranePressureType
  453. monitor.UltrafiltrationRate = ultrafiltrationRate
  454. monitor.UltrafiltrationVolume = ultrafiltrationVolume
  455. monitor.SodiumConcentration = sodiumConcentration
  456. monitor.DialysateTemperature = dialysateTemperature
  457. monitor.Temperature = temperature
  458. monitor.ReplacementRate = replacementRate
  459. monitor.DisplacementQuantity = displacementQuantity
  460. monitor.Ktv = ktv
  461. monitor.Symptom = symptom
  462. monitor.Dispose = dispose
  463. monitor.Result = result
  464. monitor.MonitoringNurse = monitoringNurse
  465. monitor.Status = 1
  466. monitor.UpdatedTime = time.Now().Unix()
  467. monitor.DisplacementFlowQuantity = displacement_flow_quantity
  468. monitor.BloodOxygenSaturation = blood_oxygen_saturation
  469. monitor.Modify = adminInfo.AdminUser.Id
  470. monitor.Heparin = heparin
  471. monitor.DialysateFlow = dialysate_flow
  472. monitor.Urr = urr
  473. monitor.BloodSugar = blood_sugar
  474. monitor.MonitorAnticoagulant = monitor_anticoagulant
  475. monitor.MonitorAnticoagulantValue = monitor_anticoagulant_value
  476. monitor.BloodPressureMonitoringSite = blood_pressure_monitoring_site
  477. monitor.Complication = complication
  478. monitor.AccumulatedBloodVolume = accumulated_blood_volume
  479. monitor.BloodMonitor = blood_monitor
  480. monitor.UreaMonitoring = urea_monitoring
  481. monitor.BloodThickness = blood_thickness
  482. monitor.BloodTemperature = blood_temperature
  483. monitor.HeparinAmount = heparin_amount
  484. monitor.Dehydration = dehydration
  485. monitor.FilterPressure = filter_pressure
  486. monitor.IsPressure = is_pressure
  487. monitor.UltrafiltrationRateOne = ultrafiltration_rate_one
  488. monitor.HeparinOne = heparin_one
  489. monitor.MonitorDiastolicBloodPressureOne = monitor_diastolic_blood_pressure_one
  490. monitor.MonitorSystolicBloodPressureOne = monitor_systolic_blood_pressure_one
  491. monitor.MonitorPulseFrequencyOne = monitor_pulse_frequency_one
  492. monitor.BloodFlowVolumeOne = blood_flow_volume_one
  493. monitor.VenousPressureOne = venous_pressure_one
  494. monitor.ArterialPressureOne = arterial_pressure_one
  495. monitor.TransmembranePressureOne = transmembrane_pressure_one
  496. monitor.UltrafiltrationVolumeOne = ultrafiltration_volume_one
  497. monitor.SodiumConcentrationOne = sodium_concentration_one
  498. monitor.DialysateTemperatureOne = dialysate_temperature_one
  499. monitor.ReplacementRateOne = replacement_rate_one
  500. monitor.DisplacementFlowQuantityOne = displacement_flow_quantity_one
  501. monitor.KtvOne = ktv_one
  502. monitor.UrrOne = urr_one
  503. monitor.ConductivityOne = conductivity_one
  504. monitor.DisplacementQuantityOne = displacement_quantity_one
  505. monitor.BloodOxygenSaturationOne = blood_oxygen_saturation_one
  506. monitor.DialysateFlowOne = dialysate_flow_one
  507. monitor.BloodSugarOne = blood_sugar_one
  508. monitor.MonitorTemperatureOne = monitor_temperature_one
  509. monitor.PulseFrequencyOne = pulse_frequency_one
  510. monitor.BloodTemperatureOne = blood_temperature_one
  511. monitor.UreaMonitoringOne = urea_monitoring_one
  512. monitor.BloodThicknessOne = blood_thickness_one
  513. monitor.BloodMonitorOne = blood_monitor_one
  514. monitor.ReplacementSpeedOne = replacement_speed_one
  515. monitor.DicarbonateOne = dicarbonate_one
  516. monitor.AccumulatedBloodVolumeOne = accumulated_blood_volume_one
  517. // 查询信息规挡的设置天数
  518. infor, _ := service.GetDialysisInformationSetting(monitor.MonitoringDate)
  519. if infor.ID > 0 && infor.WeekDay > 0 {
  520. var cha_time int64
  521. timeNowStr := time.Now().Format("2006-01-02")
  522. timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
  523. //今日的日期减去设置的日期
  524. cha_time = timeNewDate.Unix() - infor.WeekDay*86400
  525. if cha_time >= monitor.MonitoringDate {
  526. //查询审核是否允许
  527. infor, _ := service.GetDialysisInformationByRecordDate(id, monitor.MonitoringDate, monitor.UserOrgId, 7)
  528. //申请状态不允许的情况 拒绝修改
  529. if infor.ApplicationStatus != 1 {
  530. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
  531. return
  532. }
  533. }
  534. }
  535. monitor.ReplacementSpeed = replacement_speed
  536. monitor.Dicarbonate = dicarbonate
  537. err = service.UpdateMonitor(monitor)
  538. //记录日志
  539. byterequest, _ := json.Marshal(monitor)
  540. monitorRecordLog := models.XtMonitorRecordLog{
  541. RecordDate: monitor.MonitoringDate,
  542. PatientId: monitor.PatientId,
  543. Module: 3,
  544. AdminUserId: adminInfo.AdminUser.Id,
  545. Ctime: time.Now().Unix(),
  546. Mtime: 0,
  547. Status: 1,
  548. UserOrgId: monitor.UserOrgId,
  549. ErrLog: string(byterequest),
  550. Source: "手机端修改监测",
  551. }
  552. service.CreateMonitorRecordLog(monitorRecordLog)
  553. key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_records"
  554. redis := service.RedisClient()
  555. //清空key 值
  556. redis.Set(key, "", time.Second)
  557. keyOne := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(date, 10) + ":monitor_record_list_all"
  558. redis.Set(keyOne, "", time.Second)
  559. defer redis.Close()
  560. if err != nil {
  561. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeMonitorUpdate)
  562. return
  563. }
  564. this.ServeSuccessJSON(map[string]interface{}{
  565. "monitor": monitor,
  566. })
  567. }
  568. // /m/api/monitor/delete [post]
  569. // @param record_id:int
  570. // @param patient_id:int
  571. func (this *DialysisAPIController) DeleteMonitor() {
  572. recordID, _ := this.GetInt64("record_id")
  573. patientID, _ := this.GetInt64("patient_id")
  574. if recordID <= 0 || patientID <= 0 {
  575. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  576. return
  577. }
  578. adminInfo := this.GetMobileAdminUserInfo()
  579. patient, getPatientErr := service.MobileGetPatientById(adminInfo.Org.Id, patientID)
  580. if getPatientErr != nil {
  581. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  582. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  583. return
  584. } else if patient == nil {
  585. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  586. return
  587. }
  588. monitor, getMonitorErr := service.GetMonitor(adminInfo.Org.Id, patientID, recordID)
  589. if getMonitorErr != nil {
  590. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  591. return
  592. }
  593. // 查询信息规挡的设置天数
  594. infor, _ := service.GetDialysisInformationSetting(adminInfo.Org.Id)
  595. if infor.ID > 0 && infor.WeekDay > 0 {
  596. var cha_time int64
  597. timeNowStr := time.Now().Format("2006-01-02")
  598. timeNewDate, _ := utils.ParseTimeStringToTime("2006-01-02", timeNowStr)
  599. //今日的日期减去设置的日期
  600. cha_time = timeNewDate.Unix() - infor.WeekDay*86400
  601. if cha_time >= monitor.MonitoringDate {
  602. //查询审核是否允许
  603. infor, _ := service.GetDialysisInformationByRecordDate(monitor.PatientId, monitor.MonitoringDate, monitor.UserOrgId, 7)
  604. //申请状态不允许的情况 拒绝修改
  605. if infor.ApplicationStatus != 1 {
  606. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInformationExist)
  607. return
  608. }
  609. }
  610. }
  611. err := service.DisableMonitor(adminInfo.Org.Id, patientID, recordID, adminInfo.AdminUser.Id)
  612. //记录日志
  613. byterequest, _ := json.Marshal(monitor)
  614. recordLog := models.XtMonitorRecordLog{
  615. RecordDate: monitor.MonitoringDate,
  616. PatientId: monitor.PatientId,
  617. Module: 4,
  618. AdminUserId: adminInfo.AdminUser.Id,
  619. Ctime: time.Now().Unix(),
  620. Mtime: 0,
  621. Status: 1,
  622. UserOrgId: monitor.UserOrgId,
  623. ErrLog: string(byterequest),
  624. Source: "手机端删除监测",
  625. }
  626. service.CreateMonitorRecordLog(recordLog)
  627. orgid := this.GetMobileAdminUserInfo().Org.Id
  628. redis := service.RedisClient()
  629. key := strconv.FormatInt(adminInfo.Org.Id, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_record_list_all"
  630. redis.Set(key, "", time.Second)
  631. keyOne := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientID, 10) + ":" + strconv.FormatInt(monitor.MonitoringDate, 10) + ":monitor_records"
  632. redis.Set(keyOne, "", time.Second)
  633. redis.Close()
  634. if err != nil {
  635. this.ErrorLog("删除透析监测记录失败:%v", err)
  636. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBDelete)
  637. return
  638. }
  639. this.ServeSuccessJSON(map[string]interface{}{
  640. "record_id": monitor.ID,
  641. })
  642. }
  643. // /m/api/schedule/urgentinit [get]
  644. func (this *DialysisAPIController) UrgentScheduleInitData() {
  645. schedule_type, _ := this.GetInt("type", 0)
  646. adminUserInfo := this.GetMobileAdminUserInfo()
  647. today := utils.ZeroHourTimeOfDay(time.Now())
  648. //获取所有病人且没有上机记录的病人
  649. patients, getPatientsErr := service.MobileGetAllPatientsForUrgentSchedule(adminUserInfo.Org.Id, today.Unix())
  650. if getPatientsErr != nil {
  651. this.ErrorLog("获取所有患者失败:%v", getPatientsErr)
  652. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  653. return
  654. }
  655. modes, getModesErr := service.MobileGetAllTrearmentModesForUrgentSchedule()
  656. if getModesErr != nil {
  657. this.ErrorLog("获取所有治疗模式失败:%v", getModesErr)
  658. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  659. return
  660. }
  661. deviceNumbers, getDeviceNumbersErr := service.GetAllAvaildDeviceNumbers(adminUserInfo.Org.Id, today.Unix(), schedule_type)
  662. if getDeviceNumbersErr != nil {
  663. this.ErrorLog("获取所有床位失败:%v", getDeviceNumbersErr)
  664. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  665. return
  666. }
  667. schedules, getSchedulesErr := service.MobileGetOtherSchedulesForUrgentSchedule(adminUserInfo.Org.Id, today.Unix(), schedule_type)
  668. if getSchedulesErr != nil {
  669. this.ErrorLog("获取所有排班失败:%v", getSchedulesErr)
  670. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  671. return
  672. }
  673. this.ServeSuccessJSON(map[string]interface{}{
  674. "patients": patients,
  675. "modes": modes,
  676. "device_numbers": deviceNumbers,
  677. "schedules": schedules,
  678. })
  679. }
  680. // /m/api/schedule/urgentadd [post]
  681. // @param patient_id:int
  682. // @param schedule_type:int
  683. // @param mode:int
  684. // @param bed:int
  685. func (this *DialysisAPIController) AddUrgentSchedule() {
  686. patientID, _ := this.GetInt64("patient_id")
  687. scheduleType, _ := this.GetInt64("schedule_type")
  688. modeID, _ := this.GetInt64("mode")
  689. bedID, _ := this.GetInt64("bed")
  690. if patientID <= 0 || scheduleType < 1 || scheduleType > 3 || modeID < 1 || modeID > 14 || bedID <= 0 {
  691. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  692. return
  693. }
  694. adminUserInfo := this.GetMobileAdminUserInfo()
  695. patient, getPatientErr := service.GetPatientByID(adminUserInfo.Org.Id, patientID)
  696. if getPatientErr != nil {
  697. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  698. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  699. return
  700. } else if patient == nil {
  701. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  702. return
  703. }
  704. deviceNumber, getDeviceNumberErr := service.GetDeviceNumberByID(adminUserInfo.Org.Id, bedID)
  705. if getDeviceNumberErr != nil {
  706. this.ErrorLog("获取床位失败:%v", getDeviceNumberErr)
  707. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  708. return
  709. } else if deviceNumber == nil {
  710. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeviceNumberNotExist)
  711. return
  712. }
  713. scheduleDate := utils.ZeroHourTimeOfDay(time.Now())
  714. weekday := int64(scheduleDate.Weekday())
  715. if weekday == 0 {
  716. weekday = 7
  717. }
  718. //判断这个人今天是否有排班
  719. daySchedule, dayScheduleErr := service.GetDayScheduleTwo(adminUserInfo.Org.Id, scheduleDate.Unix(), patientID)
  720. //判断当前时段该床位是否有排班
  721. schedule, err := service.GetDayScheduleByBedid(adminUserInfo.Org.Id, scheduleDate.Unix(), bedID, scheduleType)
  722. if dayScheduleErr == gorm.ErrRecordNotFound { //今天没有排班
  723. if err == gorm.ErrRecordNotFound { //空床位
  724. // 创建排班数据
  725. newSchedule := &models.Schedule{
  726. UserOrgId: adminUserInfo.Org.Id,
  727. PartitionId: deviceNumber.ZoneID,
  728. BedId: deviceNumber.ID,
  729. PatientId: patientID,
  730. ScheduleDate: scheduleDate.Unix(),
  731. ScheduleType: scheduleType,
  732. ScheduleWeek: weekday,
  733. ModeId: modeID,
  734. Status: 1,
  735. CreatedTime: time.Now().Unix(),
  736. UpdatedTime: time.Now().Unix(),
  737. IsExport: 5,
  738. }
  739. createErr := service.CreateScheduleTwo(newSchedule)
  740. //记录日志
  741. byterequest, _ := json.Marshal(newSchedule)
  742. scheduleLog := models.XtScheduleLog{
  743. UserOrgId: adminUserInfo.Org.Id,
  744. RecordDate: scheduleDate.Unix(),
  745. Status: 1,
  746. PatientId: patientID,
  747. Ctime: time.Now().Unix(),
  748. Mtime: 0,
  749. ErrLog: string(byterequest),
  750. Source: "手机端新增排班",
  751. Module: 1,
  752. AdminUserId: adminUserInfo.AdminUser.Id,
  753. }
  754. service.CreateScheduleLog(scheduleLog)
  755. service.UpdateRepeatSchStatus(adminUserInfo.Org.Id, scheduleDate.Unix())
  756. redis := service.RedisClient()
  757. timeStr := time.Now().Format("2006-01-02")
  758. key := "scheduals_" + timeStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  759. redis.Set(key, "", time.Second)
  760. //处方
  761. keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":prescriptions_list_all"
  762. redis.Set(keyOne, "", time.Second)
  763. //医嘱
  764. keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":advice_list_all"
  765. redis.Set(keyTwo, "", time.Second)
  766. keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":assessment_befores_list_all"
  767. redis.Set(keySix, "", time.Second)
  768. keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":assessment_after_dislysis_list_all"
  769. redis.Set(keyThree, "", time.Second)
  770. keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":monitor_record_list_all"
  771. redis.Set(keyFour, "", time.Second)
  772. keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":treatment_summarys_list_all"
  773. redis.Set(keyFive, "", time.Second)
  774. keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + strconv.FormatInt(scheduleDate.Unix(), 10) + ":dialysis_orders_list_all"
  775. redis.Set(keySeven, "", time.Second)
  776. redis.Close()
  777. if createErr != nil {
  778. this.ErrorLog("紧急排班失败:%v", createErr)
  779. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateScheduleFail)
  780. return
  781. } else {
  782. this.ServeSuccessJSON(map[string]interface{}{
  783. "schedule": newSchedule,
  784. "patient": patient,
  785. })
  786. }
  787. } else if err == nil {
  788. if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //该床位有排班没上机记录
  789. this.ServeFailJSONWithSGJErrorCode(enums.ErrorSchedualcRepeatBed)
  790. } else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //有排班且有上机记录
  791. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  792. return
  793. }
  794. } else if err != nil {
  795. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  796. return
  797. }
  798. } else if dayScheduleErr == nil { //今天有排班
  799. if daySchedule.ID > 0 && daySchedule.DialysisOrder.ID <= 0 { //今天有排班但是没上机
  800. if err == gorm.ErrRecordNotFound { //空床位
  801. // 修改了床位逻辑
  802. daySchedule, _ := service.GetDayScheduleTwo(adminUserInfo.Org.Id, scheduleDate.Unix(), patientID)
  803. if daySchedule.ID > 0 {
  804. daySchedule.PartitionId = deviceNumber.ZoneID
  805. daySchedule.BedId = bedID
  806. daySchedule.ModeId = modeID
  807. daySchedule.ScheduleType = scheduleType
  808. daySchedule.UpdatedTime = time.Now().Unix()
  809. err := service.UpdateSchedule(&daySchedule)
  810. //记录日志
  811. byterequest, _ := json.Marshal(daySchedule)
  812. scheduleLog := models.XtScheduleLog{
  813. UserOrgId: adminUserInfo.Org.Id,
  814. RecordDate: scheduleDate.Unix(),
  815. Status: 1,
  816. PatientId: patientID,
  817. Ctime: time.Now().Unix(),
  818. Mtime: 0,
  819. ErrLog: string(byterequest),
  820. Source: "手机端修改排班",
  821. Module: 1,
  822. AdminUserId: adminUserInfo.AdminUser.Id,
  823. }
  824. service.CreateScheduleLog(scheduleLog)
  825. service.UpdateRepeatSchStatus(adminUserInfo.Org.Id, scheduleDate.Unix())
  826. redis := service.RedisClient()
  827. timeStr := time.Now().Format("2006-01-02")
  828. key := "scheduals_" + timeStr + "_" + strconv.FormatInt(adminUserInfo.Org.Id, 10)
  829. redis.Set(key, "", time.Second)
  830. //处方
  831. keyOne := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":prescriptions_list_all"
  832. redis.Set(keyOne, "", time.Second)
  833. //医嘱
  834. keyTwo := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":advice_list_all"
  835. redis.Set(keyTwo, "", time.Second)
  836. keySix := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_befores_list_all"
  837. redis.Set(keySix, "", time.Second)
  838. keyThree := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":assessment_after_dislysis_list_all"
  839. redis.Set(keyThree, "", time.Second)
  840. keyFour := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":monitor_record_list_all"
  841. redis.Set(keyFour, "", time.Second)
  842. keyFive := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":treatment_summarys_list_all"
  843. redis.Set(keyFive, "", time.Second)
  844. keySeven := strconv.FormatInt(adminUserInfo.Org.Id, 10) + ":" + ":dialysis_orders_list_all"
  845. redis.Set(keySeven, "", time.Second)
  846. redis.Close()
  847. if err != nil {
  848. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  849. return
  850. }
  851. this.ServeSuccessJSON(map[string]interface{}{
  852. "schedule": daySchedule,
  853. "patient": patient,
  854. })
  855. }
  856. } else if err == nil { //该床位被人霸占
  857. if schedule.ID > 0 && schedule.DialysisOrder.ID == 0 { //霸占该床位的病人有排班没上机记录
  858. this.ServeFailJSONWithSGJErrorCode(enums.ErrorSchedualcRepeatBed)
  859. return
  860. } else if schedule.ID > 0 && schedule.DialysisOrder.ID > 0 { //霸占该床位的病人有排班且有上机记录
  861. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  862. return
  863. }
  864. } else if err != nil {
  865. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  866. return
  867. }
  868. } else if daySchedule.ID > 0 && daySchedule.DialysisOrder.ID > 0 { //今天有排班且上机
  869. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientDialysisOrder)
  870. return
  871. }
  872. }
  873. }