patient_dataconfig_api_controller.go 38KB

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