doctors_api_controller.go 24KB

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