sign_weigh_api_controller.go 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "encoding/json"
  7. "fmt"
  8. "github.com/astaxie/beego"
  9. "github.com/jinzhu/gorm"
  10. "reflect"
  11. "strconv"
  12. "time"
  13. )
  14. func SignWeighAPIControllerRegistRouters() {
  15. beego.Router("/api/sign/patients", &SignWeighAPIController{}, "Get:GetPatients")
  16. beego.Router("/api/sign/patientsign", &SignWeighAPIController{}, "Get:GetPatientSign")
  17. beego.Router("/api/signweign", &SignWeighAPIController{}, "Post:EditPatientSign")
  18. beego.Router("/api/sign/getDialysisInforInfomation", &SignWeighAPIController{}, "Get:GetPatientList")
  19. beego.Router("/api/sign/getDialysisAfterInfomation", &SignWeighAPIController{}, "Get:GetInforByPatientId")
  20. beego.Router("/api/sign/savaData", &SignWeighAPIController{}, "Post:SaveData")
  21. beego.Router("/api/sign/editdata", &SignWeighAPIController{}, "Post:EditData")
  22. beego.Router("/api/sigh/sighdata", &SignWeighAPIController{}, "Post:Sighdata")
  23. beego.Router("/api/sign/updateSignweight", &SignWeighAPIController{}, "Post:UpdateSignweight")
  24. }
  25. type SignWeighAPIController struct {
  26. BaseAuthAPIController
  27. }
  28. // /api/sign/patients [get]
  29. func (c *SignWeighAPIController) GetPatients() {
  30. keywrods := c.GetString("keywords")
  31. fmt.Println("关键字" + keywrods)
  32. scheduleType, _ := c.GetInt64("schedule_type", 0)
  33. needScheduleType, _ := c.GetInt64("need_schedule_type", 0)
  34. nowDateTime := time.Now()
  35. nowDate := nowDateTime.Format("2006-01-02")
  36. today := nowDate
  37. nowDate += " 00:00:00"
  38. //认为没有选择{0:'全部',1:'上午',2:'下午'3:'晚上' }中的一个
  39. if scheduleType < 0 || scheduleType > 3 {
  40. nowH := nowDateTime.Hour()
  41. if nowH < 12 {
  42. scheduleType = 1
  43. } else if nowH < 18 {
  44. scheduleType = 2
  45. } else {
  46. scheduleType = 3
  47. }
  48. }
  49. timeLayout := "2006-01-02"
  50. loc, _ := time.LoadLocation("Local")
  51. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
  52. if err != nil {
  53. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  54. return
  55. }
  56. dateTime := theTime.Unix()
  57. fmt.Println("dataTime是多少", dateTime)
  58. adminUserInfo := c.GetAdminUserInfo()
  59. patients, err := service.GetSignPatients(adminUserInfo.CurrentOrgId, keywrods, dateTime, scheduleType)
  60. fmt.Println("病人信息", patients)
  61. if err != nil {
  62. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
  63. return
  64. }
  65. panel := make(map[int64]map[string]int64, 0)
  66. if needScheduleType == 1 {
  67. panel, _ = service.GetSignPanels(adminUserInfo.CurrentOrgId, dateTime)
  68. fmt.Println("panel是什么", panel)
  69. }
  70. c.ServeSuccessJSON(map[string]interface{}{
  71. "patients": patients,
  72. "today": today,
  73. "schedule_type": scheduleType,
  74. "panel": panel,
  75. })
  76. return
  77. }
  78. func (c *SignWeighAPIController) GetPatientSign() {
  79. patientID, _ := c.GetInt64("patient_id", 0)
  80. dateTime := c.GetString("date_time")
  81. timeLayout := "2006-01-02"
  82. loc, _ := time.LoadLocation("Local")
  83. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
  84. if err != nil {
  85. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  86. return
  87. }
  88. dateTimeStam := theTime.Unix()
  89. adminUserInfo := c.GetAdminUserInfo()
  90. sign, err := service.GetPatientDateSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
  91. if err != nil {
  92. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
  93. return
  94. }
  95. c.ServeSuccessJSON(map[string]interface{}{
  96. "sign": sign,
  97. })
  98. return
  99. }
  100. func (c *SignWeighAPIController) EditPatientSign() {
  101. patientID, _ := c.GetInt64("patient_id", 0)
  102. dateTime := c.GetString("date_time")
  103. timeLayout := "2006-01-02"
  104. loc, _ := time.LoadLocation("Local")
  105. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
  106. if err != nil {
  107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  108. return
  109. }
  110. dateTimeStam := theTime.Unix()
  111. adminUserInfo := c.GetAdminUserInfo()
  112. sign, err := service.GetPatientDateSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
  113. if err != nil {
  114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDBSelectNoResult)
  115. return
  116. }
  117. var signForm models.SigninAndWeigh
  118. if sign != nil {
  119. signForm = *sign
  120. signForm.UpdatedTime = time.Now().Unix()
  121. } else {
  122. signForm.PatientId = patientID
  123. signForm.RecordDate = dateTimeStam
  124. signForm.UserOrgId = adminUserInfo.CurrentOrgId
  125. signForm.SignTime = time.Now().Unix()
  126. signForm.Status = 1
  127. signForm.CreatedTime = time.Now().Unix()
  128. signForm.UpdatedTime = time.Now().Unix()
  129. }
  130. signData := make(map[string]interface{}, 0)
  131. err = json.Unmarshal(c.Ctx.Input.RequestBody, &signData)
  132. if err != nil {
  133. //utils.ErrorLog(err.Error())
  134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  135. }
  136. if signData["dry_weight"] == nil || reflect.TypeOf(signData["dry_weight"]).String() != "string" {
  137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  138. return
  139. }
  140. dryWeight, _ := strconv.ParseFloat(signData["dry_weight"].(string), 64)
  141. signForm.DryWeight = dryWeight
  142. if signData["clothes_weight"] == nil || reflect.TypeOf(signData["clothes_weight"]).String() != "string" {
  143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  144. return
  145. }
  146. clothesWeight, _ := strconv.ParseFloat(signData["clothes_weight"].(string), 64)
  147. signForm.ClothingWeight = clothesWeight
  148. if signData["weigh_before"] == nil || reflect.TypeOf(signData["weigh_before"]).String() != "string" {
  149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  150. return
  151. }
  152. weighBefore, _ := strconv.ParseFloat(signData["weigh_before"].(string), 64)
  153. signForm.WeighingBefore = weighBefore
  154. if signData["dehydrated_weight"] == nil || reflect.TypeOf(signData["dehydrated_weight"]).String() != "string" {
  155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  156. return
  157. }
  158. dehydratedWeight, _ := strconv.ParseFloat(signData["dehydrated_weight"].(string), 64)
  159. signForm.TargetDewatering = dehydratedWeight
  160. if signData["weight_before"] == nil || reflect.TypeOf(signData["weight_before"]).String() != "string" {
  161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  162. return
  163. }
  164. weightBefore, _ := strconv.ParseFloat(signData["weight_before"].(string), 64)
  165. signForm.WeightBefore = weightBefore
  166. if signData["temperature_before"] == nil || reflect.TypeOf(signData["temperature_before"]).String() != "string" {
  167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  168. return
  169. }
  170. temperatureBefore, _ := strconv.ParseFloat(signData["temperature_before"].(string), 64)
  171. signForm.TemperatureBefore = temperatureBefore
  172. if signData["pulse_rate_before"] == nil || reflect.TypeOf(signData["pulse_rate_before"]).String() != "string" {
  173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  174. return
  175. }
  176. pulseRateBefore, _ := strconv.ParseFloat(signData["pulse_rate_before"].(string), 64)
  177. signForm.PulseFrequencyBefore = pulseRateBefore
  178. if signData["respiratory_rate_before"] == nil || reflect.TypeOf(signData["respiratory_rate_before"]).String() != "string" {
  179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  180. return
  181. }
  182. respiratoryRateBefore, _ := strconv.ParseFloat(signData["respiratory_rate_before"].(string), 64)
  183. signForm.BreathingRateBefore = respiratoryRateBefore
  184. if signData["DBP_before"] == nil || reflect.TypeOf(signData["DBP_before"]).String() != "string" {
  185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  186. return
  187. }
  188. DBPBefore, _ := strconv.ParseFloat(signData["DBP_before"].(string), 64)
  189. signForm.DiastolicBloodPressureBefore = DBPBefore
  190. if signData["SBP_before"] == nil || reflect.TypeOf(signData["SBP_before"]).String() != "string" {
  191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  192. return
  193. }
  194. SBPBefore, _ := strconv.ParseFloat(signData["SBP_before"].(string), 64)
  195. signForm.SystolicBloodPressureBefore = SBPBefore
  196. if signData["weigh_after"] == nil || reflect.TypeOf(signData["weigh_after"]).String() != "string" {
  197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  198. return
  199. }
  200. weighAfter, _ := strconv.ParseFloat(signData["weigh_after"].(string), 64)
  201. signForm.WeighingAfter = weighAfter
  202. if signData["weight_reduce_after"] == nil || reflect.TypeOf(signData["weight_reduce_after"]).String() != "string" {
  203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  204. return
  205. }
  206. weightReduceAfter, _ := strconv.ParseFloat(signData["weight_reduce_after"].(string), 64)
  207. signForm.WeightLoss = weightReduceAfter
  208. if signData["weight_after"] == nil || reflect.TypeOf(signData["weight_after"]).String() != "string" {
  209. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  210. return
  211. }
  212. weightAfter, _ := strconv.ParseFloat(signData["weight_after"].(string), 64)
  213. signForm.WeightAfter = weightAfter
  214. if signData["temperature_after"] == nil || reflect.TypeOf(signData["temperature_after"]).String() != "string" {
  215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  216. return
  217. }
  218. temperatureAfter, _ := strconv.ParseFloat(signData["temperature_after"].(string), 64)
  219. signForm.TemperatureAfter = temperatureAfter
  220. if signData["pulse_rate_after"] == nil || reflect.TypeOf(signData["pulse_rate_after"]).String() != "string" {
  221. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  222. return
  223. }
  224. pulseRateAfter, _ := strconv.ParseFloat(signData["pulse_rate_after"].(string), 64)
  225. signForm.PulseFrequencyAfter = pulseRateAfter
  226. if signData["respiratory_rate_after"] == nil || reflect.TypeOf(signData["respiratory_rate_after"]).String() != "string" {
  227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  228. return
  229. }
  230. respiratoryRateAfter, _ := strconv.ParseFloat(signData["respiratory_rate_after"].(string), 64)
  231. signForm.BreathingRateAfter = respiratoryRateAfter
  232. if signData["DBP_after"] == nil || reflect.TypeOf(signData["DBP_after"]).String() != "string" {
  233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  234. return
  235. }
  236. DBPAfter, _ := strconv.ParseFloat(signData["DBP_after"].(string), 64)
  237. signForm.DiastolicBloodPressureAfter = DBPAfter
  238. if signData["SBP_after"] == nil || reflect.TypeOf(signData["SBP_after"]).String() != "string" {
  239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  240. return
  241. }
  242. SBPAfter, _ := strconv.ParseFloat(signData["SBP_after"].(string), 64)
  243. signForm.SystolicBloodPressureAfter = SBPAfter
  244. if signForm.WeighingAfter > 0 {
  245. signForm.WeighTime = time.Now().Unix()
  246. }
  247. if signForm.WeighingBefore > 0 {
  248. signForm.WeighBeforeTime = time.Now().Unix()
  249. }
  250. err = service.EditPatientSign(&signForm)
  251. if err != nil {
  252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  253. return
  254. }
  255. c.ServeSuccessJSON(map[string]interface{}{
  256. "sign": signForm,
  257. })
  258. return
  259. }
  260. func (c *SignWeighAPIController) GetPatientList() {
  261. patientID, _ := c.GetInt64("patient_id", 0)
  262. fmt.Println("patientID是设么", patientID)
  263. adminUserInfo := c.GetAdminUserInfo()
  264. nowDateTime := time.Now()
  265. nowDate := nowDateTime.Format("2006-01-02")
  266. nowDate += " 00:00:00"
  267. timeLayout := "2006-01-02"
  268. loc, _ := time.LoadLocation("Local")
  269. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
  270. datetime := theTime.Unix()
  271. list := service.GetPatientInformationList(adminUserInfo.CurrentOrgId, patientID, datetime)
  272. c.ServeSuccessJSON(map[string]interface{}{
  273. "patientlist": list,
  274. })
  275. return
  276. }
  277. func (c *SignWeighAPIController) GetInforByPatientId() {
  278. patientID, _ := c.GetInt64("patient_id", 0)
  279. adminUserInfo := c.GetAdminUserInfo()
  280. nowDateTime := time.Now()
  281. nowDate := nowDateTime.Format("2006-01-02")
  282. nowDate += " 00:00:00"
  283. timeLayout := "2006-01-02"
  284. loc, _ := time.LoadLocation("Local")
  285. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
  286. datetime := theTime.Unix()
  287. patient := service.GetInforByPatient(adminUserInfo.CurrentOrgId, patientID, datetime)
  288. fmt.Println("patient是什么", patient)
  289. c.ServeSuccessJSON(map[string]interface{}{
  290. "patientinfor": patient,
  291. })
  292. }
  293. func (c *SignWeighAPIController) SaveData() {
  294. adminUserInfo := c.GetAdminUserInfo()
  295. orgId := adminUserInfo.CurrentOrgId
  296. patient_id, _ := c.GetInt64("patient_id", 0)
  297. weight_before, _ := c.GetFloat("weight_before", 0)
  298. dry_weight, _ := c.GetFloat("dry_weight", 0)
  299. temperature, _ := c.GetFloat("temperature", 0)
  300. pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
  301. breathing_rate, _ := c.GetFloat("breathing_rate", 0)
  302. systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
  303. diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
  304. predialysisevaluation := &models.PredialysisEvaluation{
  305. WeightBefore: weight_before,
  306. DryWeight: dry_weight,
  307. Temperature: temperature,
  308. PulseFrequency: pulse_frequency,
  309. BreathingRate: breathing_rate,
  310. SystolicBloodPressure: systolic_blood_pressure,
  311. DiastolicBloodPressure: diastolic_blood_pressure,
  312. }
  313. data := service.SaveData(predialysisevaluation, patient_id, orgId)
  314. c.ServeSuccessJSON(map[string]interface{}{
  315. "params": data,
  316. })
  317. }
  318. func (c *SignWeighAPIController) EditData() {
  319. adminUserInfo := c.GetAdminUserInfo()
  320. orgId := adminUserInfo.CurrentOrgId
  321. patient_id, _ := c.GetInt64("patient_id", 0)
  322. weight_after, _ := c.GetFloat("weight_after", 0)
  323. dry_weight, _ := c.GetFloat("dry_weight", 0)
  324. temperature, _ := c.GetFloat("temperature", 0)
  325. pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
  326. breathing_rate, _ := c.GetFloat("breathing_rate", 0)
  327. systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
  328. diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
  329. assessmentafterdislysis := &models.AssessmentAfterDislysis{
  330. WeightAfter: weight_after,
  331. DryWeight: dry_weight,
  332. Temperature: temperature,
  333. PulseFrequency: pulse_frequency,
  334. BreathingRate: breathing_rate,
  335. SystolicBloodPressure: systolic_blood_pressure,
  336. DiastolicBloodPressure: diastolic_blood_pressure,
  337. }
  338. editdata := service.Editdata(assessmentafterdislysis, patient_id, orgId)
  339. c.ServeSuccessJSON(map[string]interface{}{
  340. "params": editdata,
  341. })
  342. }
  343. func (c *SignWeighAPIController) Sighdata() {
  344. fmt.Println("哈哈哈哈哈哈哈哈哈哈")
  345. patientID, _ := c.GetInt64("patient_id", 0)
  346. fmt.Println("patientID", patientID)
  347. dateTime := c.GetString("date_time")
  348. fmt.Println(patientID, dateTime)
  349. timeLayout := "2006-01-02"
  350. loc, _ := time.LoadLocation("Local")
  351. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
  352. if err != nil {
  353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  354. return
  355. }
  356. dateTimeStam := theTime.Unix()
  357. fmt.Println("datatimestam是什么", dateTimeStam)
  358. adminUserInfo := c.GetAdminUserInfo()
  359. fmt.Println(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
  360. sign, errord := service.GetSign(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
  361. fmt.Println("sigh是什么东西", sign)
  362. fmt.Println(err)
  363. weighbefore, _ := c.GetFloat("weight_before", 0)
  364. dryweightbefore, _ := c.GetFloat("dry_weight", 0)
  365. temperaturebefore, _ := c.GetFloat("temperature", 0)
  366. pulsefrequencybefore, _ := c.GetFloat("pulse_frequency", 0)
  367. breathinratebefore, _ := c.GetFloat("breathing_rate", 0)
  368. systolicbloodpressurebefore, _ := c.GetFloat("systolic_blood_pressure", 0)
  369. diastorlicbloodpressurebefore, _ := c.GetFloat("diastolic_blood_pressure", 0)
  370. weightafter, _ := c.GetFloat("weight_after", 0)
  371. temperatureafter, _ := c.GetFloat("temperatureafter", 0)
  372. pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
  373. breathingrateafter, _ := c.GetFloat("breathing_rateafter", 0)
  374. systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
  375. diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
  376. fmt.Println("请查看数据")
  377. fmt.Println("透前称重:", weighbefore, "干体重:", dryweightbefore, "透前温度", temperaturebefore, "透前脉搏", pulsefrequencybefore, "透前呼吸", breathinratebefore, "透前舒张压", systolicbloodpressurebefore, "透前伸缩呀", diastorlicbloodpressurebefore)
  378. fmt.Println("透后体重", weightafter, "透后温度", temperatureafter, "透后脉搏", pulsefrequencyafter, "透后呼吸", breathingrateafter, "透后舒张压", systolicbloodpressureafter, "透后圣索亚", diastolicbloodpressureafter)
  379. var sighForm models.SignWeight
  380. sighForm.WeightBefore = weighbefore
  381. sighForm.DryWeightBefore = dryweightbefore
  382. sighForm.TemperatureBefore = temperaturebefore
  383. sighForm.PulseFrequencyBefore = pulsefrequencybefore
  384. sighForm.BreathingRateBefore = breathinratebefore
  385. sighForm.SystolicBloodPressureBefore = systolicbloodpressurebefore
  386. sighForm.DiastolicBloodPressureBefore = diastorlicbloodpressurebefore
  387. sighForm.WeightAfter = weightafter
  388. sighForm.TemperatureAfter = temperatureafter
  389. sighForm.PulseFrequencyAfter = pulsefrequencyafter
  390. sighForm.BreathingRateAfter = breathingrateafter
  391. sighForm.SystolicBloodPressureAfter = systolicbloodpressureafter
  392. sighForm.DiastolicBloodPressureAfter = diastolicbloodpressureafter
  393. sighForm.PatientId = patientID
  394. sighForm.RecordDate = dateTimeStam
  395. sighForm.UserOrgId = adminUserInfo.CurrentOrgId
  396. sighForm.SignTime = time.Now().Unix()
  397. sighForm.Status = 1
  398. sighForm.CreatedTime = time.Now().Unix()
  399. if sighForm.WeightBefore > 0 {
  400. sighForm.WeighBeforeTime = time.Now().Unix()
  401. }
  402. if sighForm.WeightAfter > 0 {
  403. sighForm.WeighTime = time.Now().Unix()
  404. }
  405. fmt.Println("sightForm是什么", sighForm)
  406. if errord == gorm.ErrRecordNotFound {
  407. fmt.Println("aaaaaaaaaaaaaa")
  408. savesignweigh := service.Savesignweigh(&sighForm)
  409. fmt.Println("savesignweight", savesignweigh)
  410. c.ServeSuccessJSON(map[string]interface{}{
  411. "signs": sighForm,
  412. })
  413. //signweigh := service.GetSignweigh(adminUserInfo.CurrentOrgId, patientID)
  414. //fmt.Println("signweigh是什么?",signweigh)
  415. fmt.Println(sighForm)
  416. } else if errord == nil {
  417. service.Updatesignweigh(&sighForm, patientID, adminUserInfo.CurrentOrgId)
  418. } else {
  419. fmt.Println("ccccccccccccc")
  420. service.Updatesignweigh(&sighForm, patientID, adminUserInfo.CurrentOrgId)
  421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  422. }
  423. return
  424. }
  425. func (c *SignWeighAPIController) UpdateSignweight() {
  426. patientID, _ := c.GetInt64("patient_id", 0)
  427. dateTime := c.GetString("date_time")
  428. fmt.Println("病人ID", patientID, dateTime)
  429. timeLayout := "2006-01-02"
  430. loc, _ := time.LoadLocation("Local")
  431. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", dateTime+" 00:00:00", loc)
  432. if err != nil {
  433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  434. return
  435. }
  436. dateTimeStam := theTime.Unix()
  437. fmt.Println("datatimestam是什么", dateTimeStam)
  438. adminUserInfo := c.GetAdminUserInfo()
  439. fmt.Println(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
  440. //透前
  441. weight_before, _ := c.GetFloat("weight_before", 0)
  442. dry_weight, _ := c.GetFloat("dry_weight", 0)
  443. temperature, _ := c.GetFloat("temperature", 0)
  444. pulse_frequency, _ := c.GetFloat("pulse_frequency", 0)
  445. systolic_blood_pressure, _ := c.GetFloat("systolic_blood_pressure", 0)
  446. diastolic_blood_pressure, _ := c.GetFloat("diastolic_blood_pressure", 0)
  447. fmt.Println("dry_weight", dry_weight)
  448. var predialysisevaluation models.PredialysisEvaluation
  449. predialysisevaluation.PatientId = patientID
  450. predialysisevaluation.UserOrgId = adminUserInfo.CurrentOrgId
  451. predialysisevaluation.AssessmentDate = dateTimeStam
  452. predialysisevaluation.WeightBefore = weight_before
  453. predialysisevaluation.DryWeight = dry_weight
  454. predialysisevaluation.Temperature = temperature
  455. predialysisevaluation.PulseFrequency = pulse_frequency
  456. predialysisevaluation.SystolicBloodPressure = systolic_blood_pressure
  457. predialysisevaluation.DiastolicBloodPressure = diastolic_blood_pressure
  458. predialysisevaluation.CreatedTime = time.Now().Unix()
  459. predialysisevaluation.Status = 1
  460. predialysis, errcode := service.GetDislysisBerfore(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
  461. fmt.Println("sigh是什么东西", predialysis)
  462. fmt.Println("错误装太:", errcode)
  463. if errcode == gorm.ErrRecordNotFound {
  464. fmt.Println("aaaaa")
  465. service.SaveDislysisiBefore(&predialysisevaluation)
  466. } else if errcode == nil {
  467. fmt.Println("bbbbbbbbb")
  468. service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
  469. } else {
  470. service.UpdataDislysisiBefore(&predialysisevaluation, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
  471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  472. }
  473. //透后
  474. weight_after, _ := c.GetFloat("weight_after", 0)
  475. temperatureafter, _ := c.GetFloat("temperatureafter", 0)
  476. pulsefrequencyafter, _ := c.GetFloat("pulse_frequencyafter", 0)
  477. systolicbloodpressureafter, _ := c.GetFloat("systolic_blood_pressureafter", 0)
  478. diastolicbloodpressureafter, _ := c.GetFloat("diastolic_blood_pressureafter", 0)
  479. fmt.Println("aaaa")
  480. fmt.Println(weight_after, temperatureafter, pulsefrequencyafter, systolicbloodpressureafter, diastolicbloodpressureafter)
  481. var assessmentafterdislysis models.AssessmentAfterDislysis
  482. assessmentafterdislysis.PatientId = patientID
  483. assessmentafterdislysis.UserOrgId = adminUserInfo.CurrentOrgId
  484. assessmentafterdislysis.AssessmentDate = dateTimeStam
  485. assessmentafterdislysis.WeightAfter = weight_after
  486. assessmentafterdislysis.Temperature = temperatureafter
  487. assessmentafterdislysis.PulseFrequency = pulsefrequencyafter
  488. assessmentafterdislysis.SystolicBloodPressure = systolicbloodpressureafter
  489. assessmentafterdislysis.DiastolicBloodPressure = diastolicbloodpressureafter
  490. assessmentafterdislysis.CreatedTime = time.Now().Unix()
  491. assessmentafterdislysis.Status = 1
  492. dislysis, errcoder := service.GetAssessmentaafterdislysis(adminUserInfo.CurrentOrgId, dateTimeStam, patientID)
  493. fmt.Println("sigh是什么东西", dislysis)
  494. fmt.Println("错误装太:", errcoder)
  495. if errcoder == gorm.ErrRecordNotFound {
  496. fmt.Println("oooooooo")
  497. service.SaveAssessmentafter(&assessmentafterdislysis)
  498. c.ServeSuccessJSON(map[string]interface{}{
  499. "signs": predialysisevaluation,
  500. })
  501. } else if errcoder == nil {
  502. fmt.Println("ffffffffffffffff")
  503. service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
  504. c.ServeSuccessJSON(map[string]interface{}{
  505. "signs": predialysisevaluation,
  506. })
  507. } else {
  508. service.UpdataAssessment(&assessmentafterdislysis, patientID, adminUserInfo.CurrentOrgId, dateTimeStam)
  509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  510. }
  511. }
  512. //func (c *SignWeighAPIController) GetForenoonData() {
  513. // nowDateTime := time.Now()
  514. // nowDate := nowDateTime.Format("2006-01-02")
  515. // nowDate += " 00:00:00"
  516. // timeLayout := "2006-01-02"
  517. // loc, _ := time.LoadLocation("Local")
  518. // theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", nowDate, loc)
  519. // datetime := theTime.Unix()
  520. // fmt.Println("hhhhhhhhhhhhhhhhhhh")
  521. // fmt.Println("datetime",datetime)
  522. // adminUserInfo := c.GetAdminUserInfo()
  523. // orgId := adminUserInfo.CurrentOrgId
  524. // fmt.Println("orgid是什么",orgId)
  525. // total, schedule, err := service.GetForenoonData(datetime, orgId, 1)
  526. // fmt.Println("total",total)
  527. // fmt.Println("schedule",schedule)
  528. // if err != nil {
  529. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  530. // return
  531. // }
  532. //
  533. // c.ServeSuccessJSON(map[string]interface{}{
  534. // "total": total,
  535. // })
  536. //
  537. //}