patient_dataconfig_api_controller.go 46KB

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