patient_dataconfig_api_controller.go 37KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "fmt"
  8. "strconv"
  9. "strings"
  10. "time"
  11. "github.com/astaxie/beego"
  12. )
  13. func PatientDataConfigAPIControllerRegistRouters() {
  14. beego.Router("/api/patient/courses", &PatientDataConfigAPIController{}, "get:Courses")
  15. beego.Router("/api/patient/course/create", &PatientDataConfigAPIController{}, "get:CreateCourse")
  16. beego.Router("/api/patient/course/delete", &PatientDataConfigAPIController{}, "post:DeleteCourse")
  17. beego.Router("/api/patient/course/modify", &PatientDataConfigAPIController{}, "get:ModifyCourse")
  18. beego.Router("/api/patient/rescues", &PatientDataConfigAPIController{}, "get:Rescues")
  19. beego.Router("/api/patient/rescue/create", &PatientDataConfigAPIController{}, "post:CreateRescue")
  20. beego.Router("/api/patient/rescue/delete", &PatientDataConfigAPIController{}, "post:DeleteRescue")
  21. beego.Router("/api/patient/sickhistory", &PatientDataConfigAPIController{}, "get:GetSickHistorys")
  22. beego.Router("/api/patient/sickhistory/create", &PatientDataConfigAPIController{}, "get:CreateSickHistory")
  23. beego.Router("/api/patient/sickhistory/delete", &PatientDataConfigAPIController{}, "post:DeleteSickHistory")
  24. beego.Router("/api/patient/sickhistory/modify", &PatientDataConfigAPIController{}, "get:ModifySickHistory")
  25. beego.Router("/api/patient/physiquecheck", &PatientDataConfigAPIController{}, "get:GetPhysiqueChecks")
  26. beego.Router("/api/patient/physiquecheck/create", &PatientDataConfigAPIController{}, "get:CreatePhysiqueCheck")
  27. beego.Router("/api/patient/physiquecheck/delete", &PatientDataConfigAPIController{}, "post:DeletePhysiqueCheck")
  28. beego.Router("/api/patient/physiquecheck/modify", &PatientDataConfigAPIController{}, "get:ModifyPhysiqueCheck")
  29. beego.Router("/api/patient/sickhistory/print", &PatientDataConfigAPIController{}, "get:GetSickhistoryPrints")
  30. beego.Router("/api/patient/physiquecheck/print", &PatientDataConfigAPIController{}, "get:GetPhysiquecheckPrints")
  31. beego.Router("/api/patient/getpatientdialysisinforlist", &PatientDataConfigAPIController{}, "get:GetPatientDialysisInforList")
  32. }
  33. type PatientDataConfigAPIController struct {
  34. BaseAuthAPIController
  35. }
  36. func (this *PatientDataConfigAPIController) GetPhysiquecheckPrints() {
  37. patientID, _ := this.GetInt64("patient_id")
  38. idsStr := this.GetString("ids")
  39. if patientID <= 0 || len(idsStr) == 0 {
  40. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  41. return
  42. }
  43. recordIDStrs := strings.Split(idsStr, ",")
  44. patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
  45. sickHostory, _ := service.GetPatienttPhysiqueByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
  46. this.ServeSuccessJSON(map[string]interface{}{
  47. "patient": patient,
  48. "sickhistorys": sickHostory,
  49. })
  50. }
  51. func (this *PatientDataConfigAPIController) GetSickhistoryPrints() {
  52. patientID, _ := this.GetInt64("patient_id")
  53. idsStr := this.GetString("ids")
  54. if patientID <= 0 || len(idsStr) == 0 {
  55. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  56. return
  57. }
  58. recordIDStrs := strings.Split(idsStr, ",")
  59. patient, _ := service.GetPatientByID(this.GetAdminUserInfo().CurrentOrgId, patientID)
  60. sickHostory, _ := service.GetPatientSickHistoryByIds(this.GetAdminUserInfo().CurrentOrgId, patientID, recordIDStrs)
  61. for _, item := range sickHostory {
  62. pc, _ := service.GetLastPatientPhysiqueCheck(this.GetAdminUserInfo().CurrentOrgId, item.PatientId, item.RecordDate)
  63. item.XtPatientPhysiqueCheck = pc
  64. }
  65. this.ServeSuccessJSON(map[string]interface{}{
  66. "patient": patient,
  67. "sickhistorys": sickHostory,
  68. })
  69. }
  70. func (this *PatientDataConfigAPIController) GetSickHistorys() {
  71. patientID, _ := this.GetInt64("patient_id")
  72. startTimeYMDStr := this.GetString("start_time")
  73. endTimeYMDStr := this.GetString("end_time")
  74. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  75. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  76. return
  77. }
  78. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  79. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  80. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  81. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  82. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  83. return
  84. }
  85. adminUserInfo := this.GetAdminUserInfo()
  86. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  87. if getPatientErr != nil {
  88. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  89. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  90. return
  91. } else if patient == nil {
  92. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  93. return
  94. }
  95. records, getRecordsErr := service.GetPatientSickHistory(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  96. if getRecordsErr != nil {
  97. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  98. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  99. return
  100. }
  101. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  102. if getAllAdminsErr != nil {
  103. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  104. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  105. return
  106. }
  107. this.ServeSuccessJSON(map[string]interface{}{
  108. "records": records,
  109. "doctors": admins,
  110. })
  111. }
  112. func (this *PatientDataConfigAPIController) CreateSickHistory() {
  113. patientID, _ := this.GetInt64("patient_id")
  114. content := this.GetString("content")
  115. record_time_str := this.GetString("record_time")
  116. title := this.GetString("title")
  117. is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
  118. is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
  119. is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
  120. guominyaowu_desc := this.GetString("guominyaowu_desc")
  121. doctor_id, _ := this.GetInt64("doctor_id")
  122. if patientID <= 0 || len(content) == 0 {
  123. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  124. return
  125. }
  126. if len(record_time_str) == 0 {
  127. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  128. return
  129. }
  130. record_date := strings.Split(record_time_str, " ")
  131. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  132. checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
  133. adminUserInfo := this.GetAdminUserInfo()
  134. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  135. if getPatientErr != nil {
  136. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  137. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  138. return
  139. } else if patient == nil {
  140. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  141. return
  142. }
  143. now := time.Now().Unix()
  144. record := models.XtPatientSickHistory{
  145. OrgId: adminUserInfo.CurrentOrgId,
  146. PatientId: patientID,
  147. Recorder: adminUserInfo.AdminUser.Id,
  148. RecordTime: checkDate.Unix(),
  149. Content: content,
  150. Status: 1,
  151. Title: title,
  152. IsShenyizhiHistory: is_shenyizhishi,
  153. IsFumoDialysisHistory: is_fumotouxishi,
  154. HypersusceptibilityDesc: guominyaowu_desc,
  155. IsHypersusceptibility: is_guominyaowu,
  156. Ctime: now,
  157. Mtime: now,
  158. DoctorId: doctor_id,
  159. RecordDate: checkDate_two.Unix(),
  160. }
  161. createErr := service.CreatePatientSickHistory(&record)
  162. if createErr != nil {
  163. this.ErrorLog("创建患者病史记录失败:%v", createErr)
  164. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  165. return
  166. }
  167. this.ServeSuccessJSON(map[string]interface{}{
  168. "record": record,
  169. })
  170. }
  171. func (this *PatientDataConfigAPIController) DeleteSickHistory() {
  172. patientID, _ := this.GetInt64("patient_id")
  173. idsStr := this.GetString("ids")
  174. if patientID <= 0 || len(idsStr) == 0 {
  175. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  176. return
  177. }
  178. adminUserInfo := this.GetAdminUserInfo()
  179. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  180. if getPatientErr != nil {
  181. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  182. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  183. return
  184. } else if patient == nil {
  185. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  186. return
  187. }
  188. recordIDStrs := strings.Split(idsStr, ",")
  189. recordIDs := make([]int64, 0, len(recordIDStrs))
  190. for _, idStr := range recordIDStrs {
  191. id, parseErr := strconv.Atoi(idStr)
  192. if parseErr != nil {
  193. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  194. return
  195. }
  196. recordIDs = append(recordIDs, int64(id))
  197. }
  198. deleteErr := service.DeletePatientSickHistoryInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  199. if deleteErr != nil {
  200. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  201. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  202. return
  203. }
  204. this.ServeSuccessJSON(nil)
  205. }
  206. func (this *PatientDataConfigAPIController) ModifySickHistory() {
  207. patientID, _ := this.GetInt64("patient_id")
  208. content := this.GetString("content")
  209. id, _ := this.GetInt64("id", 0)
  210. record_time_str := this.GetString("record_time")
  211. title := this.GetString("title")
  212. is_shenyizhishi, _ := this.GetInt64("is_shenyizhishi")
  213. is_fumotouxishi, _ := this.GetInt64("is_fumotouxishi")
  214. is_guominyaowu, _ := this.GetInt64("is_guominyaowu")
  215. guominyaowu_desc := this.GetString("guominyaowu_desc")
  216. doctor_id, _ := this.GetInt64("doctor_id")
  217. if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
  218. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  219. return
  220. }
  221. //timeLayout := "2006-01-02"
  222. //loc, _ := time.LoadLocation("Local")
  223. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  224. fmt.Println("checkDate--------------", checkDate)
  225. adminUserInfo := this.GetAdminUserInfo()
  226. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  227. if getPatientErr != nil {
  228. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  229. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  230. return
  231. } else if patient == nil {
  232. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  233. return
  234. }
  235. now := time.Now().Unix()
  236. record := models.XtPatientSickHistory{
  237. ID: id,
  238. OrgId: adminUserInfo.CurrentOrgId,
  239. PatientId: patientID,
  240. Recorder: adminUserInfo.AdminUser.Id,
  241. Content: content,
  242. Status: 1,
  243. Ctime: now,
  244. Mtime: now,
  245. Title: title,
  246. RecordTime: checkDate.Unix(),
  247. IsShenyizhiHistory: is_shenyizhishi,
  248. IsFumoDialysisHistory: is_fumotouxishi,
  249. HypersusceptibilityDesc: guominyaowu_desc,
  250. IsHypersusceptibility: is_guominyaowu,
  251. DoctorId: doctor_id,
  252. }
  253. createErr := service.ModifyPatientSickHistory(&record)
  254. if createErr != nil {
  255. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  256. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  257. return
  258. }
  259. this.ServeSuccessJSON(map[string]interface{}{
  260. "record": record,
  261. })
  262. }
  263. func (this *PatientDataConfigAPIController) GetPhysiqueChecks() {
  264. patientID, _ := this.GetInt64("patient_id")
  265. startTimeYMDStr := this.GetString("start_time")
  266. endTimeYMDStr := this.GetString("end_time")
  267. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  268. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  269. return
  270. }
  271. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  272. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  273. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  274. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  275. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  276. return
  277. }
  278. adminUserInfo := this.GetAdminUserInfo()
  279. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  280. if getPatientErr != nil {
  281. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  282. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  283. return
  284. } else if patient == nil {
  285. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  286. return
  287. }
  288. records, getRecordsErr := service.GetPatientPhysiqueCheck(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  289. if getRecordsErr != nil {
  290. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  291. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  292. return
  293. }
  294. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  295. if getAllAdminsErr != nil {
  296. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  297. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  298. return
  299. }
  300. this.ServeSuccessJSON(map[string]interface{}{
  301. "records": records,
  302. "doctors": admins,
  303. })
  304. }
  305. func (this *PatientDataConfigAPIController) CreatePhysiqueCheck() {
  306. patientID, _ := this.GetInt64("patient_id")
  307. doctor_id, _ := this.GetInt64("doctor_id")
  308. record_time_str := this.GetString("record_time")
  309. t := this.GetString("t")
  310. p := this.GetString("p")
  311. r := this.GetString("r")
  312. bp_left := this.GetString("bp_left")
  313. bp_right := this.GetString("bp_right")
  314. pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
  315. tiwei, _ := this.GetInt64("tiwei")
  316. fuzhong, _ := this.GetInt64("fuzhong")
  317. chuxuedian, _ := this.GetInt64("chuxuedian")
  318. fayu, _ := this.GetInt64("fayu")
  319. yinyang, _ := this.GetInt64("yinyang")
  320. shenzhi, _ := this.GetInt64("shenzhi")
  321. pifunianmo, _ := this.GetInt64("pifunianmo")
  322. buwei := this.GetString("buwei")
  323. chengdu := this.GetString("chengdu")
  324. pixiachuxue, _ := this.GetInt64("pixiachuxue")
  325. zidian, _ := this.GetInt64("zidian")
  326. pifuwendu, _ := this.GetInt64("pifuwendu")
  327. qita := this.GetString("qita")
  328. linbazhongda, _ := this.GetInt64("linbazhongda")
  329. linbabuwei := this.GetString("linbabuwei")
  330. yanlian, _ := this.GetInt64("yanlian")
  331. tongkong, _ := this.GetInt64("tongkong")
  332. zuo := this.GetString("zuo")
  333. you := this.GetString("you")
  334. duiguangfanshe := this.GetString("duiguangfanshe")
  335. biantaoti := this.GetString("biantaoti")
  336. yanbu := this.GetString("yanbu")
  337. toubuqita := this.GetString("toubuqita")
  338. huxiyin := this.GetString("huxiyin")
  339. xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
  340. feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
  341. luoyin, _ := this.GetInt64("luoyin")
  342. desc := this.GetString("desc")
  343. xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
  344. xinlv, _ := this.GetInt64("xinlv")
  345. xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
  346. zayin, _ := this.GetInt64("zayin")
  347. fujiayin, _ := this.GetInt64("fujiayin")
  348. xinzangdesc := this.GetString("xinzangdesc")
  349. fushuizheng, _ := this.GetInt64("fushuizheng")
  350. ganjingjingmai := this.GetString("ganjingjingmai")
  351. gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
  352. gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
  353. pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
  354. pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
  355. shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
  356. shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
  357. fubu_desc := this.GetString("fubu_desc")
  358. oth_desc := this.GetString("oth_desc")
  359. if patientID <= 0 {
  360. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  361. return
  362. }
  363. if len(record_time_str) == 0 {
  364. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  365. return
  366. }
  367. record_date := strings.Split(record_time_str, " ")
  368. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  369. checkDate_two, _ := utils.ParseTimeStringToTime("2006-01-02", record_date[0])
  370. adminUserInfo := this.GetAdminUserInfo()
  371. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  372. if getPatientErr != nil {
  373. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  374. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  375. return
  376. } else if patient == nil {
  377. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  378. return
  379. }
  380. now := time.Now().Unix()
  381. record := models.XtPatientPhysiqueCheck{
  382. DoctorId: doctor_id,
  383. OrgId: adminUserInfo.CurrentOrgId,
  384. PatientId: patientID,
  385. Recorder: adminUserInfo.AdminUser.Id,
  386. RecordTime: checkDate.Unix(),
  387. Status: 1,
  388. Ctime: now,
  389. Mtime: now,
  390. T: t,
  391. P: p,
  392. R: r,
  393. BpRight: bp_right,
  394. BpLeft: bp_left,
  395. Pinxuerongmao: pinxuerongmao,
  396. Tiwei: tiwei,
  397. Fuzhong: fuzhong,
  398. Chuxuedian: chuxuedian,
  399. Fayu: fayu,
  400. Yinyang: yinyang,
  401. Shenzhi: shenzhi,
  402. Pifunianmo: pifunianmo,
  403. Buwei: buwei,
  404. Chengdu: chengdu,
  405. Pixiachuxue: pixiachuxue,
  406. Zidian: zidian,
  407. Pifuwendu: pifuwendu,
  408. Qita: qita,
  409. Linbazhongda: linbazhongda,
  410. Linbabuwei: linbabuwei,
  411. Yanlian: yanlian,
  412. Tongkong: tongkong,
  413. Zuo: zuo,
  414. You: you,
  415. Duiguangfanshe: duiguangfanshe,
  416. Biantaoti: biantaoti,
  417. Yanbu: yanbu,
  418. Toubuqita: toubuqita,
  419. Huxiyin: huxiyin,
  420. Xiongmomocayin: xiongmomocayin,
  421. Feizhangbuwei: feizhangbuwei,
  422. Luoyin: luoyin,
  423. Desc: desc,
  424. Xinzangdaxiao: xinzangdaxiao,
  425. Xinlv: xinlv,
  426. Xinbaomocasheng: xinbaomocasheng,
  427. Zayin: zayin,
  428. Fujiayin: fujiayin,
  429. Xinzangdesc: xinzangdesc,
  430. Fushuizheng: fushuizheng,
  431. Ganjingjingmai: ganjingjingmai,
  432. GangzhangYatong: gangzhang_yatong,
  433. GangzhangKoutong: gangzhang_koutong,
  434. PizhangKoutong: pizhang_koutong,
  435. PizhangYatong: pizhang_yatong,
  436. ShenzhangKoutong: shenzhang_koutong,
  437. ShenzhangYatong: shenzhang_yatong,
  438. FubuDesc: fubu_desc,
  439. OthDesc: oth_desc,
  440. RecordDate: checkDate_two.Unix(),
  441. }
  442. createErr := service.CreatePatientPhysiqueCheck(&record)
  443. if createErr != nil {
  444. this.ErrorLog("创建患者病史记录失败:%v", createErr)
  445. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  446. return
  447. }
  448. this.ServeSuccessJSON(map[string]interface{}{
  449. "record": record,
  450. })
  451. }
  452. func (this *PatientDataConfigAPIController) DeletePhysiqueCheck() {
  453. patientID, _ := this.GetInt64("patient_id")
  454. idsStr := this.GetString("ids")
  455. if patientID <= 0 || len(idsStr) == 0 {
  456. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  457. return
  458. }
  459. adminUserInfo := this.GetAdminUserInfo()
  460. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  461. if getPatientErr != nil {
  462. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  463. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  464. return
  465. } else if patient == nil {
  466. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  467. return
  468. }
  469. recordIDStrs := strings.Split(idsStr, ",")
  470. recordIDs := make([]int64, 0, len(recordIDStrs))
  471. for _, idStr := range recordIDStrs {
  472. id, parseErr := strconv.Atoi(idStr)
  473. if parseErr != nil {
  474. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  475. return
  476. }
  477. recordIDs = append(recordIDs, int64(id))
  478. }
  479. deleteErr := service.DeletePatientPhysiqueCheckInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  480. if deleteErr != nil {
  481. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  482. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  483. return
  484. }
  485. this.ServeSuccessJSON(nil)
  486. }
  487. func (this *PatientDataConfigAPIController) ModifyPhysiqueCheck() {
  488. patientID, _ := this.GetInt64("patient_id")
  489. id, _ := this.GetInt64("id", 0)
  490. doctor_id, _ := this.GetInt64("doctor_id", 0)
  491. record_time_str := this.GetString("record_time")
  492. if patientID <= 0 || id == 0 || len(record_time_str) == 0 {
  493. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  494. return
  495. }
  496. t := this.GetString("t")
  497. p := this.GetString("p")
  498. r := this.GetString("r")
  499. bp_left := this.GetString("bp_left")
  500. bp_right := this.GetString("bp_right")
  501. pinxuerongmao, _ := this.GetInt64("pinxuerongmao")
  502. tiwei, _ := this.GetInt64("tiwei")
  503. fuzhong, _ := this.GetInt64("fuzhong")
  504. chuxuedian, _ := this.GetInt64("chuxuedian")
  505. fayu, _ := this.GetInt64("fayu")
  506. yinyang, _ := this.GetInt64("yinyang")
  507. shenzhi, _ := this.GetInt64("shenzhi")
  508. pifunianmo, _ := this.GetInt64("pifunianmo")
  509. buwei := this.GetString("buwei")
  510. chengdu := this.GetString("chengdu")
  511. pixiachuxue, _ := this.GetInt64("pixiachuxue")
  512. zidian, _ := this.GetInt64("zidian")
  513. pifuwendu, _ := this.GetInt64("pifuwendu")
  514. qita := this.GetString("qita")
  515. linbazhongda, _ := this.GetInt64("linbazhongda")
  516. linbabuwei := this.GetString("linbabuwei")
  517. yanlian, _ := this.GetInt64("yanlian")
  518. tongkong, _ := this.GetInt64("tongkong")
  519. zuo := this.GetString("zuo")
  520. you := this.GetString("you")
  521. duiguangfanshe := this.GetString("duiguangfanshe")
  522. biantaoti := this.GetString("biantaoti")
  523. yanbu := this.GetString("yanbu")
  524. toubuqita := this.GetString("toubuqita")
  525. huxiyin := this.GetString("huxiyin")
  526. xiongmomocayin, _ := this.GetInt64("xiongmomocayin")
  527. feizhangbuwei, _ := this.GetInt64("feizhangbuwei")
  528. luoyin, _ := this.GetInt64("luoyin")
  529. desc := this.GetString("desc")
  530. xinzangdaxiao, _ := this.GetInt64("xinzangdaxiao")
  531. xinlv, _ := this.GetInt64("xinlv")
  532. xinbaomocasheng, _ := this.GetInt64("xinbaomocasheng")
  533. zayin, _ := this.GetInt64("zayin")
  534. fujiayin, _ := this.GetInt64("fujiayin")
  535. xinzangdesc := this.GetString("xinzangdesc")
  536. fushuizheng, _ := this.GetInt64("fushuizheng")
  537. ganjingjingmai := this.GetString("ganjingjingmai")
  538. gangzhang_yatong, _ := this.GetInt64("gangzhang_yatong")
  539. gangzhang_koutong, _ := this.GetInt64("gangzhang_koutong")
  540. pizhang_yatong, _ := this.GetInt64("pizhang_yatong")
  541. pizhang_koutong, _ := this.GetInt64("pizhang_koutong")
  542. shenzhang_yatong, _ := this.GetInt64("shenzhang_yatong")
  543. shenzhang_koutong, _ := this.GetInt64("shenzhang_koutong")
  544. fubu_desc := this.GetString("fubu_desc")
  545. oth_desc := this.GetString("oth_desc")
  546. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  547. adminUserInfo := this.GetAdminUserInfo()
  548. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  549. if getPatientErr != nil {
  550. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  551. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  552. return
  553. } else if patient == nil {
  554. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  555. return
  556. }
  557. now := time.Now().Unix()
  558. record := models.XtPatientPhysiqueCheck{
  559. ID: id,
  560. OrgId: adminUserInfo.CurrentOrgId,
  561. PatientId: patientID,
  562. Recorder: adminUserInfo.AdminUser.Id,
  563. RecordTime: checkDate.Unix(),
  564. DoctorId: doctor_id,
  565. Status: 1,
  566. Ctime: now,
  567. Mtime: now,
  568. T: t,
  569. P: p,
  570. R: r,
  571. BpRight: bp_right,
  572. BpLeft: bp_left,
  573. Pinxuerongmao: pinxuerongmao,
  574. Tiwei: tiwei,
  575. Fuzhong: fuzhong,
  576. Chuxuedian: chuxuedian,
  577. Fayu: fayu,
  578. Yinyang: yinyang,
  579. Shenzhi: shenzhi,
  580. Pifunianmo: pifunianmo,
  581. Buwei: buwei,
  582. Chengdu: chengdu,
  583. Pixiachuxue: pixiachuxue,
  584. Zidian: zidian,
  585. Pifuwendu: pifuwendu,
  586. Qita: qita,
  587. Linbazhongda: linbazhongda,
  588. Linbabuwei: linbabuwei,
  589. Yanlian: yanlian,
  590. Tongkong: tongkong,
  591. Zuo: zuo,
  592. You: you,
  593. Duiguangfanshe: duiguangfanshe,
  594. Biantaoti: biantaoti,
  595. Yanbu: yanbu,
  596. Toubuqita: toubuqita,
  597. Huxiyin: huxiyin,
  598. Xiongmomocayin: xiongmomocayin,
  599. Feizhangbuwei: feizhangbuwei,
  600. Luoyin: luoyin,
  601. Desc: desc,
  602. Xinzangdaxiao: xinzangdaxiao,
  603. Xinlv: xinlv,
  604. Xinbaomocasheng: xinbaomocasheng,
  605. Zayin: zayin,
  606. Fujiayin: fujiayin,
  607. Xinzangdesc: xinzangdesc,
  608. Fushuizheng: fushuizheng,
  609. Ganjingjingmai: ganjingjingmai,
  610. GangzhangYatong: gangzhang_yatong,
  611. GangzhangKoutong: gangzhang_koutong,
  612. PizhangKoutong: pizhang_koutong,
  613. PizhangYatong: pizhang_yatong,
  614. ShenzhangKoutong: shenzhang_koutong,
  615. ShenzhangYatong: shenzhang_yatong,
  616. FubuDesc: fubu_desc,
  617. OthDesc: oth_desc,
  618. }
  619. createErr := service.ModifyPatientPhysiqueCheck(&record)
  620. if createErr != nil {
  621. this.ErrorLog("修改患者体格检查失败:%v", createErr)
  622. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  623. return
  624. }
  625. this.ServeSuccessJSON(map[string]interface{}{
  626. "record": record,
  627. })
  628. }
  629. // /api/patient/courses [get]
  630. // @param patient_id:int
  631. // @param start_time:string (yyyy-MM-dd)
  632. // @param end_time:string (yyyy-MM-dd)
  633. func (this *PatientDataConfigAPIController) Courses() {
  634. patientID, _ := this.GetInt64("patient_id")
  635. startTimeYMDStr := this.GetString("start_time")
  636. endTimeYMDStr := this.GetString("end_time")
  637. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  638. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  639. return
  640. }
  641. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  642. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  643. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  644. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  645. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  646. return
  647. }
  648. adminUserInfo := this.GetAdminUserInfo()
  649. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  650. if getPatientErr != nil {
  651. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  652. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  653. return
  654. } else if patient == nil {
  655. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  656. return
  657. }
  658. records, getRecordsErr := service.GetPatientCourseOfDisease(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  659. if getRecordsErr != nil {
  660. this.ErrorLog("获取患者病程记录失败:%v", getRecordsErr)
  661. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  662. return
  663. }
  664. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  665. if getAllAdminsErr != nil {
  666. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  667. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  668. return
  669. }
  670. this.ServeSuccessJSON(map[string]interface{}{
  671. "records": records,
  672. "doctors": admins,
  673. })
  674. }
  675. // /api/patient/course/create [post]
  676. // @param patient_id:int
  677. // @param content:string
  678. func (this *PatientDataConfigAPIController) CreateCourse() {
  679. patientID, _ := this.GetInt64("patient_id")
  680. fmt.Println(patientID)
  681. content := this.GetString("content")
  682. record_time_str := this.GetString("record_time")
  683. title := this.GetString("title")
  684. if patientID <= 0 || len(content) == 0 {
  685. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  686. return
  687. }
  688. if len(record_time_str) == 0 {
  689. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  690. return
  691. }
  692. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  693. adminUserInfo := this.GetAdminUserInfo()
  694. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  695. if getPatientErr != nil {
  696. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  697. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. } else if patient == nil {
  700. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  701. return
  702. }
  703. now := time.Now().Unix()
  704. record := models.PatientDiseaseCourse{
  705. OrgID: adminUserInfo.CurrentOrgId,
  706. PatientID: patientID,
  707. Recorder: adminUserInfo.AdminUser.Id,
  708. RecordTime: checkDate.Unix(),
  709. Content: content,
  710. Status: 1,
  711. CreateTime: now,
  712. ModifyTime: now,
  713. Title: title,
  714. }
  715. createErr := service.CreatePatientCourseOfDisease(&record)
  716. if createErr != nil {
  717. this.ErrorLog("创建患者病程记录失败:%v", createErr)
  718. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  719. return
  720. }
  721. this.ServeSuccessJSON(map[string]interface{}{
  722. "record": record,
  723. })
  724. }
  725. // /api/patient/course/delete
  726. // @param patient_id:int
  727. // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
  728. func (this *PatientDataConfigAPIController) DeleteCourse() {
  729. patientID, _ := this.GetInt64("patient_id")
  730. idsStr := this.GetString("ids")
  731. if patientID <= 0 || len(idsStr) == 0 {
  732. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  733. return
  734. }
  735. adminUserInfo := this.GetAdminUserInfo()
  736. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  737. if getPatientErr != nil {
  738. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  739. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  740. return
  741. } else if patient == nil {
  742. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  743. return
  744. }
  745. recordIDStrs := strings.Split(idsStr, ",")
  746. recordIDs := make([]int64, 0, len(recordIDStrs))
  747. for _, idStr := range recordIDStrs {
  748. id, parseErr := strconv.Atoi(idStr)
  749. if parseErr != nil {
  750. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  751. return
  752. }
  753. recordIDs = append(recordIDs, int64(id))
  754. }
  755. deleteErr := service.DeletePatientCoursesInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  756. if deleteErr != nil {
  757. this.ErrorLog("删除患者病程记录失败:%v", deleteErr)
  758. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. this.ServeSuccessJSON(nil)
  762. }
  763. // /api/patient/rescues [get]
  764. // @param patient_id:int
  765. // @param start_time:string (yyyy-MM-dd)
  766. // @param end_time:string (yyyy-MM-dd)
  767. func (this *PatientDataConfigAPIController) Rescues() {
  768. patientID, _ := this.GetInt64("patient_id")
  769. startTimeYMDStr := this.GetString("start_time")
  770. endTimeYMDStr := this.GetString("end_time")
  771. if patientID <= 0 || len(startTimeYMDStr) == 0 || len(endTimeYMDStr) == 0 {
  772. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  773. return
  774. }
  775. endTimeYMDHmsStr := endTimeYMDStr + " 23:59:59"
  776. startTime, parseStartTimeErr := utils.ParseTimeStringToTime("2006-01-02", startTimeYMDStr)
  777. endTime, parseEndTimeErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  778. if parseStartTimeErr != nil || parseEndTimeErr != nil {
  779. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamFormatWrong)
  780. return
  781. }
  782. adminUserInfo := this.GetAdminUserInfo()
  783. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  784. if getPatientErr != nil {
  785. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  786. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  787. return
  788. } else if patient == nil {
  789. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  790. return
  791. }
  792. records, getRecordsErr := service.GetPatientRescueRecords(adminUserInfo.CurrentOrgId, patientID, startTime.Unix(), endTime.Unix())
  793. if getRecordsErr != nil {
  794. this.ErrorLog("获取患者抢救记录失败:%v", getRecordsErr)
  795. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  796. return
  797. }
  798. admins, getAllAdminsErr := service.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  799. if getAllAdminsErr != nil {
  800. this.ErrorLog("获取所有管理员失败:%v", getAllAdminsErr)
  801. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  802. return
  803. }
  804. this.ServeSuccessJSON(map[string]interface{}{
  805. "records": records,
  806. "doctors": admins,
  807. })
  808. }
  809. // /api/patient/rescue/create [post]
  810. // @param patient_id:int
  811. // @param content:string
  812. func (this *PatientDataConfigAPIController) CreateRescue() {
  813. patientID, _ := this.GetInt64("patient_id")
  814. content := this.GetString("content")
  815. if patientID <= 0 || len(content) == 0 {
  816. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  817. return
  818. }
  819. adminUserInfo := this.GetAdminUserInfo()
  820. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  821. if getPatientErr != nil {
  822. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  823. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  824. return
  825. } else if patient == nil {
  826. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  827. return
  828. }
  829. now := time.Now().Unix()
  830. record := models.PatientRescueRecord{
  831. OrgID: adminUserInfo.CurrentOrgId,
  832. PatientID: patientID,
  833. Recorder: adminUserInfo.AdminUser.Id,
  834. RecordTime: now,
  835. Content: content,
  836. Status: 1,
  837. CreateTime: now,
  838. ModifyTime: now,
  839. }
  840. createErr := service.CreatePatientRescueRecord(&record)
  841. if createErr != nil {
  842. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  843. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  844. return
  845. }
  846. this.ServeSuccessJSON(map[string]interface{}{
  847. "record": record,
  848. })
  849. }
  850. // /api/patient/rescue/delete
  851. // @param patient_id:int
  852. // @param ids:string 一个或多个record_id以逗号相隔 ("1,3,7")
  853. func (this *PatientDataConfigAPIController) DeleteRescue() {
  854. patientID, _ := this.GetInt64("patient_id")
  855. idsStr := this.GetString("ids")
  856. if patientID <= 0 || len(idsStr) == 0 {
  857. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  858. return
  859. }
  860. adminUserInfo := this.GetAdminUserInfo()
  861. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  862. if getPatientErr != nil {
  863. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  864. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. } else if patient == nil {
  867. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  868. return
  869. }
  870. recordIDStrs := strings.Split(idsStr, ",")
  871. recordIDs := make([]int64, 0, len(recordIDStrs))
  872. for _, idStr := range recordIDStrs {
  873. id, parseErr := strconv.Atoi(idStr)
  874. if parseErr != nil {
  875. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  876. return
  877. }
  878. recordIDs = append(recordIDs, int64(id))
  879. }
  880. deleteErr := service.DeletePatientResuceRecordsInBatch(adminUserInfo.CurrentOrgId, patientID, recordIDs)
  881. if deleteErr != nil {
  882. this.ErrorLog("删除患者抢救记录失败:%v", deleteErr)
  883. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  884. return
  885. }
  886. this.ServeSuccessJSON(nil)
  887. }
  888. func (this *PatientDataConfigAPIController) ModifyCourse() {
  889. patientID, _ := this.GetInt64("patient_id")
  890. content := this.GetString("content")
  891. id, _ := this.GetInt64("id", 0)
  892. record_time_str := this.GetString("record_time")
  893. title := this.GetString("title")
  894. if patientID <= 0 || len(content) == 0 || id == 0 || len(record_time_str) == 0 {
  895. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  896. return
  897. }
  898. //timeLayout := "2006-01-02"
  899. //loc, _ := time.LoadLocation("Local")
  900. checkDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", record_time_str)
  901. adminUserInfo := this.GetAdminUserInfo()
  902. patient, getPatientErr := service.GetPatientByID(adminUserInfo.CurrentOrgId, patientID)
  903. if getPatientErr != nil {
  904. this.ErrorLog("获取患者信息失败:%v", getPatientErr)
  905. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  906. return
  907. } else if patient == nil {
  908. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  909. return
  910. }
  911. now := time.Now().Unix()
  912. record := models.PatientDiseaseCourse{
  913. ID: id,
  914. OrgID: adminUserInfo.CurrentOrgId,
  915. PatientID: patientID,
  916. Recorder: adminUserInfo.AdminUser.Id,
  917. Content: content,
  918. Status: 1,
  919. CreateTime: now,
  920. ModifyTime: now,
  921. Title: title,
  922. RecordTime: checkDate.Unix(),
  923. }
  924. createErr := service.ModifyPatientCourses(&record)
  925. if createErr != nil {
  926. this.ErrorLog("创建患者抢救记录失败:%v", createErr)
  927. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  928. return
  929. }
  930. this.ServeSuccessJSON(map[string]interface{}{
  931. "record": record,
  932. })
  933. }
  934. func (this *PatientDataConfigAPIController) GetPatientDialysisInforList() {
  935. patientID, _ := this.GetInt64("patient_id")
  936. record_date := this.GetString("record_date")
  937. timeLayout := "2006-01-02"
  938. loc, _ := time.LoadLocation("Local")
  939. var startTime int64
  940. if len(record_date) > 0 {
  941. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  942. if err != nil {
  943. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  944. return
  945. }
  946. startTime = theTime.Unix()
  947. }
  948. fmt.Println("startTime0000000000000000", startTime)
  949. //获取患者姓名
  950. patient, _ := service.GetPatientName(patientID)
  951. orgId := this.GetAdminUserInfo().CurrentOrgId
  952. //获取透析处方
  953. prescription, _ := service.GetDialysisPrescription(patientID, orgId, startTime)
  954. //获取透前评估
  955. assessmentBefor, _ := service.GetAssessmentBefor(orgId, patientID, startTime)
  956. //透析上机
  957. order, _ := service.GetDialysisOrder(orgId, patientID, startTime)
  958. //透析监测
  959. monitor, _ := service.GetFistMonitorSix(orgId, patientID, startTime)
  960. //透析医嘱
  961. advice, _ := service.GetBloodDoctorAdvice(startTime, orgId, patientID)
  962. //透后评估
  963. afterDislysis, _ := service.GetAssessmentAfterDissData(patientID, orgId, startTime)
  964. this.ServeSuccessJSON(map[string]interface{}{
  965. "patient": patient,
  966. "prescription": prescription,
  967. "assessmentBefor": assessmentBefor,
  968. "order": order,
  969. "monitor": monitor,
  970. "advice": advice,
  971. "afterDislysis": afterDislysis,
  972. })
  973. }