doctors_api_controller.go 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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.GetAllAdminUsers(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  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. _, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  313. if errcode == gorm.ErrRecordNotFound {
  314. access := models.XtPatientVascularAccess{
  315. AccessProject: access_project,
  316. BloodAccessPartId: blood_access_part_id,
  317. BloodAccessPartOperaId: blood_access_part_opera_id,
  318. FirstStartTime: firstStartTime.Unix(),
  319. InflowPass: inflow_pass,
  320. Remark: remark,
  321. StartTime: startTime.Unix(),
  322. StopReason: stop_reason,
  323. UserStatus: user_status,
  324. Creator: creator,
  325. UserOrgId: orgId,
  326. Status: 1,
  327. Ctime: time.Now().Unix(),
  328. StopTime: stopTime.Unix(),
  329. PatientId: patient_id,
  330. OtherVascular: other_vascular,
  331. CiType: ci_type,
  332. BloodCultupe: blood_cultupe,
  333. SequelaeType: sequelae_type,
  334. }
  335. err := service.SaveVascularAccess(&access)
  336. if err == nil {
  337. this.ServeSuccessJSON(map[string]interface{}{
  338. "access": access,
  339. })
  340. return
  341. }
  342. } else if errcode == nil {
  343. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  344. return
  345. }
  346. }
  347. func (this *DoctorsApiController) GetAllVacualAccessList() {
  348. limit, _ := this.GetInt64("limit")
  349. page, _ := this.GetInt64("page")
  350. patient_id, _ := this.GetInt64("patient_id")
  351. orgId := this.GetAdminUserInfo().CurrentOrgId
  352. appId := this.GetAdminUserInfo().CurrentAppId
  353. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  354. doctor, err := service.GetAllDoctor(orgId, appId)
  355. if err == nil {
  356. this.ServeSuccessJSON(map[string]interface{}{
  357. "list": list,
  358. "total": total,
  359. "doctor": doctor,
  360. })
  361. return
  362. }
  363. }
  364. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  365. id, _ := this.GetInt64("id")
  366. accessDetail, err := service.GetVasularAccessByDetail(id)
  367. orgId := this.GetAdminUserInfo().CurrentOrgId
  368. appId := this.GetAdminUserInfo().CurrentAppId
  369. doctor, err := service.GetAllDoctor(orgId, appId)
  370. if err == nil {
  371. this.ServeSuccessJSON(map[string]interface{}{
  372. "accessDetail": accessDetail,
  373. "doctor": doctor,
  374. })
  375. return
  376. }
  377. }
  378. func (this *DoctorsApiController) UpdateVasularAccess() {
  379. id, _ := this.GetInt64("id")
  380. access_project, _ := this.GetInt64("access_project")
  381. blood_access_part_id := this.GetString("blood_access_part_id")
  382. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  383. first_start_time := this.GetString("first_start_time")
  384. timeLayout := "2006-01-02"
  385. loc, _ := time.LoadLocation("Local")
  386. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  387. inflow_pass := this.GetString("inflow_pass")
  388. remark := this.GetString("remark")
  389. start_time := this.GetString("start_time")
  390. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  391. stop_reason := this.GetString("stop_reason")
  392. user_status, _ := this.GetInt64("user_status")
  393. stop_time := this.GetString("stop_time")
  394. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  395. adminUserInfo := this.GetAdminUserInfo()
  396. orgId := adminUserInfo.CurrentOrgId
  397. creator := adminUserInfo.AdminUser.Id
  398. patientId, _ := this.GetInt64("patient_id")
  399. other_vascular := this.GetString("other_vascular")
  400. ci_type, _ := this.GetInt64("ci_type")
  401. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  402. sequelae_type, _ := this.GetInt64("sequelae_type")
  403. access := models.XtPatientVascularAccess{
  404. AccessProject: access_project,
  405. BloodAccessPartId: blood_access_part_id,
  406. BloodAccessPartOperaId: blood_access_part_opera_id,
  407. FirstStartTime: firstStartTime.Unix(),
  408. InflowPass: inflow_pass,
  409. Remark: remark,
  410. StartTime: startTime.Unix(),
  411. StopReason: stop_reason,
  412. UserStatus: user_status,
  413. Modify: creator,
  414. UserOrgId: orgId,
  415. Status: 1,
  416. StopTime: stopTime.Unix(),
  417. OtherVascular: other_vascular,
  418. CiType: ci_type,
  419. BloodCultupe: blood_cultupe,
  420. SequelaeType: sequelae_type,
  421. }
  422. _, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  423. if errcode == gorm.ErrRecordNotFound {
  424. err := service.UpdateVascularAccess(&access, id)
  425. if err == nil {
  426. this.ServeSuccessJSON(map[string]interface{}{
  427. "access": access,
  428. })
  429. return
  430. }
  431. } else if errcode == nil {
  432. this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  433. return
  434. }
  435. }
  436. func (this *DoctorsApiController) DeleteVasularAccess() {
  437. id, _ := this.GetInt64("id")
  438. err := service.DeleteVasularAccess(id)
  439. fmt.Println(err)
  440. returnData := make(map[string]interface{}, 0)
  441. returnData["msg"] = "ok"
  442. this.ServeSuccessJSON(returnData)
  443. return
  444. }
  445. func (this *DoctorsApiController) SavePassWayAssessment() {
  446. blood_dealwidth := this.GetString("blood_dealwith")
  447. blood_project := this.GetString("blood_project")
  448. blood_result := this.GetString("blood_result")
  449. creator, _ := this.GetInt64("creator")
  450. parent_id, _ := this.GetInt64("parent_id")
  451. patient_id, _ := this.GetInt64("patient_id")
  452. start_time := this.GetString("start_time")
  453. timeLayout := "2006-01-02"
  454. loc, _ := time.LoadLocation("Local")
  455. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  456. modify := this.GetAdminUserInfo().AdminUser.Id
  457. orgId := this.GetAdminUserInfo().CurrentOrgId
  458. assessment := models.XtPatientPasswayAssessment{
  459. StartTime: startTime.Unix(),
  460. BloodDealwith: blood_dealwidth,
  461. BloodProject: blood_project,
  462. BloodResult: blood_result,
  463. Creator: creator,
  464. PatientId: patient_id,
  465. ParentId: parent_id,
  466. Modify: modify,
  467. UserOrgId: orgId,
  468. Status: 1,
  469. Ctime: time.Now().Unix(),
  470. }
  471. err := service.CreatePatientWayAssessment(&assessment)
  472. if err == nil {
  473. this.ServeSuccessJSON(map[string]interface{}{
  474. "assessment": assessment,
  475. })
  476. return
  477. }
  478. }
  479. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  480. patient_id, _ := this.GetInt64("patient_id")
  481. parent_id, _ := this.GetInt64("parent_id")
  482. page, _ := this.GetInt64("page")
  483. limit, _ := this.GetInt64("limit")
  484. adminUserInfo := this.GetAdminUserInfo()
  485. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  486. if err == nil {
  487. this.ServeSuccessJSON(map[string]interface{}{
  488. "list": list,
  489. "total": total,
  490. })
  491. return
  492. }
  493. }
  494. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  495. id, _ := this.GetInt64("id")
  496. assessment, err := service.GetPasswayAssesmentById(id)
  497. if err == nil {
  498. this.ServeSuccessJSON(map[string]interface{}{
  499. "assessment": assessment,
  500. })
  501. return
  502. }
  503. }
  504. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  505. id, _ := this.GetInt64("id")
  506. blood_dealwidth := this.GetString("blood_dealwith")
  507. blood_project := this.GetString("blood_project")
  508. blood_result := this.GetString("blood_result")
  509. creator, _ := this.GetInt64("creator")
  510. start_time := this.GetString("start_time")
  511. timeLayout := "2006-01-02"
  512. loc, _ := time.LoadLocation("Local")
  513. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  514. modify := this.GetAdminUserInfo().AdminUser.Id
  515. assessment := models.XtPatientPasswayAssessment{
  516. BloodResult: blood_result,
  517. BloodDealwith: blood_dealwidth,
  518. BloodProject: blood_project,
  519. Creator: creator,
  520. StartTime: startTime.Unix(),
  521. Modify: modify,
  522. }
  523. err := service.UpdatePassWayAssesment(&assessment, id)
  524. if err == nil {
  525. this.ServeSuccessJSON(map[string]interface{}{
  526. "assessment": assessment,
  527. })
  528. return
  529. }
  530. }
  531. func (this *DoctorsApiController) DeleteWayAssessment() {
  532. id, _ := this.GetInt64("id")
  533. err := service.DeleteWayAssessment(id)
  534. fmt.Println(err)
  535. returnData := make(map[string]interface{}, 0)
  536. returnData["msg"] = "ok"
  537. this.ServeSuccessJSON(returnData)
  538. return
  539. }
  540. func (this *DoctorsApiController) GetAccessList() {
  541. adminUserInfo := this.GetAdminUserInfo()
  542. orgId := adminUserInfo.CurrentOrgId
  543. //血管通路
  544. list, err := service.GetAccessList(orgId)
  545. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  546. //血管通路部位
  547. access, err := service.GetBloodAccess(orgId)
  548. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  549. if err == nil {
  550. this.ServeSuccessJSON(map[string]interface{}{
  551. "blood_access_part_opera": blood_access_part_opera,
  552. "blood_access_part": blood_access_part,
  553. })
  554. return
  555. }
  556. }