doctors_api_controller.go 51KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "github.com/jinzhu/gorm"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type DoctorsApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func DoctorApiRegistRouters() {
  19. beego.Router("/api/alldoctors", &DoctorsApiController{}, "get:GetAllDoctorAndNurse")
  20. beego.Router("/api/admin/users", &DoctorsApiController{}, "get:GetAllAdminUsers")
  21. beego.Router("/api/patient/getdryweightdata", &DoctorsApiController{}, "Get:GetDryWeightData")
  22. beego.Router("/api/patient/getAllDoctor", &DoctorsApiController{}, "Get:GetAllDoctor")
  23. beego.Router("/api/patient/updatedryweightdata", &DoctorsApiController{}, "Post:UpdatedDryWeightData")
  24. beego.Router("/api/patient/getalldata", &DoctorsApiController{}, "Get:GetAllData")
  25. beego.Router("/api/paients/getdryweightdetail", &DoctorsApiController{}, "Get:GetDryWeightDetail")
  26. beego.Router("/api/patients/modifydryweightdata", &DoctorsApiController{}, "Get:ModifydryWeightData")
  27. beego.Router("/api/patient/deletedryweight", &DoctorsApiController{}, "Delete:DeleteDryWeight")
  28. beego.Router("/api/schedule/advices", &DoctorsApiController{}, "Get:ScheduleAdvices")
  29. beego.Router("/api/schedule/getdoctoradvicecount", &DoctorsApiController{}, "Get:GetDoctorAdviceCount")
  30. beego.Router("/api/patient/savevasularaccess", &DoctorsApiController{}, "Get:SaveVasularAccess")
  31. beego.Router("/api/patient/getallvascualraccesslist", &DoctorsApiController{}, "Get:GetAllVacualAccessList")
  32. beego.Router("/api/patient/getvascularaccessbydetial", &DoctorsApiController{}, "Get:GetVascularAccessByDetail")
  33. beego.Router("/api/patient/updatevasularaccess", &DoctorsApiController{}, "Get:UpdateVasularAccess")
  34. beego.Router("/api/patient/deletevascularaccess", &DoctorsApiController{}, "Get:DeleteVasularAccess")
  35. beego.Router("/api/patient/savepasswayassessment", &DoctorsApiController{}, "Get:SavePassWayAssessment")
  36. beego.Router("/api/patient/getallpasswayassessment", &DoctorsApiController{}, "Get:GetAllPassWayAssessment")
  37. beego.Router("/api/patient/getpasswayassmentbyid", &DoctorsApiController{}, "Get:GetPasswayAssesmentById")
  38. beego.Router("/api/patient/updatepasswayassesment", &DoctorsApiController{}, "Get:UpdatePassWayAssesment")
  39. beego.Router("/api/patient/deletepasswayassessment", &DoctorsApiController{}, "Get:DeleteWayAssessment")
  40. beego.Router("/api/patient/getaccesslist", &DoctorsApiController{}, "Get:GetAccessList")
  41. //阶段小结路由
  42. beego.Router("/api/patient/getinspectionmajoritem", &DoctorsApiController{}, "Get:GetInspectionMajorItem")
  43. beego.Router("/api/patient/getinspectiondetail", &DoctorsApiController{}, "Get:GetInspectionDetailByProject")
  44. beego.Router("/api/patient/getinspectionitemlist", &DoctorsApiController{}, "Get:GetInspectionItemlist")
  45. beego.Router("/api/patient/getinitdatelist", &DoctorsApiController{}, "Get:GetInitDateList")
  46. beego.Router("/api/patient/savecreationinspection", &DoctorsApiController{}, "Post:SaveCreationInspection")
  47. beego.Router("/api/patient/getemlatesummarylist", &DoctorsApiController{}, "Get:GetTemplateSummaryList")
  48. beego.Router("/api/patient/gettemplatesummarydetail", &DoctorsApiController{}, "Get:GetTemplateSummaryDetail")
  49. beego.Router("/api/patient/gettemplatesummaryprintdetail", &DoctorsApiController{}, "Get:GetTemplateSummaryPrintDetail")
  50. beego.Router("/api/patient/updatetemplatesummary", &DoctorsApiController{}, "Post:UpdateTempalteSummary")
  51. beego.Router("/api/patient/deletesummary", &DoctorsApiController{}, "Get:DeleteSummary")
  52. beego.Router("/api/patient/hospitalsummary", &DoctorsApiController{}, "Post:HospitalSummary")
  53. beego.Router("/api/patient/gethospitalsummarylist", &DoctorsApiController{}, "Get:GetHospitalSummaryList")
  54. beego.Router("/api/patient/gethospitalsummaydetail", &DoctorsApiController{}, "Get:GetHospitalSummaryDetail")
  55. beego.Router("/api/patient/updatehospitalsummary", &DoctorsApiController{}, "Post:UpdateHospitalSummary")
  56. beego.Router("/api/patient/deletehospitalsummary", &DoctorsApiController{}, "Get:DeleteHospitalSummary")
  57. beego.Router("/api/patient/getpatientinfo", &DoctorsApiController{}, "Get:GetPatientInfo")
  58. }
  59. func (c *DoctorsApiController) ScheduleAdvices() {
  60. schedualDate := c.GetString("date")
  61. adviceType, _ := c.GetInt("advice_type")
  62. patientType, _ := c.GetInt("patient_type")
  63. delivery_way := c.GetString("delivery_way")
  64. schedule_type, _ := c.GetInt64("schedule_type")
  65. partition_type, _ := c.GetInt64("partition_type")
  66. patient_id, _ := c.GetInt64("patient_id")
  67. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  68. adviceType = 0
  69. }
  70. if patientType != 1 && patientType != 2 {
  71. patientType = 0
  72. }
  73. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  74. if parseDateErr != nil {
  75. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  76. return
  77. }
  78. adminUserInfo := c.GetAdminUserInfo()
  79. orgID := adminUserInfo.CurrentOrgId
  80. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id)
  81. hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id)
  82. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
  83. //project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
  84. for _, item := range project {
  85. index := 0
  86. for _, subItem := range item.HisPrescriptionTeamProject {
  87. if subItem.HisProject.CostClassify != 3 {
  88. subItem.IsCheckTeam = 2
  89. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  90. }
  91. if subItem.HisProject.CostClassify == 3 {
  92. subItem.IsCheckTeam = 1
  93. index = index + 1
  94. if index == 1 {
  95. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  96. }
  97. }
  98. }
  99. }
  100. //for _, item := range project {
  101. // index := 0
  102. // for _, subItem := range item.HisPrescriptionTeamProject {
  103. //
  104. // //获取所有的患者
  105. // patients, _ := service.GetAllPatientListByListTwo(orgID)
  106. //
  107. // //获取所有床位
  108. // numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
  109. //
  110. // //获取透析处方
  111. // prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
  112. //
  113. // //获取上机
  114. // dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
  115. // for key, item := range project {
  116. // for _, patient := range patients {
  117. // if item.PatientId == patient.ID {
  118. // project[key].SchedualPatient = patient
  119. // break
  120. // }
  121. // }
  122. // // 获取床位信息
  123. // for _, it := range numberList {
  124. // if item.BedId == it.ID {
  125. // project[key].DeviceNumber = it
  126. // break
  127. // }
  128. // }
  129. //
  130. // // 获取处方
  131. // for _, it := range prescriptions {
  132. // if item.PatientId == it.PatientId {
  133. // project[key].Prescription = it
  134. // break
  135. // }
  136. // }
  137. //
  138. // //获取上机
  139. // for _, it := range dialysisOrders {
  140. // if item.PatientId == it.PatientId {
  141. // project[key].DialysisOrder = it
  142. // break
  143. // }
  144. // }
  145. // }
  146. // if subItem.HisProject.CostClassify != 3 {
  147. // subItem.IsCheckTeam = 2
  148. // item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  149. // }
  150. //
  151. // if subItem.HisProject.CostClassify == 3 {
  152. // subItem.IsCheckTeam = 1
  153. // index = index + 1
  154. // if index == 1 {
  155. // item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  156. // }
  157. // }
  158. // }
  159. //}
  160. config, _ := service.GetHisDoctorConfig(orgID)
  161. project_config, _ := service.GetHisProjectConfig(orgID)
  162. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  163. if err != nil {
  164. c.ErrorLog("获取排班信息失败:%v", err)
  165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  166. } else {
  167. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  168. for _, schedual := range scheduals {
  169. if len(schedual.DoctorAdvices) > 0 {
  170. filtedScheduals = append(filtedScheduals, schedual)
  171. }
  172. }
  173. c.ServeSuccessJSON(map[string]interface{}{
  174. "scheduals": filtedScheduals,
  175. "adminUser": adminUser,
  176. "hisAdvices": hisAdvices,
  177. "config": config,
  178. "project_config": project_config,
  179. "project": project,
  180. })
  181. }
  182. }
  183. func (c *DoctorsApiController) GetAllDoctorAndNurse() {
  184. adminUserInfo := c.GetAdminUserInfo()
  185. doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  186. c.ServeSuccessJSON(map[string]interface{}{
  187. "doctors": doctors,
  188. "nursers": nursers,
  189. })
  190. return
  191. }
  192. func (c *DoctorsApiController) GetAllAdminUsers() {
  193. adminUserInfo := c.GetAdminUserInfo()
  194. users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
  195. c.ServeSuccessJSON(map[string]interface{}{
  196. "users": users,
  197. })
  198. return
  199. }
  200. func (c *DoctorsApiController) GetDryWeightData() {
  201. adminUserInfo := c.GetAdminUserInfo()
  202. orgid := adminUserInfo.CurrentOrgId
  203. patientid, _ := c.GetInt64("patientid")
  204. fmt.Println("patientid", patientid)
  205. id := adminUserInfo.AdminUser.Id
  206. fmt.Println("id", id)
  207. recordDateStr := time.Now().Format("2006-01-02")
  208. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  209. fmt.Scan("parseDateErr", parseDateErr)
  210. nowtime := recordDate.Unix()
  211. fmt.Println("nowtime", nowtime)
  212. pre, err := service.GetDryWeightByPatientId(patientid, orgid)
  213. fmt.Println("错误", err)
  214. c.ServeSuccessJSON(map[string]interface{}{
  215. "pre": pre,
  216. })
  217. }
  218. func (c *DoctorsApiController) GetAllDoctor() {
  219. adminUserInfo := c.GetAdminUserInfo()
  220. orgid := adminUserInfo.CurrentOrgId
  221. appid := adminUserInfo.CurrentAppId
  222. fmt.Println("appid", appid)
  223. appRole, err := service.GetAllDoctor(orgid, appid)
  224. fmt.Println("appRole", appRole)
  225. fmt.Println("错误", err)
  226. c.ServeSuccessJSON(map[string]interface{}{
  227. "appRole": appRole,
  228. })
  229. }
  230. func (c *DoctorsApiController) UpdatedDryWeightData() {
  231. adminUserInfo := c.GetAdminUserInfo()
  232. orgid := adminUserInfo.CurrentOrgId
  233. userid := adminUserInfo.AdminUser.Id
  234. dry_weight, _ := c.GetFloat("dry_weight")
  235. doctors, _ := c.GetInt64("doctors")
  236. remarks := c.GetString("remarks")
  237. patientid, _ := c.GetInt64("patient_id")
  238. //透前数据
  239. dryweight, _ := c.GetFloat("dryweight")
  240. var weight = dryweight - dry_weight
  241. weights := fmt.Sprintf("%.1f", weight)
  242. var sum string
  243. _, errcode := service.QueryDryWeight(orgid, patientid)
  244. if errcode == gorm.ErrRecordNotFound {
  245. sum = "/"
  246. patientDryweight := models.SgjPatientDryweight{
  247. DryWeight: dry_weight,
  248. Creator: doctors,
  249. Remakes: remarks,
  250. AdjustedValue: sum,
  251. PatientId: patientid,
  252. Ctime: time.Now().Unix(),
  253. UserOrgId: orgid,
  254. Status: 1,
  255. UserId: userid,
  256. }
  257. err := service.CreatePatientWeight(&patientDryweight)
  258. loc, _ := time.LoadLocation("Local")
  259. nowTime := time.Now()
  260. nowDay := nowTime.Format("2006-01-02")
  261. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  262. redis := service.RedisClient()
  263. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  264. redis.Set(keyTwo, "", time.Second)
  265. prescription := models.PredialysisEvaluation{
  266. DryWeight: dry_weight,
  267. AssessmentDate: dayTime.Unix(),
  268. }
  269. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  270. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  271. fmt.Println(errors)
  272. }
  273. keyThree := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  274. redis.Set(keyThree, "", time.Second)
  275. keyFive := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  276. redis.Set(keyFive, "", time.Second)
  277. redis.Close()
  278. fmt.Println("err", err)
  279. c.ServeSuccessJSON(map[string]interface{}{
  280. "patientDryweight": patientDryweight,
  281. })
  282. return
  283. }
  284. fmt.Println("sum", sum)
  285. if weight == 0 {
  286. sum = "/"
  287. }
  288. if weight > 0 {
  289. sum = weights + "(" + "下调" + ")"
  290. }
  291. if weight < 0 {
  292. var sums = dry_weight - dryweight
  293. float := fmt.Sprintf("%.1f", sums)
  294. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  295. sum = float + "(" + "上调" + ")"
  296. }
  297. patientDryweight := models.SgjPatientDryweight{
  298. DryWeight: dry_weight,
  299. Creator: doctors,
  300. Remakes: remarks,
  301. AdjustedValue: sum,
  302. PatientId: patientid,
  303. Ctime: time.Now().Unix(),
  304. UserOrgId: orgid,
  305. Status: 1,
  306. UserId: userid,
  307. }
  308. err := service.CreatePatientWeight(&patientDryweight)
  309. recordDateStr := time.Now().Format("2006-01-02")
  310. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  311. fmt.Scan("parseDateErr", parseDateErr)
  312. nowtime := recordDate.Unix()
  313. fmt.Println("nowtime", nowtime)
  314. loc, _ := time.LoadLocation("Local")
  315. nowTime := time.Now()
  316. nowDay := nowTime.Format("2006-01-02")
  317. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  318. redis := service.RedisClient()
  319. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  320. redis.Set(keyTwo, "", time.Second)
  321. prescription := models.PredialysisEvaluation{
  322. DryWeight: dry_weight,
  323. AssessmentDate: dayTime.Unix(),
  324. }
  325. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  326. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  327. fmt.Println(errors)
  328. }
  329. key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  330. redis.Set(key, "", time.Second)
  331. keySix := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  332. redis.Set(keySix, "", time.Second)
  333. fmt.Println("err", err)
  334. redis.Close()
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "patientDryweight": patientDryweight,
  337. })
  338. }
  339. func (c *DoctorsApiController) GetAllData() {
  340. id, _ := c.GetInt64("id")
  341. page, _ := c.GetInt64("page")
  342. fmt.Println("page", page)
  343. limit, _ := c.GetInt64("limit")
  344. fmt.Println("limit", limit)
  345. fmt.Println("id", id)
  346. adminUserInfo := c.GetAdminUserInfo()
  347. orgid := adminUserInfo.CurrentOrgId
  348. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  349. c.ServeSuccessJSON(map[string]interface{}{
  350. "dry": dry,
  351. "total": total,
  352. })
  353. }
  354. func (c *DoctorsApiController) GetDryWeightDetail() {
  355. id, _ := c.GetInt64("id")
  356. dryweight, _ := service.GetDryWeightDetailById(id)
  357. c.ServeSuccessJSON(map[string]interface{}{
  358. "dryweight": dryweight,
  359. })
  360. }
  361. func (c *DoctorsApiController) ModifydryWeightData() {
  362. adjustvalue := c.GetString("adjustvalue")
  363. creator, _ := c.GetInt64("creator")
  364. dryweight, _ := c.GetInt64("dryweight")
  365. dry := strconv.FormatInt(dryweight, 10)
  366. dry_weight, _ := strconv.ParseFloat(dry, 64)
  367. id, _ := c.GetInt64("id")
  368. remark := c.GetString("remark")
  369. patientDryweight := models.SgjPatientDryweight{
  370. AdjustedValue: adjustvalue,
  371. Creator: creator,
  372. DryWeight: dry_weight,
  373. Remakes: remark,
  374. }
  375. service.ModifyDryWeightData(&patientDryweight, id)
  376. c.ServeSuccessJSON(map[string]interface{}{
  377. "patientDryweight": patientDryweight,
  378. })
  379. }
  380. func (c *DoctorsApiController) DeleteDryWeight() {
  381. id, _ := c.GetInt64("id")
  382. service.DeleteDryWeight(id)
  383. returnData := make(map[string]interface{}, 0)
  384. returnData["msg"] = "ok"
  385. c.ServeSuccessJSON(returnData)
  386. return
  387. }
  388. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  389. timeLayout := "2006-01-02"
  390. loc, _ := time.LoadLocation("Local")
  391. start_time := c.GetString("start_time")
  392. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  393. end_time := c.GetString("end_time")
  394. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  395. delive_way := c.GetString("delive_way")
  396. adminUserInfo := c.GetAdminUserInfo()
  397. orgId := adminUserInfo.CurrentOrgId
  398. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  399. if len(list) == 0 {
  400. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  401. c.ServeSuccessJSON(map[string]interface{}{
  402. "list": list,
  403. })
  404. } else {
  405. c.ServeSuccessJSON(map[string]interface{}{
  406. "list": list,
  407. })
  408. }
  409. }
  410. func (this *DoctorsApiController) SaveVasularAccess() {
  411. access_project, _ := this.GetInt64("access_project")
  412. blood_access_part_id := this.GetString("blood_access_part_id")
  413. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  414. first_start_time := this.GetString("first_start_time")
  415. timeLayout := "2006-01-02"
  416. loc, _ := time.LoadLocation("Local")
  417. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  418. inflow_pass := this.GetString("inflow_pass")
  419. remark := this.GetString("remark")
  420. start_time := this.GetString("start_time")
  421. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  422. stop_reason := this.GetString("stop_reason")
  423. user_status, _ := this.GetInt64("user_status")
  424. stop_time := this.GetString("stop_time")
  425. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  426. patient_id, _ := this.GetInt64("patient_id")
  427. other_vascular := this.GetString("other_vascular")
  428. ci_type, _ := this.GetInt64("ci_type")
  429. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  430. sequelae_type, _ := this.GetInt64("sequelae_type")
  431. adminUserInfo := this.GetAdminUserInfo()
  432. orgId := adminUserInfo.CurrentOrgId
  433. creator := adminUserInfo.AdminUser.Id
  434. //查询改日期是否存在
  435. access := models.XtPatientVascularAccess{
  436. AccessProject: access_project,
  437. BloodAccessPartId: blood_access_part_id,
  438. BloodAccessPartOperaId: blood_access_part_opera_id,
  439. FirstStartTime: firstStartTime.Unix(),
  440. InflowPass: inflow_pass,
  441. Remark: remark,
  442. StartTime: startTime.Unix(),
  443. StopReason: stop_reason,
  444. UserStatus: user_status,
  445. Creator: creator,
  446. UserOrgId: orgId,
  447. Status: 1,
  448. Ctime: time.Now().Unix(),
  449. StopTime: stopTime.Unix(),
  450. PatientId: patient_id,
  451. OtherVascular: other_vascular,
  452. CiType: ci_type,
  453. BloodCultupe: blood_cultupe,
  454. SequelaeType: sequelae_type,
  455. }
  456. err := service.SaveVascularAccess(&access)
  457. if err == nil {
  458. this.ServeSuccessJSON(map[string]interface{}{
  459. "access": access,
  460. })
  461. return
  462. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  463. //if errcode == gorm.ErrRecordNotFound {
  464. // access := models.XtPatientVascularAccess{
  465. // AccessProject: access_project,
  466. // BloodAccessPartId: blood_access_part_id,
  467. // BloodAccessPartOperaId: blood_access_part_opera_id,
  468. // FirstStartTime: firstStartTime.Unix(),
  469. // InflowPass: inflow_pass,
  470. // Remark: remark,
  471. // StartTime: startTime.Unix(),
  472. // StopReason: stop_reason,
  473. // UserStatus: user_status,
  474. // Creator: creator,
  475. // UserOrgId: orgId,
  476. // Status: 1,
  477. // Ctime: time.Now().Unix(),
  478. // StopTime: stopTime.Unix(),
  479. // PatientId: patient_id,
  480. // OtherVascular: other_vascular,
  481. // CiType: ci_type,
  482. // BloodCultupe: blood_cultupe,
  483. // SequelaeType: sequelae_type,
  484. // }
  485. // err := service.SaveVascularAccess(&access)
  486. // if err == nil {
  487. // this.ServeSuccessJSON(map[string]interface{}{
  488. // "access": access,
  489. // })
  490. // return
  491. // }
  492. //} else if errcode == nil {
  493. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  494. // return
  495. }
  496. }
  497. func (this *DoctorsApiController) GetAllVacualAccessList() {
  498. limit, _ := this.GetInt64("limit")
  499. page, _ := this.GetInt64("page")
  500. patient_id, _ := this.GetInt64("patient_id")
  501. orgId := this.GetAdminUserInfo().CurrentOrgId
  502. appId := this.GetAdminUserInfo().CurrentAppId
  503. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  504. doctor, err := service.GetAllDoctor(orgId, appId)
  505. if err == nil {
  506. this.ServeSuccessJSON(map[string]interface{}{
  507. "list": list,
  508. "total": total,
  509. "doctor": doctor,
  510. })
  511. return
  512. }
  513. }
  514. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  515. id, _ := this.GetInt64("id")
  516. accessDetail, err := service.GetVasularAccessByDetail(id)
  517. orgId := this.GetAdminUserInfo().CurrentOrgId
  518. appId := this.GetAdminUserInfo().CurrentAppId
  519. doctor, err := service.GetAllDoctor(orgId, appId)
  520. if err == nil {
  521. this.ServeSuccessJSON(map[string]interface{}{
  522. "accessDetail": accessDetail,
  523. "doctor": doctor,
  524. })
  525. return
  526. }
  527. }
  528. func (this *DoctorsApiController) UpdateVasularAccess() {
  529. id, _ := this.GetInt64("id")
  530. access_project, _ := this.GetInt64("access_project")
  531. blood_access_part_id := this.GetString("blood_access_part_id")
  532. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  533. first_start_time := this.GetString("first_start_time")
  534. timeLayout := "2006-01-02"
  535. loc, _ := time.LoadLocation("Local")
  536. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  537. inflow_pass := this.GetString("inflow_pass")
  538. remark := this.GetString("remark")
  539. start_time := this.GetString("start_time")
  540. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  541. stop_reason := this.GetString("stop_reason")
  542. user_status, _ := this.GetInt64("user_status")
  543. stop_time := this.GetString("stop_time")
  544. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  545. adminUserInfo := this.GetAdminUserInfo()
  546. orgId := adminUserInfo.CurrentOrgId
  547. creator := adminUserInfo.AdminUser.Id
  548. patientId, _ := this.GetInt64("patient_id")
  549. other_vascular := this.GetString("other_vascular")
  550. ci_type, _ := this.GetInt64("ci_type")
  551. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  552. sequelae_type, _ := this.GetInt64("sequelae_type")
  553. access := models.XtPatientVascularAccess{
  554. AccessProject: access_project,
  555. BloodAccessPartId: blood_access_part_id,
  556. BloodAccessPartOperaId: blood_access_part_opera_id,
  557. FirstStartTime: firstStartTime.Unix(),
  558. InflowPass: inflow_pass,
  559. Remark: remark,
  560. StartTime: startTime.Unix(),
  561. StopReason: stop_reason,
  562. UserStatus: user_status,
  563. Modify: creator,
  564. UserOrgId: orgId,
  565. Status: 1,
  566. StopTime: stopTime.Unix(),
  567. OtherVascular: other_vascular,
  568. CiType: ci_type,
  569. BloodCultupe: blood_cultupe,
  570. SequelaeType: sequelae_type,
  571. PatientId: patientId,
  572. }
  573. err := service.UpdateVascularAccess(&access, id)
  574. if err == nil {
  575. this.ServeSuccessJSON(map[string]interface{}{
  576. "access": access,
  577. })
  578. return
  579. }
  580. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  581. //if errcode == gorm.ErrRecordNotFound {
  582. // err := service.UpdateVascularAccess(&access, id)
  583. // if err == nil {
  584. // this.ServeSuccessJSON(map[string]interface{}{
  585. // "access": access,
  586. // })
  587. // return
  588. // }
  589. //} else if errcode == nil {
  590. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  591. // return
  592. //}
  593. }
  594. func (this *DoctorsApiController) DeleteVasularAccess() {
  595. id, _ := this.GetInt64("id")
  596. err := service.DeleteVasularAccess(id)
  597. fmt.Println(err)
  598. returnData := make(map[string]interface{}, 0)
  599. returnData["msg"] = "ok"
  600. this.ServeSuccessJSON(returnData)
  601. return
  602. }
  603. func (this *DoctorsApiController) SavePassWayAssessment() {
  604. blood_dealwidth := this.GetString("blood_dealwith")
  605. blood_project := this.GetString("blood_project")
  606. blood_result := this.GetString("blood_result")
  607. creator, _ := this.GetInt64("creator")
  608. parent_id, _ := this.GetInt64("parent_id")
  609. patient_id, _ := this.GetInt64("patient_id")
  610. start_time := this.GetString("start_time")
  611. timeLayout := "2006-01-02"
  612. loc, _ := time.LoadLocation("Local")
  613. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  614. modify := this.GetAdminUserInfo().AdminUser.Id
  615. orgId := this.GetAdminUserInfo().CurrentOrgId
  616. assessment := models.XtPatientPasswayAssessment{
  617. StartTime: startTime.Unix(),
  618. BloodDealwith: blood_dealwidth,
  619. BloodProject: blood_project,
  620. BloodResult: blood_result,
  621. Creator: creator,
  622. PatientId: patient_id,
  623. ParentId: parent_id,
  624. Modify: modify,
  625. UserOrgId: orgId,
  626. Status: 1,
  627. Ctime: time.Now().Unix(),
  628. }
  629. err := service.CreatePatientWayAssessment(&assessment)
  630. if err == nil {
  631. this.ServeSuccessJSON(map[string]interface{}{
  632. "assessment": assessment,
  633. })
  634. return
  635. }
  636. }
  637. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  638. patient_id, _ := this.GetInt64("patient_id")
  639. parent_id, _ := this.GetInt64("parent_id")
  640. page, _ := this.GetInt64("page")
  641. limit, _ := this.GetInt64("limit")
  642. adminUserInfo := this.GetAdminUserInfo()
  643. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  644. if err == nil {
  645. this.ServeSuccessJSON(map[string]interface{}{
  646. "list": list,
  647. "total": total,
  648. })
  649. return
  650. }
  651. }
  652. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  653. id, _ := this.GetInt64("id")
  654. assessment, err := service.GetPasswayAssesmentById(id)
  655. if err == nil {
  656. this.ServeSuccessJSON(map[string]interface{}{
  657. "assessment": assessment,
  658. })
  659. return
  660. }
  661. }
  662. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  663. id, _ := this.GetInt64("id")
  664. blood_dealwidth := this.GetString("blood_dealwith")
  665. blood_project := this.GetString("blood_project")
  666. blood_result := this.GetString("blood_result")
  667. creator, _ := this.GetInt64("creator")
  668. start_time := this.GetString("start_time")
  669. timeLayout := "2006-01-02"
  670. loc, _ := time.LoadLocation("Local")
  671. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  672. modify := this.GetAdminUserInfo().AdminUser.Id
  673. assessment := models.XtPatientPasswayAssessment{
  674. BloodResult: blood_result,
  675. BloodDealwith: blood_dealwidth,
  676. BloodProject: blood_project,
  677. Creator: creator,
  678. StartTime: startTime.Unix(),
  679. Modify: modify,
  680. }
  681. err := service.UpdatePassWayAssesment(&assessment, id)
  682. if err == nil {
  683. this.ServeSuccessJSON(map[string]interface{}{
  684. "assessment": assessment,
  685. })
  686. return
  687. }
  688. }
  689. func (this *DoctorsApiController) DeleteWayAssessment() {
  690. id, _ := this.GetInt64("id")
  691. err := service.DeleteWayAssessment(id)
  692. fmt.Println(err)
  693. returnData := make(map[string]interface{}, 0)
  694. returnData["msg"] = "ok"
  695. this.ServeSuccessJSON(returnData)
  696. return
  697. }
  698. func (this *DoctorsApiController) GetAccessList() {
  699. adminUserInfo := this.GetAdminUserInfo()
  700. orgId := adminUserInfo.CurrentOrgId
  701. //血管通路
  702. list, err := service.GetAccessList(orgId)
  703. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  704. //血管通路部位
  705. access, err := service.GetBloodAccess(orgId)
  706. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  707. if err == nil {
  708. this.ServeSuccessJSON(map[string]interface{}{
  709. "blood_access_part_opera": blood_access_part_opera,
  710. "blood_access_part": blood_access_part,
  711. })
  712. return
  713. }
  714. }
  715. func (this *DoctorsApiController) GetInspectionMajorItem() {
  716. other_start_time := this.GetString("other_start_time")
  717. last_time := this.GetString("last_time")
  718. timeLayout := "2006-01-02"
  719. loc, _ := time.LoadLocation("Local")
  720. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
  721. lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
  722. patient_id, _ := this.GetInt64("patient_id")
  723. adminUserInfo := this.GetAdminUserInfo()
  724. orgId := adminUserInfo.CurrentOrgId
  725. list, err := service.GetInspectionMajorItem(startTime.Unix(), lastTime.Unix(), orgId, patient_id)
  726. if err == nil {
  727. this.ServeSuccessJSON(map[string]interface{}{
  728. "list": list,
  729. })
  730. return
  731. }
  732. }
  733. func (this *DoctorsApiController) GetInspectionDetailByProject() {
  734. project_id, _ := this.GetInt64("project_id")
  735. patient_id, _ := this.GetInt64("patient_id")
  736. inspect_date, _ := this.GetInt64("inspect_date")
  737. orgId := this.GetAdminUserInfo().CurrentOrgId
  738. list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
  739. if err == nil {
  740. this.ServeSuccessJSON(map[string]interface{}{
  741. "list": list,
  742. })
  743. return
  744. }
  745. }
  746. func (this *DoctorsApiController) GetInspectionItemlist() {
  747. patient_id, _ := this.GetInt64("patient_id")
  748. ids := this.GetString("ids")
  749. inspect_date := this.GetString("inspect_date")
  750. idSplit := strings.Split(ids, ",")
  751. indateSplit := strings.Split(inspect_date, ",")
  752. list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
  753. if err == nil {
  754. this.ServeSuccessJSON(map[string]interface{}{
  755. "list": list,
  756. })
  757. return
  758. }
  759. }
  760. func (this *DoctorsApiController) GetInitDateList() {
  761. patient_id, _ := this.GetInt64("patient_id")
  762. start_time := this.GetString("start_time")
  763. timeLayout := "2006-01-02"
  764. loc, _ := time.LoadLocation("Local")
  765. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  766. end_time := this.GetString("end_time")
  767. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  768. fmt.Println("endtime2323232233223232332", endTime)
  769. prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
  770. befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
  771. after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
  772. orgId := this.GetAdminUserInfo().CurrentOrgId
  773. //统计透析次数
  774. modelist, err := service.GetDialysisDialysisMode(patient_id, startTime.Unix(), endTime.Unix(), orgId)
  775. docList, _ := service.GetAllDoctorThree(orgId)
  776. stockType, err := service.GetStockType(orgId)
  777. summaryList, err := service.GetTemplateSummary(orgId)
  778. planList, err := service.GetTemplatePlan(orgId)
  779. if err == nil {
  780. this.ServeSuccessJSON(map[string]interface{}{
  781. "beforlist": befor_list,
  782. "prescription_list": prescription_list,
  783. "after_list": after_list,
  784. "modelist": modelist,
  785. "docList": docList,
  786. "stockType": stockType,
  787. "summaryList": summaryList,
  788. "planList": planList,
  789. })
  790. return
  791. }
  792. }
  793. func (this *DoctorsApiController) SaveCreationInspection() {
  794. dataBody := make(map[string]interface{}, 0)
  795. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  796. if err != nil {
  797. utils.ErrorLog(err.Error())
  798. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  799. return
  800. }
  801. title := dataBody["title"].(string)
  802. dryWeight := dataBody["dry_weight"].(string)
  803. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  804. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  805. hd_count := int64(dataBody["hd_count"].(float64))
  806. hdf_count := int64(dataBody["hdf_count"].(float64))
  807. hp_count := int64(dataBody["hp_count"].(float64))
  808. other_count := int64(dataBody["other_count"].(float64))
  809. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  810. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  811. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  812. kaliumstr := dataBody["kalium"].(string)
  813. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  814. autunitestr := dataBody["autunite"].(string)
  815. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  816. natriumstr := dataBody["natrium"].(string)
  817. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  818. hour := int64(dataBody["hour"].(float64))
  819. minute := int64(dataBody["minute"].(float64))
  820. beforWeight := dataBody["befor_weight"].(string)
  821. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  822. afterWeight := dataBody["after_weight"].(string)
  823. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  824. befor_pressure := dataBody["befor_pressure"].(string)
  825. template_summary_content := dataBody["template_summary_content"].(string)
  826. template_plan_content := dataBody["template_plan_content"].(string)
  827. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  828. record_time := dataBody["record_time"].(string)
  829. timeLayout := "2006-01-02"
  830. loc, _ := time.LoadLocation("Local")
  831. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  832. after_pressure := dataBody["after_pressure"].(string)
  833. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  834. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  835. patient_id := int64(dataBody["patient_id"].(float64))
  836. orgId := this.GetAdminUserInfo().CurrentOrgId
  837. inspect_date := dataBody["inspect_date"].(string)
  838. project_id := dataBody["project_id"].(string)
  839. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  840. //title := this.GetString("title")
  841. //dryWeight := this.GetString("dry_weight")
  842. //dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  843. //dialysis_count, _ := this.GetInt64("dialysis_count")
  844. //hd_count, _ := this.GetInt64("hd_count")
  845. //hdf_count, _ := this.GetInt64("hdf_count")
  846. //hp_count, _ := this.GetInt64("hp_count")
  847. //other_count, _ := this.GetInt64("other_count")
  848. //dialzer_apparatus := this.GetString("dialzer_apparatus")
  849. //perfusion_apparatus := this.GetString("perfusion_apparatus")
  850. //anticoagulant, _ := this.GetInt64("anticoagulant")
  851. //kaliumstr := this.GetString("kalium")
  852. //kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  853. //
  854. //autunitestr := this.GetString("autunite")
  855. //autunite, _ := strconv.ParseFloat(autunitestr, 64)
  856. //natriumstr := this.GetString("natrium")
  857. //natrium, _ := strconv.ParseFloat(natriumstr, 64)
  858. //hour, _ := this.GetInt64("hour")
  859. //minute, _ := this.GetInt64("minute")
  860. //beforWeight := this.GetString("befor_weight")
  861. //befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  862. //afterWeight := this.GetString("after_weight")
  863. //after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  864. //befor_pressure := this.GetString("befor_pressure")
  865. //template_summary_content := this.GetString("template_summary_content")
  866. //template_plan_content := this.GetString("template_plan_content")
  867. //admin_user_id, _ := this.GetInt64("admin_user_id")
  868. //record_time := this.GetString("record_time")
  869. //timeLayout := "2006-01-02"
  870. //loc, _ := time.LoadLocation("Local")
  871. //recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  872. //after_pressure := this.GetString("after_pressure")
  873. //template_summary_id, _ := this.GetInt64("template_summary_id")
  874. //template_plan_id, _ := this.GetInt64("template_plan_id")
  875. //template_inspection_id, _ := this.GetInt64("template_inspection_id")
  876. //patient_id, _ := this.GetInt64("patient_id")
  877. //fmt.Println("patient_id", patient_id)
  878. //orgId := this.GetAdminUserInfo().CurrentOrgId
  879. //inspect_date := this.GetString("inspect_date")
  880. //project_id := this.GetString("project_id")
  881. summary := models.XtTemplateSummary{
  882. StartYear: 0,
  883. StartMonth: 0,
  884. Radio: 0,
  885. Quarter: 0,
  886. DryWeight: dry_weight,
  887. DialysisCount: dialysis_count,
  888. HdCount: hd_count,
  889. HdfCount: hdf_count,
  890. HpCount: hp_count,
  891. OtherCount: other_count,
  892. DialzerApparatus: dialzer_apparatus,
  893. PerfusionApparatus: perfusion_apparatus,
  894. Anticoagulant: anticoagulant,
  895. Kalium: kalium,
  896. Autunite: autunite,
  897. Natrium: natrium,
  898. Hour: hour,
  899. Minute: minute,
  900. BeforWeight: befor_weight,
  901. AfterWeight: after_weight,
  902. BeforPressure: befor_pressure,
  903. AfterPressure: after_pressure,
  904. TemplateSummaryId: template_summary_id,
  905. TemplateSummaryContent: template_summary_content,
  906. TemplatePlanId: template_plan_id,
  907. TemplatePlanContent: template_plan_content,
  908. TemplateInspectionId: template_inspection_id,
  909. AdminUserId: admin_user_id,
  910. RecordTime: recordTime.Unix(),
  911. PatientId: patient_id,
  912. UserOrgId: orgId,
  913. Status: 1,
  914. Ctime: time.Now().Unix(),
  915. Mtime: 0,
  916. Title: title,
  917. InspectDate: inspect_date,
  918. ProjectId: project_id,
  919. }
  920. err = service.CreateSummary(&summary)
  921. if err == nil {
  922. this.ServeSuccessJSON(map[string]interface{}{
  923. "summary": summary,
  924. })
  925. return
  926. }
  927. }
  928. func (this *DoctorsApiController) GetTemplateSummaryList() {
  929. patient_id, _ := this.GetInt64("patient_id")
  930. start_time := this.GetString("start_time")
  931. timeLayout := "2006-01-02"
  932. loc, _ := time.LoadLocation("Local")
  933. end_time := this.GetString("end_time")
  934. orgId := this.GetAdminUserInfo().CurrentOrgId
  935. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  936. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  937. list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
  938. if err == nil {
  939. this.ServeSuccessJSON(map[string]interface{}{
  940. "list": list,
  941. })
  942. return
  943. }
  944. }
  945. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  946. id, _ := this.GetInt64("id")
  947. list, err := service.GetTemplateSummaryDetail(id)
  948. ids := strings.Split(list.ProjectId, ",")
  949. datelist := strings.Split(list.InspectDate, ",")
  950. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  951. if err == nil {
  952. this.ServeSuccessJSON(map[string]interface{}{
  953. "list": list,
  954. "inspectlist": inspectlist,
  955. })
  956. return
  957. }
  958. }
  959. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  960. id, _ := this.GetInt64("id")
  961. list, err := service.GetTemplateSummaryPrintDetail(id)
  962. ids := strings.Split(list.ProjectId, ",")
  963. datelist := strings.Split(list.InspectDate, ",")
  964. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  965. orgId := this.GetAdminUserInfo().CurrentOrgId
  966. doctorList, _ := service.GetAllDoctorThree(orgId)
  967. if err == nil {
  968. this.ServeSuccessJSON(map[string]interface{}{
  969. "list": list,
  970. "doctorList": doctorList,
  971. "inspectlist": inspectlist,
  972. })
  973. return
  974. }
  975. }
  976. func (this *DoctorsApiController) UpdateTempalteSummary() {
  977. dataBody := make(map[string]interface{}, 0)
  978. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  979. if err != nil {
  980. utils.ErrorLog(err.Error())
  981. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  982. return
  983. }
  984. id, _ := this.GetInt64("id")
  985. title := this.GetString("title")
  986. dryWeight := this.GetString("dry_weight")
  987. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  988. dialysis_count, _ := this.GetInt64("dialysis_count")
  989. hd_count, _ := this.GetInt64("hd_count")
  990. hdf_count, _ := this.GetInt64("hdf_count")
  991. hp_count, _ := this.GetInt64("hp_count")
  992. other_count, _ := this.GetInt64("other_count")
  993. dialzer_apparatus := this.GetString("dialzer_apparatus")
  994. perfusion_apparatus := this.GetString("perfusion_apparatus")
  995. anticoagulant, _ := this.GetInt64("anticoagulant")
  996. kaliumstr := this.GetString("kalium")
  997. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  998. autunitestr := this.GetString("autunite")
  999. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  1000. natriumstr := this.GetString("natrium")
  1001. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  1002. hour, _ := this.GetInt64("hour")
  1003. minute, _ := this.GetInt64("minute")
  1004. beforWeight := this.GetString("befor_weight")
  1005. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  1006. afterWeight := this.GetString("after_weight")
  1007. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  1008. befor_pressure := this.GetString("befor_pressure")
  1009. template_summary_content := this.GetString("template_summary_content")
  1010. template_plan_content := this.GetString("template_plan_content")
  1011. admin_user_id, _ := this.GetInt64("admin_user_id")
  1012. record_time := this.GetString("record_time")
  1013. timeLayout := "2006-01-02"
  1014. loc, _ := time.LoadLocation("Local")
  1015. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  1016. after_pressure := this.GetString("after_pressure")
  1017. template_summary_id, _ := this.GetInt64("template_summary_id")
  1018. template_plan_id, _ := this.GetInt64("template_plan_id")
  1019. template_inspection_id, _ := this.GetInt64("template_inspection_id")
  1020. patient_id, _ := this.GetInt64("patient_id")
  1021. fmt.Println("patient_id", patient_id)
  1022. orgId := this.GetAdminUserInfo().CurrentOrgId
  1023. inspect_date := this.GetString("inspect_date")
  1024. project_id := this.GetString("project_id")
  1025. summary := models.XtTemplateSummary{
  1026. ID: id,
  1027. StartYear: 0,
  1028. StartMonth: 0,
  1029. Radio: 0,
  1030. Quarter: 0,
  1031. DryWeight: dry_weight,
  1032. DialysisCount: dialysis_count,
  1033. HdCount: hd_count,
  1034. HdfCount: hdf_count,
  1035. HpCount: hp_count,
  1036. OtherCount: other_count,
  1037. DialzerApparatus: dialzer_apparatus,
  1038. PerfusionApparatus: perfusion_apparatus,
  1039. Anticoagulant: anticoagulant,
  1040. Kalium: kalium,
  1041. Autunite: autunite,
  1042. Natrium: natrium,
  1043. Hour: hour,
  1044. Minute: minute,
  1045. BeforWeight: befor_weight,
  1046. AfterWeight: after_weight,
  1047. BeforPressure: befor_pressure,
  1048. AfterPressure: after_pressure,
  1049. TemplateSummaryId: template_summary_id,
  1050. TemplateSummaryContent: template_summary_content,
  1051. TemplatePlanId: template_plan_id,
  1052. TemplatePlanContent: template_plan_content,
  1053. TemplateInspectionId: template_inspection_id,
  1054. AdminUserId: admin_user_id,
  1055. RecordTime: recordTime.Unix(),
  1056. PatientId: patient_id,
  1057. UserOrgId: orgId,
  1058. Status: 1,
  1059. Ctime: time.Now().Unix(),
  1060. Mtime: 0,
  1061. Title: title,
  1062. ProjectId: project_id,
  1063. InspectDate: inspect_date,
  1064. }
  1065. err = service.UpdateTempalteSummary(&summary)
  1066. if err == nil {
  1067. this.ServeSuccessJSON(map[string]interface{}{
  1068. "list": summary,
  1069. })
  1070. return
  1071. }
  1072. }
  1073. func (this *DoctorsApiController) DeleteSummary() {
  1074. ids := this.GetString("ids")
  1075. idsplit := strings.Split(ids, ",")
  1076. err := service.DeleteSummary(idsplit)
  1077. fmt.Println(err)
  1078. returnData := make(map[string]interface{}, 0)
  1079. returnData["msg"] = "ok"
  1080. this.ServeSuccessJSON(returnData)
  1081. return
  1082. }
  1083. func (this *DoctorsApiController) HospitalSummary() {
  1084. timeLayout := "2006-01-02"
  1085. loc, _ := time.LoadLocation("Local")
  1086. dataBody := make(map[string]interface{}, 0)
  1087. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1088. fmt.Print("err", err)
  1089. admission_time := dataBody["admission_time"].(string)
  1090. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1091. admissiontime := admissionTimes.Unix()
  1092. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1093. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1094. connecticut := dataBody["connecticut"].(string)
  1095. dean := int64(dataBody["dean"].(float64))
  1096. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1097. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1098. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1099. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1100. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1101. discharge_advice := dataBody["discharge_advice"].(string)
  1102. discharge_time := dataBody["discharge_time"].(string)
  1103. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1104. dischargetime := dischargeTimes.Unix()
  1105. doctor := int64(dataBody["doctor"].(float64))
  1106. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1107. illness_discharge := dataBody["illness_discharge"].(string)
  1108. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1109. pathology := dataBody["pathology"].(string)
  1110. record_date := dataBody["record_date"].(string)
  1111. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1112. recordtime := recordDates.Unix()
  1113. sick_personnel := dataBody["sick_personnel"].(string)
  1114. title := dataBody["title"].(string)
  1115. treatment_id := dataBody["treatment_id"].(string)
  1116. treatment := dataBody["treatment"].(string)
  1117. ultrasound := dataBody["ultrasound"].(string)
  1118. xray := dataBody["xray"].(string)
  1119. patient_id := int64(dataBody["patient_id"].(float64))
  1120. orgId := this.GetAdminUserInfo().CurrentOrgId
  1121. summary := models.XtHospitalSummary{
  1122. PatientId: patient_id,
  1123. AdmissionTime: admissiontime,
  1124. DischargeTime: dischargetime,
  1125. SickPersonnel: sick_personnel,
  1126. Xray: xray,
  1127. Connecticut: connecticut,
  1128. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1129. Ultrasound: ultrasound,
  1130. Pathology: pathology,
  1131. AdmittingDiagnosisId: admitting_diagnosis_id,
  1132. AdmittingDiagnosis: admitting_diagnosis,
  1133. DischargeDiagnosis: discharge_diagnosis,
  1134. DiagnosisAdmissionId: diagnosis_admission_id,
  1135. DiagnosisAdmission: diagnosis_admission,
  1136. TreatmentId: treatment_id,
  1137. Treatment: treatment,
  1138. IllnessDischargeId: illness_discharge_id,
  1139. IllnessDischarge: illness_discharge,
  1140. DischargeAdviceId: discharge_advice_id,
  1141. DischargeAdvice: discharge_advice,
  1142. UserOrgId: orgId,
  1143. Status: 1,
  1144. Ctime: time.Now().Unix(),
  1145. Mtime: 0,
  1146. RecordTime: recordtime,
  1147. Title: title,
  1148. Doctor: doctor,
  1149. RecordDate: recordtime,
  1150. DeanId: dean,
  1151. DischargeDiagnosisId: discharge_diagnosis_id,
  1152. }
  1153. service.CreateHisSummary(&summary)
  1154. this.ServeSuccessJSON(map[string]interface{}{
  1155. "list": summary,
  1156. })
  1157. return
  1158. }
  1159. func (this *DoctorsApiController) GetHospitalSummaryList() {
  1160. timeLayout := "2006-01-02"
  1161. loc, _ := time.LoadLocation("Local")
  1162. orgId := this.GetAdminUserInfo().CurrentOrgId
  1163. patient_id, _ := this.GetInt64("patient_id")
  1164. start_time := this.GetString("start_time")
  1165. fmt.Println("start_tim232232323232323232323232332", start_time)
  1166. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1167. startime := dischargeTimes.Unix()
  1168. fmt.Println("startime1111111111111111111111", startime)
  1169. end_time := this.GetString("end_time")
  1170. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1171. endtime := endTimes.Unix()
  1172. list, err := service.GetHospitalSummaryList(orgId, patient_id, startime, endtime)
  1173. if err == nil {
  1174. this.ServeSuccessJSON(map[string]interface{}{
  1175. "list": list,
  1176. })
  1177. return
  1178. }
  1179. }
  1180. func (this *DoctorsApiController) GetHospitalSummaryDetail() {
  1181. id, _ := this.GetInt64("id")
  1182. detail, err := service.GetHospitalSummaryDetail(id)
  1183. if err == nil {
  1184. this.ServeSuccessJSON(map[string]interface{}{
  1185. "detail": detail,
  1186. })
  1187. return
  1188. }
  1189. }
  1190. func (this *DoctorsApiController) UpdateHospitalSummary() {
  1191. timeLayout := "2006-01-02"
  1192. loc, _ := time.LoadLocation("Local")
  1193. dataBody := make(map[string]interface{}, 0)
  1194. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1195. fmt.Print("err", err)
  1196. admission_time := dataBody["admission_time"].(string)
  1197. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1198. admissiontime := admissionTimes.Unix()
  1199. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1200. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1201. connecticut := dataBody["connecticut"].(string)
  1202. dean := int64(dataBody["dean"].(float64))
  1203. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1204. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1205. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1206. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1207. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1208. discharge_advice := dataBody["discharge_advice"].(string)
  1209. discharge_time := dataBody["discharge_time"].(string)
  1210. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1211. dischargetime := dischargeTimes.Unix()
  1212. doctor := int64(dataBody["doctor"].(float64))
  1213. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1214. illness_discharge := dataBody["illness_discharge"].(string)
  1215. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1216. pathology := dataBody["pathology"].(string)
  1217. record_date := dataBody["record_date"].(string)
  1218. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1219. recordtime := recordDates.Unix()
  1220. sick_personnel := dataBody["sick_personnel"].(string)
  1221. title := dataBody["title"].(string)
  1222. treatment_id := dataBody["treatment_id"].(string)
  1223. treatment := dataBody["treatment"].(string)
  1224. ultrasound := dataBody["ultrasound"].(string)
  1225. xray := dataBody["xray"].(string)
  1226. patient_id := int64(dataBody["patient_id"].(float64))
  1227. id := int64(dataBody["id"].(float64))
  1228. summary := models.XtHospitalSummary{
  1229. PatientId: patient_id,
  1230. AdmissionTime: admissiontime,
  1231. DischargeTime: dischargetime,
  1232. SickPersonnel: sick_personnel,
  1233. Xray: xray,
  1234. Connecticut: connecticut,
  1235. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1236. Ultrasound: ultrasound,
  1237. Pathology: pathology,
  1238. AdmittingDiagnosisId: admitting_diagnosis_id,
  1239. AdmittingDiagnosis: admitting_diagnosis,
  1240. DischargeDiagnosis: discharge_diagnosis,
  1241. DiagnosisAdmissionId: diagnosis_admission_id,
  1242. DiagnosisAdmission: diagnosis_admission,
  1243. TreatmentId: treatment_id,
  1244. Treatment: treatment,
  1245. IllnessDischargeId: illness_discharge_id,
  1246. IllnessDischarge: illness_discharge,
  1247. DischargeAdviceId: discharge_advice_id,
  1248. DischargeAdvice: discharge_advice,
  1249. Mtime: time.Now().Unix(),
  1250. RecordTime: recordtime,
  1251. Title: title,
  1252. Doctor: doctor,
  1253. RecordDate: recordtime,
  1254. DeanId: dean,
  1255. DischargeDiagnosisId: discharge_diagnosis_id,
  1256. }
  1257. err = service.UpdateHospital(id, summary)
  1258. if err == nil {
  1259. this.ServeSuccessJSON(map[string]interface{}{
  1260. "detail": summary,
  1261. })
  1262. return
  1263. }
  1264. }
  1265. func (this *DoctorsApiController) DeleteHospitalSummary() {
  1266. schIDStr := this.GetString("ids")
  1267. idStrs := strings.Split(schIDStr, ",")
  1268. err := service.DeleteHospitalSummary(idStrs)
  1269. fmt.Println(err)
  1270. returnData := make(map[string]interface{}, 0)
  1271. returnData["msg"] = "ok"
  1272. this.ServeSuccessJSON(returnData)
  1273. return
  1274. }
  1275. func (this *DoctorsApiController) GetPatientInfo() {
  1276. patient_id, _ := this.GetInt64("patient_id")
  1277. orgId := this.GetAdminUserInfo().CurrentOrgId
  1278. detail, err := service.GetPatientDetail(patient_id, orgId)
  1279. if err == nil {
  1280. this.ServeSuccessJSON(map[string]interface{}{
  1281. "patient": detail,
  1282. })
  1283. return
  1284. }
  1285. }