patient_dataconfig_api_controller.go 39KB

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