doctors_api_controller.go 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  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. beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Get:SaveCreationInspection")
  46. beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
  47. beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
  48. beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
  49. beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Get:UpdateTempalteSummary")
  50. }
  51. func (c *DoctorsApiController) ScheduleAdvices() {
  52. schedualDate := c.GetString("date")
  53. adviceType, _ := c.GetInt("advice_type")
  54. patientType, _ := c.GetInt("patient_type")
  55. delivery_way := c.GetString("delivery_way")
  56. schedule_type, _ := c.GetInt64("schedule_type")
  57. partition_type, _ := c.GetInt64("partition_type")
  58. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  59. adviceType = 0
  60. }
  61. if patientType != 1 && patientType != 2 {
  62. patientType = 0
  63. }
  64. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  65. if parseDateErr != nil {
  66. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  67. return
  68. }
  69. adminUserInfo := c.GetAdminUserInfo()
  70. orgID := adminUserInfo.CurrentOrgId
  71. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type)
  72. hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type)
  73. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type)
  74. config, _ := service.GetHisDoctorConfig(orgID)
  75. project_config, _ := service.GetHisProjectConfig(orgID)
  76. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  77. if err != nil {
  78. c.ErrorLog("获取排班信息失败:%v", err)
  79. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  80. } else {
  81. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  82. for _, schedual := range scheduals {
  83. if len(schedual.DoctorAdvices) > 0 {
  84. filtedScheduals = append(filtedScheduals, schedual)
  85. }
  86. }
  87. c.ServeSuccessJSON(map[string]interface{}{
  88. "scheduals": filtedScheduals,
  89. "adminUser": adminUser,
  90. "hisAdvices": hisAdvices,
  91. "config": config,
  92. "project_config": project_config,
  93. "project": project,
  94. })
  95. }
  96. }
  97. func (c *DoctorsApiController) GetAllDoctorAndNurse() {
  98. adminUserInfo := c.GetAdminUserInfo()
  99. doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  100. c.ServeSuccessJSON(map[string]interface{}{
  101. "doctors": doctors,
  102. "nursers": nursers,
  103. })
  104. return
  105. }
  106. func (c *DoctorsApiController) GetAllAdminUsers() {
  107. adminUserInfo := c.GetAdminUserInfo()
  108. users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
  109. c.ServeSuccessJSON(map[string]interface{}{
  110. "users": users,
  111. })
  112. return
  113. }
  114. func (c *DoctorsApiController) GetDryWeightData() {
  115. adminUserInfo := c.GetAdminUserInfo()
  116. orgid := adminUserInfo.CurrentOrgId
  117. patientid, _ := c.GetInt64("patientid")
  118. fmt.Println("patientid", patientid)
  119. id := adminUserInfo.AdminUser.Id
  120. fmt.Println("id", id)
  121. recordDateStr := time.Now().Format("2006-01-02")
  122. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  123. fmt.Scan("parseDateErr", parseDateErr)
  124. nowtime := recordDate.Unix()
  125. fmt.Println("nowtime", nowtime)
  126. pre, err := service.GetDryWeightByPatientId(patientid, orgid)
  127. fmt.Println("错误", err)
  128. c.ServeSuccessJSON(map[string]interface{}{
  129. "pre": pre,
  130. })
  131. }
  132. func (c *DoctorsApiController) GetAllDoctor() {
  133. adminUserInfo := c.GetAdminUserInfo()
  134. orgid := adminUserInfo.CurrentOrgId
  135. appid := adminUserInfo.CurrentAppId
  136. fmt.Println("appid", appid)
  137. appRole, err := service.GetAllDoctor(orgid, appid)
  138. fmt.Println("appRole", appRole)
  139. fmt.Println("错误", err)
  140. c.ServeSuccessJSON(map[string]interface{}{
  141. "appRole": appRole,
  142. })
  143. }
  144. func (c *DoctorsApiController) UpdatedDryWeightData() {
  145. adminUserInfo := c.GetAdminUserInfo()
  146. orgid := adminUserInfo.CurrentOrgId
  147. userid := adminUserInfo.AdminUser.Id
  148. fmt.Println("userid", userid)
  149. dry_weight, _ := c.GetFloat("dry_weight")
  150. fmt.Println("dry_weight", dry_weight)
  151. doctors, _ := c.GetInt64("doctors")
  152. fmt.Println("doctors", doctors)
  153. remarks := c.GetString("remarks")
  154. fmt.Println("remarks", remarks)
  155. patientid, _ := c.GetInt64("patient_id")
  156. fmt.Println("patientid", patientid)
  157. //透前数据
  158. dryweight, _ := c.GetFloat("dryweight")
  159. fmt.Println("dryweight", dryweight)
  160. var weight = dryweight - dry_weight
  161. weights := fmt.Sprintf("%.1f", weight)
  162. //weights := strconv.FormatFloat(sprintf, 'E', -1, 64)
  163. fmt.Println("weight", weights)
  164. fmt.Println("weight", weight)
  165. var sum string
  166. dryWeight, errcode := service.QueryDryWeight(orgid, patientid)
  167. fmt.Println("errcode", errcode)
  168. fmt.Println("dryWeight", dryWeight)
  169. if errcode == gorm.ErrRecordNotFound {
  170. sum = "/"
  171. patientDryweight := models.SgjPatientDryweight{
  172. DryWeight: dry_weight,
  173. Creator: doctors,
  174. Remakes: remarks,
  175. AdjustedValue: sum,
  176. PatientId: patientid,
  177. Ctime: time.Now().Unix(),
  178. UserOrgId: orgid,
  179. Status: 1,
  180. UserId: userid,
  181. }
  182. err := service.CreatePatientWeight(&patientDryweight)
  183. fmt.Println("err", err)
  184. c.ServeSuccessJSON(map[string]interface{}{
  185. "patientDryweight": patientDryweight,
  186. })
  187. return
  188. }
  189. fmt.Println("sum", sum)
  190. if weight == 0 {
  191. sum = "/"
  192. }
  193. if weight > 0 {
  194. sum = weights + "(" + "下调" + ")"
  195. }
  196. if weight < 0 {
  197. var sums = dry_weight - dryweight
  198. float := fmt.Sprintf("%.1f", sums)
  199. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  200. sum = float + "(" + "上调" + ")"
  201. }
  202. patientDryweight := models.SgjPatientDryweight{
  203. DryWeight: dry_weight,
  204. Creator: doctors,
  205. Remakes: remarks,
  206. AdjustedValue: sum,
  207. PatientId: patientid,
  208. Ctime: time.Now().Unix(),
  209. UserOrgId: orgid,
  210. Status: 1,
  211. UserId: userid,
  212. }
  213. err := service.CreatePatientWeight(&patientDryweight)
  214. //sgjPatientDryweight, _ := service.GetLastData(orgid)
  215. recordDateStr := time.Now().Format("2006-01-02")
  216. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  217. fmt.Scan("parseDateErr", parseDateErr)
  218. nowtime := recordDate.Unix()
  219. fmt.Println("nowtime", nowtime)
  220. //prescription := models.PredialysisEvaluation{
  221. // DryWeight: dryweight,
  222. //}
  223. //errors := service.UpdateDialysisPrescription( sgjPatientDryweight.PatientId, sgjPatientDryweight.UserOrgId, sgjPatientDryweight.DryWeight, prescription)
  224. //fmt.Println("error",errors)
  225. fmt.Println("err", err)
  226. fmt.Println("patientdryweight", patientDryweight)
  227. c.ServeSuccessJSON(map[string]interface{}{
  228. "patientDryweight": patientDryweight,
  229. })
  230. }
  231. func (c *DoctorsApiController) GetAllData() {
  232. id, _ := c.GetInt64("id")
  233. page, _ := c.GetInt64("page")
  234. fmt.Println("page", page)
  235. limit, _ := c.GetInt64("limit")
  236. fmt.Println("limit", limit)
  237. fmt.Println("id", id)
  238. adminUserInfo := c.GetAdminUserInfo()
  239. orgid := adminUserInfo.CurrentOrgId
  240. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  241. c.ServeSuccessJSON(map[string]interface{}{
  242. "dry": dry,
  243. "total": total,
  244. })
  245. }
  246. func (c *DoctorsApiController) GetDryWeightDetail() {
  247. id, _ := c.GetInt64("id")
  248. dryweight, _ := service.GetDryWeightDetailById(id)
  249. c.ServeSuccessJSON(map[string]interface{}{
  250. "dryweight": dryweight,
  251. })
  252. }
  253. func (c *DoctorsApiController) ModifydryWeightData() {
  254. adjustvalue := c.GetString("adjustvalue")
  255. creator, _ := c.GetInt64("creator")
  256. dryweight, _ := c.GetInt64("dryweight")
  257. dry := strconv.FormatInt(dryweight, 10)
  258. dry_weight, _ := strconv.ParseFloat(dry, 64)
  259. id, _ := c.GetInt64("id")
  260. remark := c.GetString("remark")
  261. patientDryweight := models.SgjPatientDryweight{
  262. AdjustedValue: adjustvalue,
  263. Creator: creator,
  264. DryWeight: dry_weight,
  265. Remakes: remark,
  266. }
  267. service.ModifyDryWeightData(&patientDryweight, id)
  268. c.ServeSuccessJSON(map[string]interface{}{
  269. "patientDryweight": patientDryweight,
  270. })
  271. }
  272. func (c *DoctorsApiController) DeleteDryWeight() {
  273. id, _ := c.GetInt64("id")
  274. service.DeleteDryWeight(id)
  275. returnData := make(map[string]interface{}, 0)
  276. returnData["msg"] = "ok"
  277. c.ServeSuccessJSON(returnData)
  278. return
  279. }
  280. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  281. timeLayout := "2006-01-02"
  282. loc, _ := time.LoadLocation("Local")
  283. start_time := c.GetString("start_time")
  284. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  285. end_time := c.GetString("end_time")
  286. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  287. delive_way := c.GetString("delive_way")
  288. adminUserInfo := c.GetAdminUserInfo()
  289. orgId := adminUserInfo.CurrentOrgId
  290. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  291. if len(list) == 0 {
  292. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  293. c.ServeSuccessJSON(map[string]interface{}{
  294. "list": list,
  295. })
  296. } else {
  297. c.ServeSuccessJSON(map[string]interface{}{
  298. "list": list,
  299. })
  300. }
  301. }
  302. func (this *DoctorsApiController) SaveVasularAccess() {
  303. access_project, _ := this.GetInt64("access_project")
  304. blood_access_part_id := this.GetString("blood_access_part_id")
  305. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  306. first_start_time := this.GetString("first_start_time")
  307. timeLayout := "2006-01-02"
  308. loc, _ := time.LoadLocation("Local")
  309. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  310. inflow_pass := this.GetString("inflow_pass")
  311. remark := this.GetString("remark")
  312. start_time := this.GetString("start_time")
  313. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  314. stop_reason := this.GetString("stop_reason")
  315. user_status, _ := this.GetInt64("user_status")
  316. stop_time := this.GetString("stop_time")
  317. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  318. patient_id, _ := this.GetInt64("patient_id")
  319. other_vascular := this.GetString("other_vascular")
  320. ci_type, _ := this.GetInt64("ci_type")
  321. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  322. sequelae_type, _ := this.GetInt64("sequelae_type")
  323. adminUserInfo := this.GetAdminUserInfo()
  324. orgId := adminUserInfo.CurrentOrgId
  325. creator := adminUserInfo.AdminUser.Id
  326. //查询改日期是否存在
  327. access := models.XtPatientVascularAccess{
  328. AccessProject: access_project,
  329. BloodAccessPartId: blood_access_part_id,
  330. BloodAccessPartOperaId: blood_access_part_opera_id,
  331. FirstStartTime: firstStartTime.Unix(),
  332. InflowPass: inflow_pass,
  333. Remark: remark,
  334. StartTime: startTime.Unix(),
  335. StopReason: stop_reason,
  336. UserStatus: user_status,
  337. Creator: creator,
  338. UserOrgId: orgId,
  339. Status: 1,
  340. Ctime: time.Now().Unix(),
  341. StopTime: stopTime.Unix(),
  342. PatientId: patient_id,
  343. OtherVascular: other_vascular,
  344. CiType: ci_type,
  345. BloodCultupe: blood_cultupe,
  346. SequelaeType: sequelae_type,
  347. }
  348. err := service.SaveVascularAccess(&access)
  349. if err == nil {
  350. this.ServeSuccessJSON(map[string]interface{}{
  351. "access": access,
  352. })
  353. return
  354. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  355. //if errcode == gorm.ErrRecordNotFound {
  356. // access := models.XtPatientVascularAccess{
  357. // AccessProject: access_project,
  358. // BloodAccessPartId: blood_access_part_id,
  359. // BloodAccessPartOperaId: blood_access_part_opera_id,
  360. // FirstStartTime: firstStartTime.Unix(),
  361. // InflowPass: inflow_pass,
  362. // Remark: remark,
  363. // StartTime: startTime.Unix(),
  364. // StopReason: stop_reason,
  365. // UserStatus: user_status,
  366. // Creator: creator,
  367. // UserOrgId: orgId,
  368. // Status: 1,
  369. // Ctime: time.Now().Unix(),
  370. // StopTime: stopTime.Unix(),
  371. // PatientId: patient_id,
  372. // OtherVascular: other_vascular,
  373. // CiType: ci_type,
  374. // BloodCultupe: blood_cultupe,
  375. // SequelaeType: sequelae_type,
  376. // }
  377. // err := service.SaveVascularAccess(&access)
  378. // if err == nil {
  379. // this.ServeSuccessJSON(map[string]interface{}{
  380. // "access": access,
  381. // })
  382. // return
  383. // }
  384. //} else if errcode == nil {
  385. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  386. // return
  387. }
  388. }
  389. func (this *DoctorsApiController) GetAllVacualAccessList() {
  390. limit, _ := this.GetInt64("limit")
  391. page, _ := this.GetInt64("page")
  392. patient_id, _ := this.GetInt64("patient_id")
  393. orgId := this.GetAdminUserInfo().CurrentOrgId
  394. appId := this.GetAdminUserInfo().CurrentAppId
  395. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  396. doctor, err := service.GetAllDoctor(orgId, appId)
  397. if err == nil {
  398. this.ServeSuccessJSON(map[string]interface{}{
  399. "list": list,
  400. "total": total,
  401. "doctor": doctor,
  402. })
  403. return
  404. }
  405. }
  406. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  407. id, _ := this.GetInt64("id")
  408. accessDetail, err := service.GetVasularAccessByDetail(id)
  409. orgId := this.GetAdminUserInfo().CurrentOrgId
  410. appId := this.GetAdminUserInfo().CurrentAppId
  411. doctor, err := service.GetAllDoctor(orgId, appId)
  412. if err == nil {
  413. this.ServeSuccessJSON(map[string]interface{}{
  414. "accessDetail": accessDetail,
  415. "doctor": doctor,
  416. })
  417. return
  418. }
  419. }
  420. func (this *DoctorsApiController) UpdateVasularAccess() {
  421. id, _ := this.GetInt64("id")
  422. access_project, _ := this.GetInt64("access_project")
  423. blood_access_part_id := this.GetString("blood_access_part_id")
  424. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  425. first_start_time := this.GetString("first_start_time")
  426. timeLayout := "2006-01-02"
  427. loc, _ := time.LoadLocation("Local")
  428. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  429. inflow_pass := this.GetString("inflow_pass")
  430. remark := this.GetString("remark")
  431. start_time := this.GetString("start_time")
  432. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  433. stop_reason := this.GetString("stop_reason")
  434. user_status, _ := this.GetInt64("user_status")
  435. stop_time := this.GetString("stop_time")
  436. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  437. adminUserInfo := this.GetAdminUserInfo()
  438. orgId := adminUserInfo.CurrentOrgId
  439. creator := adminUserInfo.AdminUser.Id
  440. patientId, _ := this.GetInt64("patient_id")
  441. other_vascular := this.GetString("other_vascular")
  442. ci_type, _ := this.GetInt64("ci_type")
  443. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  444. sequelae_type, _ := this.GetInt64("sequelae_type")
  445. access := models.XtPatientVascularAccess{
  446. AccessProject: access_project,
  447. BloodAccessPartId: blood_access_part_id,
  448. BloodAccessPartOperaId: blood_access_part_opera_id,
  449. FirstStartTime: firstStartTime.Unix(),
  450. InflowPass: inflow_pass,
  451. Remark: remark,
  452. StartTime: startTime.Unix(),
  453. StopReason: stop_reason,
  454. UserStatus: user_status,
  455. Modify: creator,
  456. UserOrgId: orgId,
  457. Status: 1,
  458. StopTime: stopTime.Unix(),
  459. OtherVascular: other_vascular,
  460. CiType: ci_type,
  461. BloodCultupe: blood_cultupe,
  462. SequelaeType: sequelae_type,
  463. PatientId: patientId,
  464. }
  465. err := service.UpdateVascularAccess(&access, id)
  466. if err == nil {
  467. this.ServeSuccessJSON(map[string]interface{}{
  468. "access": access,
  469. })
  470. return
  471. }
  472. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  473. //if errcode == gorm.ErrRecordNotFound {
  474. // err := service.UpdateVascularAccess(&access, id)
  475. // if err == nil {
  476. // this.ServeSuccessJSON(map[string]interface{}{
  477. // "access": access,
  478. // })
  479. // return
  480. // }
  481. //} else if errcode == nil {
  482. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  483. // return
  484. //}
  485. }
  486. func (this *DoctorsApiController) DeleteVasularAccess() {
  487. id, _ := this.GetInt64("id")
  488. err := service.DeleteVasularAccess(id)
  489. fmt.Println(err)
  490. returnData := make(map[string]interface{}, 0)
  491. returnData["msg"] = "ok"
  492. this.ServeSuccessJSON(returnData)
  493. return
  494. }
  495. func (this *DoctorsApiController) SavePassWayAssessment() {
  496. blood_dealwidth := this.GetString("blood_dealwith")
  497. blood_project := this.GetString("blood_project")
  498. blood_result := this.GetString("blood_result")
  499. creator, _ := this.GetInt64("creator")
  500. parent_id, _ := this.GetInt64("parent_id")
  501. patient_id, _ := this.GetInt64("patient_id")
  502. start_time := this.GetString("start_time")
  503. timeLayout := "2006-01-02"
  504. loc, _ := time.LoadLocation("Local")
  505. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  506. modify := this.GetAdminUserInfo().AdminUser.Id
  507. orgId := this.GetAdminUserInfo().CurrentOrgId
  508. assessment := models.XtPatientPasswayAssessment{
  509. StartTime: startTime.Unix(),
  510. BloodDealwith: blood_dealwidth,
  511. BloodProject: blood_project,
  512. BloodResult: blood_result,
  513. Creator: creator,
  514. PatientId: patient_id,
  515. ParentId: parent_id,
  516. Modify: modify,
  517. UserOrgId: orgId,
  518. Status: 1,
  519. Ctime: time.Now().Unix(),
  520. }
  521. err := service.CreatePatientWayAssessment(&assessment)
  522. if err == nil {
  523. this.ServeSuccessJSON(map[string]interface{}{
  524. "assessment": assessment,
  525. })
  526. return
  527. }
  528. }
  529. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  530. patient_id, _ := this.GetInt64("patient_id")
  531. parent_id, _ := this.GetInt64("parent_id")
  532. page, _ := this.GetInt64("page")
  533. limit, _ := this.GetInt64("limit")
  534. adminUserInfo := this.GetAdminUserInfo()
  535. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  536. if err == nil {
  537. this.ServeSuccessJSON(map[string]interface{}{
  538. "list": list,
  539. "total": total,
  540. })
  541. return
  542. }
  543. }
  544. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  545. id, _ := this.GetInt64("id")
  546. assessment, err := service.GetPasswayAssesmentById(id)
  547. if err == nil {
  548. this.ServeSuccessJSON(map[string]interface{}{
  549. "assessment": assessment,
  550. })
  551. return
  552. }
  553. }
  554. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  555. id, _ := this.GetInt64("id")
  556. blood_dealwidth := this.GetString("blood_dealwith")
  557. blood_project := this.GetString("blood_project")
  558. blood_result := this.GetString("blood_result")
  559. creator, _ := this.GetInt64("creator")
  560. start_time := this.GetString("start_time")
  561. timeLayout := "2006-01-02"
  562. loc, _ := time.LoadLocation("Local")
  563. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  564. modify := this.GetAdminUserInfo().AdminUser.Id
  565. assessment := models.XtPatientPasswayAssessment{
  566. BloodResult: blood_result,
  567. BloodDealwith: blood_dealwidth,
  568. BloodProject: blood_project,
  569. Creator: creator,
  570. StartTime: startTime.Unix(),
  571. Modify: modify,
  572. }
  573. err := service.UpdatePassWayAssesment(&assessment, id)
  574. if err == nil {
  575. this.ServeSuccessJSON(map[string]interface{}{
  576. "assessment": assessment,
  577. })
  578. return
  579. }
  580. }
  581. func (this *DoctorsApiController) DeleteWayAssessment() {
  582. id, _ := this.GetInt64("id")
  583. err := service.DeleteWayAssessment(id)
  584. fmt.Println(err)
  585. returnData := make(map[string]interface{}, 0)
  586. returnData["msg"] = "ok"
  587. this.ServeSuccessJSON(returnData)
  588. return
  589. }
  590. func (this *DoctorsApiController) GetAccessList() {
  591. adminUserInfo := this.GetAdminUserInfo()
  592. orgId := adminUserInfo.CurrentOrgId
  593. //血管通路
  594. list, err := service.GetAccessList(orgId)
  595. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  596. //血管通路部位
  597. access, err := service.GetBloodAccess(orgId)
  598. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  599. if err == nil {
  600. this.ServeSuccessJSON(map[string]interface{}{
  601. "blood_access_part_opera": blood_access_part_opera,
  602. "blood_access_part": blood_access_part,
  603. })
  604. return
  605. }
  606. }
  607. func (this *DoctorsApiController) GetInspectionMajorItem() {
  608. other_start_time := this.GetString("other_start_time")
  609. timeLayout := "2006-01-02"
  610. loc, _ := time.LoadLocation("Local")
  611. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
  612. fmt.Println("startTime2222345555533344334334433433344", startTime.Unix())
  613. patient_id, _ := this.GetInt64("patient_id")
  614. adminUserInfo := this.GetAdminUserInfo()
  615. orgId := adminUserInfo.CurrentOrgId
  616. list, err := service.GetInspectionMajorItem(startTime.Unix(), orgId, patient_id)
  617. if err == nil {
  618. this.ServeSuccessJSON(map[string]interface{}{
  619. "list": list,
  620. })
  621. return
  622. }
  623. }
  624. func (this *DoctorsApiController) GetInspectionDetailByProject() {
  625. project_id, _ := this.GetInt64("project_id")
  626. patient_id, _ := this.GetInt64("patient_id")
  627. inspect_date, _ := this.GetInt64("inspect_date")
  628. orgId := this.GetAdminUserInfo().CurrentOrgId
  629. list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
  630. if err == nil {
  631. this.ServeSuccessJSON(map[string]interface{}{
  632. "list": list,
  633. })
  634. return
  635. }
  636. }
  637. func (this *DoctorsApiController) GetInspectionItemlist() {
  638. patient_id, _ := this.GetInt64("patient_id")
  639. ids := this.GetString("ids")
  640. inspect_date := this.GetString("inspect_date")
  641. idSplit := strings.Split(ids, ",")
  642. indateSplit := strings.Split(inspect_date, ",")
  643. list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
  644. if err == nil {
  645. this.ServeSuccessJSON(map[string]interface{}{
  646. "list": list,
  647. })
  648. return
  649. }
  650. }
  651. func (this *DoctorsApiController) GetInitDateList() {
  652. patient_id, _ := this.GetInt64("patient_id")
  653. prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id)
  654. befor_list, err := service.GetDialysisBeforInitDateList(patient_id)
  655. after_list, err := service.GetDialysisAssementAfter(patient_id)
  656. //统计透析次数
  657. modelist, err := service.GetDialysisDialysisMode(patient_id)
  658. orgId := this.GetAdminUserInfo().CurrentOrgId
  659. docList, _ := service.GetAllDoctorThree(orgId)
  660. stockType, err := service.GetStockType(orgId)
  661. summaryList, err := service.GetTemplateSummary(orgId)
  662. planList, err := service.GetTemplatePlan(orgId)
  663. if err == nil {
  664. this.ServeSuccessJSON(map[string]interface{}{
  665. "beforlist": befor_list,
  666. "prescription_list": prescription_list,
  667. "after_list": after_list,
  668. "modelist": modelist,
  669. "docList": docList,
  670. "stockType": stockType,
  671. "summaryList": summaryList,
  672. "planList": planList,
  673. })
  674. return
  675. }
  676. }
  677. func (this *DoctorsApiController) SaveCreationInspection() {
  678. title := this.GetString("title")
  679. dry_weight, _ := this.GetFloat("dry_weight")
  680. fmt.Println("hhhhhhhhhhhhh", dry_weight)
  681. dialysis_count, _ := this.GetInt64("dialysis_count")
  682. hd_count, _ := this.GetInt64("hd_count")
  683. hdf_count, _ := this.GetInt64("hdf_count")
  684. hp_count, _ := this.GetInt64("hp_count")
  685. other_count, _ := this.GetInt64("other_count")
  686. dialzer_apparatus := this.GetString("dialzer_apparatus")
  687. perfusion_apparatus := this.GetString("perfusion_apparatus")
  688. anticoagulant, _ := this.GetInt64("anticoagulant")
  689. fmt.Println(anticoagulant)
  690. kalium, _ := this.GetFloat("kalium")
  691. autunite, _ := this.GetFloat("autunite")
  692. natrium, _ := this.GetFloat("natrium")
  693. hour, _ := this.GetInt64("hour")
  694. minute, _ := this.GetInt64("minute")
  695. befor_weight, _ := this.GetFloat("befor_weight")
  696. after_weight, _ := this.GetFloat("after_weight")
  697. befor_pressure := this.GetString("befor_pressure")
  698. template_summary_content := this.GetString("template_summary_content")
  699. template_plan_content := this.GetString("template_plan_content")
  700. template_inspection_content := this.GetString("template_inspection_content")
  701. fmt.Println("hhhh232233232232332232323", template_inspection_content)
  702. admin_user_id, _ := this.GetInt64("admin_user_id")
  703. record_time := this.GetString("record_time")
  704. timeLayout := "2006-01-02"
  705. loc, _ := time.LoadLocation("Local")
  706. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  707. after_pressure := this.GetString("after_pressure")
  708. template_summary_id, _ := this.GetInt64("template_summary_id")
  709. template_plan_id, _ := this.GetInt64("template_plan_id")
  710. template_inspection_id, _ := this.GetInt64("template_inspection_id")
  711. patient_id, _ := this.GetInt64("patient_id")
  712. fmt.Println("patient_id", patient_id)
  713. orgId := this.GetAdminUserInfo().CurrentOrgId
  714. summary := models.XtTemplateSummary{
  715. StartYear: 0,
  716. StartMonth: 0,
  717. Radio: 0,
  718. Quarter: 0,
  719. DryWeight: dry_weight,
  720. DialysisCount: dialysis_count,
  721. HdCount: hd_count,
  722. HdfCount: hdf_count,
  723. HpCount: hp_count,
  724. OtherCount: other_count,
  725. DialzerApparatus: dialzer_apparatus,
  726. PerfusionApparatus: perfusion_apparatus,
  727. Anticoagulant: anticoagulant,
  728. Kalium: kalium,
  729. Autunite: autunite,
  730. Natrium: natrium,
  731. Hour: hour,
  732. Minute: minute,
  733. BeforWeight: befor_weight,
  734. AfterWeight: after_weight,
  735. BeforPressure: befor_pressure,
  736. AfterPressure: after_pressure,
  737. TemplateSummaryId: template_summary_id,
  738. TemplateSummaryContent: template_summary_content,
  739. TemplatePlanId: template_plan_id,
  740. TemplatePlanContent: template_plan_content,
  741. TemplateInspectionId: template_inspection_id,
  742. TemplateInspectionContent: template_inspection_content,
  743. AdminUserId: admin_user_id,
  744. RecordTime: recordTime.Unix(),
  745. PatientId: patient_id,
  746. UserOrgId: orgId,
  747. Status: 1,
  748. Ctime: time.Now().Unix(),
  749. Mtime: 0,
  750. Title: title,
  751. }
  752. err := service.CreateSummary(&summary)
  753. if err == nil {
  754. this.ServeSuccessJSON(map[string]interface{}{
  755. "summary": summary,
  756. })
  757. return
  758. }
  759. }
  760. func (this *DoctorsApiController) GetTemplateSummaryList() {
  761. patient_id, _ := this.GetInt64("patient_id")
  762. orgId := this.GetAdminUserInfo().CurrentOrgId
  763. list, err := service.GetTemplateSummaryList(patient_id, orgId)
  764. if err == nil {
  765. this.ServeSuccessJSON(map[string]interface{}{
  766. "list": list,
  767. })
  768. return
  769. }
  770. }
  771. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  772. id, _ := this.GetInt64("id")
  773. list, err := service.GetTemplateSummaryDetail(id)
  774. if err == nil {
  775. this.ServeSuccessJSON(map[string]interface{}{
  776. "list": list,
  777. })
  778. return
  779. }
  780. }
  781. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  782. id, _ := this.GetInt64("id")
  783. list, err := service.GetTemplateSummaryPrintDetail(id)
  784. orgId := this.GetAdminUserInfo().CurrentOrgId
  785. doctorList, _ := service.GetAllDoctorThree(orgId)
  786. if err == nil {
  787. this.ServeSuccessJSON(map[string]interface{}{
  788. "list": list,
  789. "doctorList": doctorList,
  790. })
  791. return
  792. }
  793. }
  794. func (this *DoctorsApiController) UpdateTempalteSummary() {
  795. id, _ := this.GetInt64("id")
  796. title := this.GetString("title")
  797. dry_weight, _ := this.GetFloat("dry_weight")
  798. fmt.Println("hhhhhhhhhhhhh", dry_weight)
  799. dialysis_count, _ := this.GetInt64("dialysis_count")
  800. hd_count, _ := this.GetInt64("hd_count")
  801. hdf_count, _ := this.GetInt64("hdf_count")
  802. hp_count, _ := this.GetInt64("hp_count")
  803. other_count, _ := this.GetInt64("other_count")
  804. dialzer_apparatus := this.GetString("dialzer_apparatus")
  805. perfusion_apparatus := this.GetString("perfusion_apparatus")
  806. anticoagulant, _ := this.GetInt64("anticoagulant")
  807. fmt.Println(anticoagulant)
  808. kalium, _ := this.GetFloat("kalium")
  809. autunite, _ := this.GetFloat("autunite")
  810. natrium, _ := this.GetFloat("natrium")
  811. hour, _ := this.GetInt64("hour")
  812. minute, _ := this.GetInt64("minute")
  813. befor_weight, _ := this.GetFloat("befor_weight")
  814. after_weight, _ := this.GetFloat("after_weight")
  815. befor_pressure := this.GetString("befor_pressure")
  816. template_summary_content := this.GetString("template_summary_content")
  817. template_plan_content := this.GetString("template_plan_content")
  818. template_inspection_content := this.GetString("template_inspection_content")
  819. fmt.Println("hhhh232233232232332232323", template_inspection_content)
  820. admin_user_id, _ := this.GetInt64("admin_user_id")
  821. record_time := this.GetString("record_time")
  822. timeLayout := "2006-01-02"
  823. loc, _ := time.LoadLocation("Local")
  824. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  825. after_pressure := this.GetString("after_pressure")
  826. template_summary_id, _ := this.GetInt64("template_summary_id")
  827. template_plan_id, _ := this.GetInt64("template_plan_id")
  828. template_inspection_id, _ := this.GetInt64("template_inspection_id")
  829. patient_id, _ := this.GetInt64("patient_id")
  830. fmt.Println("patient_id", patient_id)
  831. orgId := this.GetAdminUserInfo().CurrentOrgId
  832. summary := models.XtTemplateSummary{
  833. ID: id,
  834. StartYear: 0,
  835. StartMonth: 0,
  836. Radio: 0,
  837. Quarter: 0,
  838. DryWeight: dry_weight,
  839. DialysisCount: dialysis_count,
  840. HdCount: hd_count,
  841. HdfCount: hdf_count,
  842. HpCount: hp_count,
  843. OtherCount: other_count,
  844. DialzerApparatus: dialzer_apparatus,
  845. PerfusionApparatus: perfusion_apparatus,
  846. Anticoagulant: anticoagulant,
  847. Kalium: kalium,
  848. Autunite: autunite,
  849. Natrium: natrium,
  850. Hour: hour,
  851. Minute: minute,
  852. BeforWeight: befor_weight,
  853. AfterWeight: after_weight,
  854. BeforPressure: befor_pressure,
  855. AfterPressure: after_pressure,
  856. TemplateSummaryId: template_summary_id,
  857. TemplateSummaryContent: template_summary_content,
  858. TemplatePlanId: template_plan_id,
  859. TemplatePlanContent: template_plan_content,
  860. TemplateInspectionId: template_inspection_id,
  861. TemplateInspectionContent: template_inspection_content,
  862. AdminUserId: admin_user_id,
  863. RecordTime: recordTime.Unix(),
  864. PatientId: patient_id,
  865. UserOrgId: orgId,
  866. Status: 1,
  867. Ctime: time.Now().Unix(),
  868. Mtime: 0,
  869. Title: title,
  870. }
  871. err := service.UpdateTempalteSummary(&summary)
  872. if err == nil {
  873. this.ServeSuccessJSON(map[string]interface{}{
  874. "list": summary,
  875. })
  876. return
  877. }
  878. }