doctors_api_controller.go 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "fmt"
  8. "github.com/astaxie/beego"
  9. "github.com/jinzhu/gorm"
  10. "strconv"
  11. "time"
  12. )
  13. type DoctorsApiController struct {
  14. BaseAuthAPIController
  15. }
  16. func DoctorApiRegistRouters() {
  17. beego.Router("/api/alldoctors", &DoctorsApiController{}, "get:GetAllDoctorAndNurse")
  18. beego.Router("/api/admin/users", &DoctorsApiController{}, "get:GetAllAdminUsers")
  19. beego.Router("/api/patient/getdryweightdata", &DoctorsApiController{}, "Get:GetDryWeightData")
  20. beego.Router("/api/patient/getAllDoctor", &DoctorsApiController{}, "Get:GetAllDoctor")
  21. beego.Router("/api/patient/updatedryweightdata", &DoctorsApiController{}, "Post:UpdatedDryWeightData")
  22. beego.Router("/api/patient/getalldata", &DoctorsApiController{}, "Get:GetAllData")
  23. beego.Router("/api/paients/getdryweightdetail", &DoctorsApiController{}, "Get:GetDryWeightDetail")
  24. beego.Router("/api/patients/modifydryweightdata", &DoctorsApiController{}, "Get:ModifydryWeightData")
  25. beego.Router("/api/patient/deletedryweight", &DoctorsApiController{}, "Delete:DeleteDryWeight")
  26. beego.Router("/api/schedule/advices", &DoctorsApiController{}, "Get:ScheduleAdvices")
  27. beego.Router("/api/schedule/getdoctoradvicecount", &DoctorsApiController{}, "Get:GetDoctorAdviceCount")
  28. beego.Router("/api/patient/savevasularaccess", &DoctorsApiController{}, "Get:SaveVasularAccess")
  29. beego.Router("/api/patient/getallvascualraccesslist", &DoctorsApiController{}, "Get:GetAllVacualAccessList")
  30. beego.Router("/api/patient/getvascularaccessbydetial", &DoctorsApiController{}, "Get:GetVascularAccessByDetail")
  31. beego.Router("/api/patient/updatevasularaccess", &DoctorsApiController{}, "Get:UpdateVasularAccess")
  32. beego.Router("/api/patient/deletevascularaccess", &DoctorsApiController{}, "Get:DeleteVasularAccess")
  33. beego.Router("/api/patient/savepasswayassessment", &DoctorsApiController{}, "Get:SavePassWayAssessment")
  34. beego.Router("/api/patient/getallpasswayassessment", &DoctorsApiController{}, "Get:GetAllPassWayAssessment")
  35. beego.Router("/api/patient/getpasswayassmentbyid", &DoctorsApiController{}, "Get:GetPasswayAssesmentById")
  36. beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
  37. beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
  38. beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
  39. }
  40. func (c *DoctorsApiController) ScheduleAdvices() {
  41. schedualDate := c.GetString("date")
  42. adviceType, _ := c.GetInt("advice_type")
  43. patientType, _ := c.GetInt("patient_type")
  44. delivery_way := c.GetString("delivery_way")
  45. schedule_type, _ := c.GetInt64("schedule_type")
  46. partition_type, _ := c.GetInt64("partition_type")
  47. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  48. adviceType = 0
  49. }
  50. if patientType != 1 && patientType != 2 {
  51. patientType = 0
  52. }
  53. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  54. if parseDateErr != nil {
  55. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  56. return
  57. }
  58. adminUserInfo := c.GetAdminUserInfo()
  59. orgID := adminUserInfo.CurrentOrgId
  60. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
  61. hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
  62. config, _ := service.GetHisDoctorConfig(orgID)
  63. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  64. if err != nil {
  65. c.ErrorLog("获取排班信息失败:%v", err)
  66. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  67. } else {
  68. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  69. for _, schedual := range scheduals {
  70. if len(schedual.DoctorAdvices) > 0 {
  71. filtedScheduals = append(filtedScheduals, schedual)
  72. }
  73. }
  74. c.ServeSuccessJSON(map[string]interface{}{
  75. "scheduals": filtedScheduals,
  76. "adminUser": adminUser,
  77. "hisAdvices": hisAdvices,
  78. "config": config,
  79. })
  80. }
  81. }
  82. func (c *DoctorsApiController) GetAllDoctorAndNurse() {
  83. adminUserInfo := c.GetAdminUserInfo()
  84. doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  85. c.ServeSuccessJSON(map[string]interface{}{
  86. "doctors": doctors,
  87. "nursers": nursers,
  88. })
  89. return
  90. }
  91. func (c *DoctorsApiController) GetAllAdminUsers() {
  92. adminUserInfo := c.GetAdminUserInfo()
  93. users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
  94. c.ServeSuccessJSON(map[string]interface{}{
  95. "users": users,
  96. })
  97. return
  98. }
  99. func (c *DoctorsApiController) GetDryWeightData() {
  100. adminUserInfo := c.GetAdminUserInfo()
  101. orgid := adminUserInfo.CurrentOrgId
  102. patientid, _ := c.GetInt64("patientid")
  103. fmt.Println("patientid", patientid)
  104. id := adminUserInfo.AdminUser.Id
  105. fmt.Println("id", id)
  106. recordDateStr := time.Now().Format("2006-01-02")
  107. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  108. fmt.Scan("parseDateErr", parseDateErr)
  109. nowtime := recordDate.Unix()
  110. fmt.Println("nowtime", nowtime)
  111. pre, err := service.GetDryWeightByPatientId(patientid, orgid)
  112. fmt.Println("错误", err)
  113. c.ServeSuccessJSON(map[string]interface{}{
  114. "pre": pre,
  115. })
  116. }
  117. func (c *DoctorsApiController) GetAllDoctor() {
  118. adminUserInfo := c.GetAdminUserInfo()
  119. orgid := adminUserInfo.CurrentOrgId
  120. appid := adminUserInfo.CurrentAppId
  121. fmt.Println("appid", appid)
  122. appRole, err := service.GetAllDoctor(orgid, appid)
  123. fmt.Println("appRole", appRole)
  124. fmt.Println("错误", err)
  125. c.ServeSuccessJSON(map[string]interface{}{
  126. "appRole": appRole,
  127. })
  128. }
  129. func (c *DoctorsApiController) UpdatedDryWeightData() {
  130. adminUserInfo := c.GetAdminUserInfo()
  131. orgid := adminUserInfo.CurrentOrgId
  132. userid := adminUserInfo.AdminUser.Id
  133. fmt.Println("userid", userid)
  134. dry_weight, _ := c.GetFloat("dry_weight")
  135. fmt.Println("dry_weight", dry_weight)
  136. doctors, _ := c.GetInt64("doctors")
  137. fmt.Println("doctors", doctors)
  138. remarks := c.GetString("remarks")
  139. fmt.Println("remarks", remarks)
  140. patientid, _ := c.GetInt64("patient_id")
  141. fmt.Println("patientid", patientid)
  142. //透前数据
  143. dryweight, _ := c.GetFloat("dryweight")
  144. fmt.Println("dryweight", dryweight)
  145. var weight = dryweight - dry_weight
  146. weights := fmt.Sprintf("%.1f", weight)
  147. //weights := strconv.FormatFloat(sprintf, 'E', -1, 64)
  148. fmt.Println("weight", weights)
  149. fmt.Println("weight", weight)
  150. var sum string
  151. dryWeight, errcode := service.QueryDryWeight(orgid, patientid)
  152. fmt.Println("errcode", errcode)
  153. fmt.Println("dryWeight", dryWeight)
  154. if errcode == gorm.ErrRecordNotFound {
  155. sum = "/"
  156. patientDryweight := models.SgjPatientDryweight{
  157. DryWeight: dry_weight,
  158. Creator: doctors,
  159. Remakes: remarks,
  160. AdjustedValue: sum,
  161. PatientId: patientid,
  162. Ctime: time.Now().Unix(),
  163. UserOrgId: orgid,
  164. Status: 1,
  165. UserId: userid,
  166. }
  167. err := service.CreatePatientWeight(&patientDryweight)
  168. fmt.Println("err", err)
  169. c.ServeSuccessJSON(map[string]interface{}{
  170. "patientDryweight": patientDryweight,
  171. })
  172. return
  173. }
  174. fmt.Println("sum", sum)
  175. if weight == 0 {
  176. sum = "/"
  177. }
  178. if weight > 0 {
  179. sum = weights + "(" + "下调" + ")"
  180. }
  181. if weight < 0 {
  182. var sums = dry_weight - dryweight
  183. float := fmt.Sprintf("%.1f", sums)
  184. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  185. sum = float + "(" + "上调" + ")"
  186. }
  187. patientDryweight := models.SgjPatientDryweight{
  188. DryWeight: dry_weight,
  189. Creator: doctors,
  190. Remakes: remarks,
  191. AdjustedValue: sum,
  192. PatientId: patientid,
  193. Ctime: time.Now().Unix(),
  194. UserOrgId: orgid,
  195. Status: 1,
  196. UserId: userid,
  197. }
  198. err := service.CreatePatientWeight(&patientDryweight)
  199. //sgjPatientDryweight, _ := service.GetLastData(orgid)
  200. recordDateStr := time.Now().Format("2006-01-02")
  201. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  202. fmt.Scan("parseDateErr", parseDateErr)
  203. nowtime := recordDate.Unix()
  204. fmt.Println("nowtime", nowtime)
  205. //prescription := models.PredialysisEvaluation{
  206. // DryWeight: dryweight,
  207. //}
  208. //errors := service.UpdateDialysisPrescription( sgjPatientDryweight.PatientId, sgjPatientDryweight.UserOrgId, sgjPatientDryweight.DryWeight, prescription)
  209. //fmt.Println("error",errors)
  210. fmt.Println("err", err)
  211. fmt.Println("patientdryweight", patientDryweight)
  212. c.ServeSuccessJSON(map[string]interface{}{
  213. "patientDryweight": patientDryweight,
  214. })
  215. }
  216. func (c *DoctorsApiController) GetAllData() {
  217. id, _ := c.GetInt64("id")
  218. page, _ := c.GetInt64("page")
  219. fmt.Println("page", page)
  220. limit, _ := c.GetInt64("limit")
  221. fmt.Println("limit", limit)
  222. fmt.Println("id", id)
  223. adminUserInfo := c.GetAdminUserInfo()
  224. orgid := adminUserInfo.CurrentOrgId
  225. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  226. c.ServeSuccessJSON(map[string]interface{}{
  227. "dry": dry,
  228. "total": total,
  229. })
  230. }
  231. func (c *DoctorsApiController) GetDryWeightDetail() {
  232. id, _ := c.GetInt64("id")
  233. dryweight, _ := service.GetDryWeightDetailById(id)
  234. c.ServeSuccessJSON(map[string]interface{}{
  235. "dryweight": dryweight,
  236. })
  237. }
  238. func (c *DoctorsApiController) ModifydryWeightData() {
  239. adjustvalue := c.GetString("adjustvalue")
  240. creator, _ := c.GetInt64("creator")
  241. dryweight, _ := c.GetInt64("dryweight")
  242. dry := strconv.FormatInt(dryweight, 10)
  243. dry_weight, _ := strconv.ParseFloat(dry, 64)
  244. id, _ := c.GetInt64("id")
  245. remark := c.GetString("remark")
  246. patientDryweight := models.SgjPatientDryweight{
  247. AdjustedValue: adjustvalue,
  248. Creator: creator,
  249. DryWeight: dry_weight,
  250. Remakes: remark,
  251. }
  252. service.ModifyDryWeightData(&patientDryweight, id)
  253. c.ServeSuccessJSON(map[string]interface{}{
  254. "patientDryweight": patientDryweight,
  255. })
  256. }
  257. func (c *DoctorsApiController) DeleteDryWeight() {
  258. id, _ := c.GetInt64("id")
  259. service.DeleteDryWeight(id)
  260. returnData := make(map[string]interface{}, 0)
  261. returnData["msg"] = "ok"
  262. c.ServeSuccessJSON(returnData)
  263. return
  264. }
  265. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  266. timeLayout := "2006-01-02"
  267. loc, _ := time.LoadLocation("Local")
  268. start_time := c.GetString("start_time")
  269. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  270. end_time := c.GetString("end_time")
  271. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  272. delive_way := c.GetString("delive_way")
  273. adminUserInfo := c.GetAdminUserInfo()
  274. orgId := adminUserInfo.CurrentOrgId
  275. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  276. if len(list) == 0 {
  277. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  278. c.ServeSuccessJSON(map[string]interface{}{
  279. "list": list,
  280. })
  281. } else {
  282. c.ServeSuccessJSON(map[string]interface{}{
  283. "list": list,
  284. })
  285. }
  286. }
  287. func (this *DoctorsApiController) SaveVasularAccess() {
  288. access_project, _ := this.GetInt64("access_project")
  289. blood_access_part_id := this.GetString("blood_access_part_id")
  290. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  291. first_start_time := this.GetString("first_start_time")
  292. timeLayout := "2006-01-02"
  293. loc, _ := time.LoadLocation("Local")
  294. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  295. inflow_pass := this.GetString("inflow_pass")
  296. remark := this.GetString("remark")
  297. start_time := this.GetString("start_time")
  298. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  299. stop_reason := this.GetString("stop_reason")
  300. user_status, _ := this.GetInt64("user_status")
  301. stop_time := this.GetString("stop_time")
  302. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  303. patient_id, _ := this.GetInt64("patient_id")
  304. other_vascular := this.GetString("other_vascular")
  305. ci_type, _ := this.GetInt64("ci_type")
  306. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  307. sequelae_type, _ := this.GetInt64("sequelae_type")
  308. adminUserInfo := this.GetAdminUserInfo()
  309. orgId := adminUserInfo.CurrentOrgId
  310. creator := adminUserInfo.AdminUser.Id
  311. //查询改日期是否存在
  312. access := models.XtPatientVascularAccess{
  313. AccessProject: access_project,
  314. BloodAccessPartId: blood_access_part_id,
  315. BloodAccessPartOperaId: blood_access_part_opera_id,
  316. FirstStartTime: firstStartTime.Unix(),
  317. InflowPass: inflow_pass,
  318. Remark: remark,
  319. StartTime: startTime.Unix(),
  320. StopReason: stop_reason,
  321. UserStatus: user_status,
  322. Creator: creator,
  323. UserOrgId: orgId,
  324. Status: 1,
  325. Ctime: time.Now().Unix(),
  326. StopTime: stopTime.Unix(),
  327. PatientId: patient_id,
  328. OtherVascular: other_vascular,
  329. CiType: ci_type,
  330. BloodCultupe: blood_cultupe,
  331. SequelaeType: sequelae_type,
  332. }
  333. err := service.SaveVascularAccess(&access)
  334. if err == nil {
  335. this.ServeSuccessJSON(map[string]interface{}{
  336. "access": access,
  337. })
  338. return
  339. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  340. //if errcode == gorm.ErrRecordNotFound {
  341. // access := models.XtPatientVascularAccess{
  342. // AccessProject: access_project,
  343. // BloodAccessPartId: blood_access_part_id,
  344. // BloodAccessPartOperaId: blood_access_part_opera_id,
  345. // FirstStartTime: firstStartTime.Unix(),
  346. // InflowPass: inflow_pass,
  347. // Remark: remark,
  348. // StartTime: startTime.Unix(),
  349. // StopReason: stop_reason,
  350. // UserStatus: user_status,
  351. // Creator: creator,
  352. // UserOrgId: orgId,
  353. // Status: 1,
  354. // Ctime: time.Now().Unix(),
  355. // StopTime: stopTime.Unix(),
  356. // PatientId: patient_id,
  357. // OtherVascular: other_vascular,
  358. // CiType: ci_type,
  359. // BloodCultupe: blood_cultupe,
  360. // SequelaeType: sequelae_type,
  361. // }
  362. // err := service.SaveVascularAccess(&access)
  363. // if err == nil {
  364. // this.ServeSuccessJSON(map[string]interface{}{
  365. // "access": access,
  366. // })
  367. // return
  368. // }
  369. //} else if errcode == nil {
  370. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  371. // return
  372. }
  373. }
  374. func (this *DoctorsApiController) GetAllVacualAccessList() {
  375. limit, _ := this.GetInt64("limit")
  376. page, _ := this.GetInt64("page")
  377. patient_id, _ := this.GetInt64("patient_id")
  378. orgId := this.GetAdminUserInfo().CurrentOrgId
  379. appId := this.GetAdminUserInfo().CurrentAppId
  380. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  381. doctor, err := service.GetAllDoctor(orgId, appId)
  382. if err == nil {
  383. this.ServeSuccessJSON(map[string]interface{}{
  384. "list": list,
  385. "total": total,
  386. "doctor": doctor,
  387. })
  388. return
  389. }
  390. }
  391. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  392. id, _ := this.GetInt64("id")
  393. accessDetail, err := service.GetVasularAccessByDetail(id)
  394. orgId := this.GetAdminUserInfo().CurrentOrgId
  395. appId := this.GetAdminUserInfo().CurrentAppId
  396. doctor, err := service.GetAllDoctor(orgId, appId)
  397. if err == nil {
  398. this.ServeSuccessJSON(map[string]interface{}{
  399. "accessDetail": accessDetail,
  400. "doctor": doctor,
  401. })
  402. return
  403. }
  404. }
  405. func (this *DoctorsApiController) UpdateVasularAccess() {
  406. id, _ := this.GetInt64("id")
  407. access_project, _ := this.GetInt64("access_project")
  408. blood_access_part_id := this.GetString("blood_access_part_id")
  409. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  410. first_start_time := this.GetString("first_start_time")
  411. timeLayout := "2006-01-02"
  412. loc, _ := time.LoadLocation("Local")
  413. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  414. inflow_pass := this.GetString("inflow_pass")
  415. remark := this.GetString("remark")
  416. start_time := this.GetString("start_time")
  417. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  418. stop_reason := this.GetString("stop_reason")
  419. user_status, _ := this.GetInt64("user_status")
  420. stop_time := this.GetString("stop_time")
  421. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  422. adminUserInfo := this.GetAdminUserInfo()
  423. orgId := adminUserInfo.CurrentOrgId
  424. creator := adminUserInfo.AdminUser.Id
  425. patientId, _ := this.GetInt64("patient_id")
  426. other_vascular := this.GetString("other_vascular")
  427. ci_type, _ := this.GetInt64("ci_type")
  428. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  429. sequelae_type, _ := this.GetInt64("sequelae_type")
  430. access := models.XtPatientVascularAccess{
  431. AccessProject: access_project,
  432. BloodAccessPartId: blood_access_part_id,
  433. BloodAccessPartOperaId: blood_access_part_opera_id,
  434. FirstStartTime: firstStartTime.Unix(),
  435. InflowPass: inflow_pass,
  436. Remark: remark,
  437. StartTime: startTime.Unix(),
  438. StopReason: stop_reason,
  439. UserStatus: user_status,
  440. Modify: creator,
  441. UserOrgId: orgId,
  442. Status: 1,
  443. StopTime: stopTime.Unix(),
  444. OtherVascular: other_vascular,
  445. CiType: ci_type,
  446. BloodCultupe: blood_cultupe,
  447. SequelaeType: sequelae_type,
  448. PatientId: patientId,
  449. }
  450. err := service.UpdateVascularAccess(&access, id)
  451. if err == nil {
  452. this.ServeSuccessJSON(map[string]interface{}{
  453. "access": access,
  454. })
  455. return
  456. }
  457. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  458. //if errcode == gorm.ErrRecordNotFound {
  459. // err := service.UpdateVascularAccess(&access, id)
  460. // if err == nil {
  461. // this.ServeSuccessJSON(map[string]interface{}{
  462. // "access": access,
  463. // })
  464. // return
  465. // }
  466. //} else if errcode == nil {
  467. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  468. // return
  469. //}
  470. }
  471. func (this *DoctorsApiController) DeleteVasularAccess() {
  472. id, _ := this.GetInt64("id")
  473. err := service.DeleteVasularAccess(id)
  474. fmt.Println(err)
  475. returnData := make(map[string]interface{}, 0)
  476. returnData["msg"] = "ok"
  477. this.ServeSuccessJSON(returnData)
  478. return
  479. }
  480. func (this *DoctorsApiController) SavePassWayAssessment() {
  481. blood_dealwidth := this.GetString("blood_dealwith")
  482. blood_project := this.GetString("blood_project")
  483. blood_result := this.GetString("blood_result")
  484. creator, _ := this.GetInt64("creator")
  485. parent_id, _ := this.GetInt64("parent_id")
  486. patient_id, _ := this.GetInt64("patient_id")
  487. start_time := this.GetString("start_time")
  488. timeLayout := "2006-01-02"
  489. loc, _ := time.LoadLocation("Local")
  490. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  491. modify := this.GetAdminUserInfo().AdminUser.Id
  492. orgId := this.GetAdminUserInfo().CurrentOrgId
  493. assessment := models.XtPatientPasswayAssessment{
  494. StartTime: startTime.Unix(),
  495. BloodDealwith: blood_dealwidth,
  496. BloodProject: blood_project,
  497. BloodResult: blood_result,
  498. Creator: creator,
  499. PatientId: patient_id,
  500. ParentId: parent_id,
  501. Modify: modify,
  502. UserOrgId: orgId,
  503. Status: 1,
  504. Ctime: time.Now().Unix(),
  505. }
  506. err := service.CreatePatientWayAssessment(&assessment)
  507. if err == nil {
  508. this.ServeSuccessJSON(map[string]interface{}{
  509. "assessment": assessment,
  510. })
  511. return
  512. }
  513. }
  514. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  515. patient_id, _ := this.GetInt64("patient_id")
  516. parent_id, _ := this.GetInt64("parent_id")
  517. page, _ := this.GetInt64("page")
  518. limit, _ := this.GetInt64("limit")
  519. adminUserInfo := this.GetAdminUserInfo()
  520. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  521. if err == nil {
  522. this.ServeSuccessJSON(map[string]interface{}{
  523. "list": list,
  524. "total": total,
  525. })
  526. return
  527. }
  528. }
  529. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  530. id, _ := this.GetInt64("id")
  531. assessment, err := service.GetPasswayAssesmentById(id)
  532. if err == nil {
  533. this.ServeSuccessJSON(map[string]interface{}{
  534. "assessment": assessment,
  535. })
  536. return
  537. }
  538. }
  539. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  540. id, _ := this.GetInt64("id")
  541. blood_dealwidth := this.GetString("blood_dealwith")
  542. blood_project := this.GetString("blood_project")
  543. blood_result := this.GetString("blood_result")
  544. creator, _ := this.GetInt64("creator")
  545. start_time := this.GetString("start_time")
  546. timeLayout := "2006-01-02"
  547. loc, _ := time.LoadLocation("Local")
  548. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  549. modify := this.GetAdminUserInfo().AdminUser.Id
  550. assessment := models.XtPatientPasswayAssessment{
  551. BloodResult: blood_result,
  552. BloodDealwith: blood_dealwidth,
  553. BloodProject: blood_project,
  554. Creator: creator,
  555. StartTime: startTime.Unix(),
  556. Modify: modify,
  557. }
  558. err := service.UpdatePassWayAssesment(&assessment, id)
  559. if err == nil {
  560. this.ServeSuccessJSON(map[string]interface{}{
  561. "assessment": assessment,
  562. })
  563. return
  564. }
  565. }
  566. func (this *DoctorsApiController) DeleteWayAssessment() {
  567. id, _ := this.GetInt64("id")
  568. err := service.DeleteWayAssessment(id)
  569. fmt.Println(err)
  570. returnData := make(map[string]interface{}, 0)
  571. returnData["msg"] = "ok"
  572. this.ServeSuccessJSON(returnData)
  573. return
  574. }
  575. func (this *DoctorsApiController) GetAccessList() {
  576. adminUserInfo := this.GetAdminUserInfo()
  577. orgId := adminUserInfo.CurrentOrgId
  578. //血管通路
  579. list, err := service.GetAccessList(orgId)
  580. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  581. //血管通路部位
  582. access, err := service.GetBloodAccess(orgId)
  583. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  584. if err == nil {
  585. this.ServeSuccessJSON(map[string]interface{}{
  586. "blood_access_part_opera": blood_access_part_opera,
  587. "blood_access_part": blood_access_part,
  588. })
  589. return
  590. }
  591. }