patient_dataconfig_api_controller.go 36KB

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