doctors_api_controller.go 23KB

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