doctors_api_controller.go 35KB

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