doctors_api_controller.go 22KB

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