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 {
  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. fmt.Println("是错2323223322323232323", dayTime.Unix())
  319. redis := service.RedisClient()
  320. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  321. redis.Set(keyTwo, "", time.Second)
  322. prescription := models.PredialysisEvaluation{
  323. DryWeight: dry_weight,
  324. AssessmentDate: dayTime.Unix(),
  325. }
  326. if orgid != 10016 || orgid != 9882 {
  327. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  328. fmt.Println(errors)
  329. }
  330. key := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  331. redis.Set(key, "", time.Second)
  332. keySix := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  333. redis.Set(keySix, "", time.Second)
  334. fmt.Println("err", err)
  335. redis.Close()
  336. c.ServeSuccessJSON(map[string]interface{}{
  337. "patientDryweight": patientDryweight,
  338. })
  339. }
  340. func (c *DoctorsApiController) GetAllData() {
  341. id, _ := c.GetInt64("id")
  342. page, _ := c.GetInt64("page")
  343. fmt.Println("page", page)
  344. limit, _ := c.GetInt64("limit")
  345. fmt.Println("limit", limit)
  346. fmt.Println("id", id)
  347. adminUserInfo := c.GetAdminUserInfo()
  348. orgid := adminUserInfo.CurrentOrgId
  349. dry, total, _ := service.GetAllData(orgid, id, page, limit)
  350. c.ServeSuccessJSON(map[string]interface{}{
  351. "dry": dry,
  352. "total": total,
  353. })
  354. }
  355. func (c *DoctorsApiController) GetDryWeightDetail() {
  356. id, _ := c.GetInt64("id")
  357. dryweight, _ := service.GetDryWeightDetailById(id)
  358. c.ServeSuccessJSON(map[string]interface{}{
  359. "dryweight": dryweight,
  360. })
  361. }
  362. func (c *DoctorsApiController) ModifydryWeightData() {
  363. adjustvalue := c.GetString("adjustvalue")
  364. creator, _ := c.GetInt64("creator")
  365. dryweight, _ := c.GetInt64("dryweight")
  366. dry := strconv.FormatInt(dryweight, 10)
  367. dry_weight, _ := strconv.ParseFloat(dry, 64)
  368. id, _ := c.GetInt64("id")
  369. remark := c.GetString("remark")
  370. patientDryweight := models.SgjPatientDryweight{
  371. AdjustedValue: adjustvalue,
  372. Creator: creator,
  373. DryWeight: dry_weight,
  374. Remakes: remark,
  375. }
  376. service.ModifyDryWeightData(&patientDryweight, id)
  377. c.ServeSuccessJSON(map[string]interface{}{
  378. "patientDryweight": patientDryweight,
  379. })
  380. }
  381. func (c *DoctorsApiController) DeleteDryWeight() {
  382. id, _ := c.GetInt64("id")
  383. service.DeleteDryWeight(id)
  384. returnData := make(map[string]interface{}, 0)
  385. returnData["msg"] = "ok"
  386. c.ServeSuccessJSON(returnData)
  387. return
  388. }
  389. func (c *DoctorsApiController) GetDoctorAdviceCount() {
  390. timeLayout := "2006-01-02"
  391. loc, _ := time.LoadLocation("Local")
  392. start_time := c.GetString("start_time")
  393. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  394. end_time := c.GetString("end_time")
  395. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  396. delive_way := c.GetString("delive_way")
  397. adminUserInfo := c.GetAdminUserInfo()
  398. orgId := adminUserInfo.CurrentOrgId
  399. list, _ := service.GetDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  400. if len(list) == 0 {
  401. list, _ := service.GetHisDoctorAdviceCount(startTime.Unix(), endTime.Unix(), delive_way, orgId)
  402. c.ServeSuccessJSON(map[string]interface{}{
  403. "list": list,
  404. })
  405. } else {
  406. c.ServeSuccessJSON(map[string]interface{}{
  407. "list": list,
  408. })
  409. }
  410. }
  411. func (this *DoctorsApiController) SaveVasularAccess() {
  412. access_project, _ := this.GetInt64("access_project")
  413. blood_access_part_id := this.GetString("blood_access_part_id")
  414. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  415. first_start_time := this.GetString("first_start_time")
  416. timeLayout := "2006-01-02"
  417. loc, _ := time.LoadLocation("Local")
  418. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  419. inflow_pass := this.GetString("inflow_pass")
  420. remark := this.GetString("remark")
  421. start_time := this.GetString("start_time")
  422. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  423. stop_reason := this.GetString("stop_reason")
  424. user_status, _ := this.GetInt64("user_status")
  425. stop_time := this.GetString("stop_time")
  426. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  427. patient_id, _ := this.GetInt64("patient_id")
  428. other_vascular := this.GetString("other_vascular")
  429. ci_type, _ := this.GetInt64("ci_type")
  430. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  431. sequelae_type, _ := this.GetInt64("sequelae_type")
  432. adminUserInfo := this.GetAdminUserInfo()
  433. orgId := adminUserInfo.CurrentOrgId
  434. creator := adminUserInfo.AdminUser.Id
  435. //查询改日期是否存在
  436. access := models.XtPatientVascularAccess{
  437. AccessProject: access_project,
  438. BloodAccessPartId: blood_access_part_id,
  439. BloodAccessPartOperaId: blood_access_part_opera_id,
  440. FirstStartTime: firstStartTime.Unix(),
  441. InflowPass: inflow_pass,
  442. Remark: remark,
  443. StartTime: startTime.Unix(),
  444. StopReason: stop_reason,
  445. UserStatus: user_status,
  446. Creator: creator,
  447. UserOrgId: orgId,
  448. Status: 1,
  449. Ctime: time.Now().Unix(),
  450. StopTime: stopTime.Unix(),
  451. PatientId: patient_id,
  452. OtherVascular: other_vascular,
  453. CiType: ci_type,
  454. BloodCultupe: blood_cultupe,
  455. SequelaeType: sequelae_type,
  456. }
  457. err := service.SaveVascularAccess(&access)
  458. if err == nil {
  459. this.ServeSuccessJSON(map[string]interface{}{
  460. "access": access,
  461. })
  462. return
  463. //_, errcode := service.GetDialysisDateByDate(startTime.Unix(), patient_id, orgId)
  464. //if errcode == gorm.ErrRecordNotFound {
  465. // access := models.XtPatientVascularAccess{
  466. // AccessProject: access_project,
  467. // BloodAccessPartId: blood_access_part_id,
  468. // BloodAccessPartOperaId: blood_access_part_opera_id,
  469. // FirstStartTime: firstStartTime.Unix(),
  470. // InflowPass: inflow_pass,
  471. // Remark: remark,
  472. // StartTime: startTime.Unix(),
  473. // StopReason: stop_reason,
  474. // UserStatus: user_status,
  475. // Creator: creator,
  476. // UserOrgId: orgId,
  477. // Status: 1,
  478. // Ctime: time.Now().Unix(),
  479. // StopTime: stopTime.Unix(),
  480. // PatientId: patient_id,
  481. // OtherVascular: other_vascular,
  482. // CiType: ci_type,
  483. // BloodCultupe: blood_cultupe,
  484. // SequelaeType: sequelae_type,
  485. // }
  486. // err := service.SaveVascularAccess(&access)
  487. // if err == nil {
  488. // this.ServeSuccessJSON(map[string]interface{}{
  489. // "access": access,
  490. // })
  491. // return
  492. // }
  493. //} else if errcode == nil {
  494. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  495. // return
  496. }
  497. }
  498. func (this *DoctorsApiController) GetAllVacualAccessList() {
  499. limit, _ := this.GetInt64("limit")
  500. page, _ := this.GetInt64("page")
  501. patient_id, _ := this.GetInt64("patient_id")
  502. orgId := this.GetAdminUserInfo().CurrentOrgId
  503. appId := this.GetAdminUserInfo().CurrentAppId
  504. list, total, err := service.GetAllVacualAccessList(orgId, limit, page, patient_id)
  505. doctor, err := service.GetAllDoctor(orgId, appId)
  506. if err == nil {
  507. this.ServeSuccessJSON(map[string]interface{}{
  508. "list": list,
  509. "total": total,
  510. "doctor": doctor,
  511. })
  512. return
  513. }
  514. }
  515. func (this *DoctorsApiController) GetVascularAccessByDetail() {
  516. id, _ := this.GetInt64("id")
  517. accessDetail, err := service.GetVasularAccessByDetail(id)
  518. orgId := this.GetAdminUserInfo().CurrentOrgId
  519. appId := this.GetAdminUserInfo().CurrentAppId
  520. doctor, err := service.GetAllDoctor(orgId, appId)
  521. if err == nil {
  522. this.ServeSuccessJSON(map[string]interface{}{
  523. "accessDetail": accessDetail,
  524. "doctor": doctor,
  525. })
  526. return
  527. }
  528. }
  529. func (this *DoctorsApiController) UpdateVasularAccess() {
  530. id, _ := this.GetInt64("id")
  531. access_project, _ := this.GetInt64("access_project")
  532. blood_access_part_id := this.GetString("blood_access_part_id")
  533. blood_access_part_opera_id := this.GetString("blood_access_part_opera_id")
  534. first_start_time := this.GetString("first_start_time")
  535. timeLayout := "2006-01-02"
  536. loc, _ := time.LoadLocation("Local")
  537. firstStartTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", first_start_time+" 00:00:00", loc)
  538. inflow_pass := this.GetString("inflow_pass")
  539. remark := this.GetString("remark")
  540. start_time := this.GetString("start_time")
  541. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  542. stop_reason := this.GetString("stop_reason")
  543. user_status, _ := this.GetInt64("user_status")
  544. stop_time := this.GetString("stop_time")
  545. stopTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", stop_time+" 00:00:00", loc)
  546. adminUserInfo := this.GetAdminUserInfo()
  547. orgId := adminUserInfo.CurrentOrgId
  548. creator := adminUserInfo.AdminUser.Id
  549. patientId, _ := this.GetInt64("patient_id")
  550. other_vascular := this.GetString("other_vascular")
  551. ci_type, _ := this.GetInt64("ci_type")
  552. blood_cultupe, _ := this.GetInt64("blood_cultupe")
  553. sequelae_type, _ := this.GetInt64("sequelae_type")
  554. access := models.XtPatientVascularAccess{
  555. AccessProject: access_project,
  556. BloodAccessPartId: blood_access_part_id,
  557. BloodAccessPartOperaId: blood_access_part_opera_id,
  558. FirstStartTime: firstStartTime.Unix(),
  559. InflowPass: inflow_pass,
  560. Remark: remark,
  561. StartTime: startTime.Unix(),
  562. StopReason: stop_reason,
  563. UserStatus: user_status,
  564. Modify: creator,
  565. UserOrgId: orgId,
  566. Status: 1,
  567. StopTime: stopTime.Unix(),
  568. OtherVascular: other_vascular,
  569. CiType: ci_type,
  570. BloodCultupe: blood_cultupe,
  571. SequelaeType: sequelae_type,
  572. PatientId: patientId,
  573. }
  574. err := service.UpdateVascularAccess(&access, id)
  575. if err == nil {
  576. this.ServeSuccessJSON(map[string]interface{}{
  577. "access": access,
  578. })
  579. return
  580. }
  581. //_, errcode := service.GetDialysisDateByDateOne(startTime.Unix(), patientId, orgId, id)
  582. //if errcode == gorm.ErrRecordNotFound {
  583. // err := service.UpdateVascularAccess(&access, id)
  584. // if err == nil {
  585. // this.ServeSuccessJSON(map[string]interface{}{
  586. // "access": access,
  587. // })
  588. // return
  589. // }
  590. //} else if errcode == nil {
  591. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorDialysisOrderRepeatBed)
  592. // return
  593. //}
  594. }
  595. func (this *DoctorsApiController) DeleteVasularAccess() {
  596. id, _ := this.GetInt64("id")
  597. err := service.DeleteVasularAccess(id)
  598. fmt.Println(err)
  599. returnData := make(map[string]interface{}, 0)
  600. returnData["msg"] = "ok"
  601. this.ServeSuccessJSON(returnData)
  602. return
  603. }
  604. func (this *DoctorsApiController) SavePassWayAssessment() {
  605. blood_dealwidth := this.GetString("blood_dealwith")
  606. blood_project := this.GetString("blood_project")
  607. blood_result := this.GetString("blood_result")
  608. creator, _ := this.GetInt64("creator")
  609. parent_id, _ := this.GetInt64("parent_id")
  610. patient_id, _ := this.GetInt64("patient_id")
  611. start_time := this.GetString("start_time")
  612. timeLayout := "2006-01-02"
  613. loc, _ := time.LoadLocation("Local")
  614. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  615. modify := this.GetAdminUserInfo().AdminUser.Id
  616. orgId := this.GetAdminUserInfo().CurrentOrgId
  617. assessment := models.XtPatientPasswayAssessment{
  618. StartTime: startTime.Unix(),
  619. BloodDealwith: blood_dealwidth,
  620. BloodProject: blood_project,
  621. BloodResult: blood_result,
  622. Creator: creator,
  623. PatientId: patient_id,
  624. ParentId: parent_id,
  625. Modify: modify,
  626. UserOrgId: orgId,
  627. Status: 1,
  628. Ctime: time.Now().Unix(),
  629. }
  630. err := service.CreatePatientWayAssessment(&assessment)
  631. if err == nil {
  632. this.ServeSuccessJSON(map[string]interface{}{
  633. "assessment": assessment,
  634. })
  635. return
  636. }
  637. }
  638. func (this *DoctorsApiController) GetAllPassWayAssessment() {
  639. patient_id, _ := this.GetInt64("patient_id")
  640. parent_id, _ := this.GetInt64("parent_id")
  641. page, _ := this.GetInt64("page")
  642. limit, _ := this.GetInt64("limit")
  643. adminUserInfo := this.GetAdminUserInfo()
  644. list, total, err := service.GetAllPassWayAssessment(parent_id, patient_id, page, limit, adminUserInfo.CurrentOrgId)
  645. if err == nil {
  646. this.ServeSuccessJSON(map[string]interface{}{
  647. "list": list,
  648. "total": total,
  649. })
  650. return
  651. }
  652. }
  653. func (this *DoctorsApiController) GetPasswayAssesmentById() {
  654. id, _ := this.GetInt64("id")
  655. assessment, err := service.GetPasswayAssesmentById(id)
  656. if err == nil {
  657. this.ServeSuccessJSON(map[string]interface{}{
  658. "assessment": assessment,
  659. })
  660. return
  661. }
  662. }
  663. func (this *DoctorsApiController) UpdatePassWayAssesment() {
  664. id, _ := this.GetInt64("id")
  665. blood_dealwidth := this.GetString("blood_dealwith")
  666. blood_project := this.GetString("blood_project")
  667. blood_result := this.GetString("blood_result")
  668. creator, _ := this.GetInt64("creator")
  669. start_time := this.GetString("start_time")
  670. timeLayout := "2006-01-02"
  671. loc, _ := time.LoadLocation("Local")
  672. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  673. modify := this.GetAdminUserInfo().AdminUser.Id
  674. assessment := models.XtPatientPasswayAssessment{
  675. BloodResult: blood_result,
  676. BloodDealwith: blood_dealwidth,
  677. BloodProject: blood_project,
  678. Creator: creator,
  679. StartTime: startTime.Unix(),
  680. Modify: modify,
  681. }
  682. err := service.UpdatePassWayAssesment(&assessment, id)
  683. if err == nil {
  684. this.ServeSuccessJSON(map[string]interface{}{
  685. "assessment": assessment,
  686. })
  687. return
  688. }
  689. }
  690. func (this *DoctorsApiController) DeleteWayAssessment() {
  691. id, _ := this.GetInt64("id")
  692. err := service.DeleteWayAssessment(id)
  693. fmt.Println(err)
  694. returnData := make(map[string]interface{}, 0)
  695. returnData["msg"] = "ok"
  696. this.ServeSuccessJSON(returnData)
  697. return
  698. }
  699. func (this *DoctorsApiController) GetAccessList() {
  700. adminUserInfo := this.GetAdminUserInfo()
  701. orgId := adminUserInfo.CurrentOrgId
  702. //血管通路
  703. list, err := service.GetAccessList(orgId)
  704. blood_access_part_opera, err := service.GetParentAccessList(orgId, list.ID)
  705. //血管通路部位
  706. access, err := service.GetBloodAccess(orgId)
  707. blood_access_part, err := service.GetParentAccessList(orgId, access.ID)
  708. if err == nil {
  709. this.ServeSuccessJSON(map[string]interface{}{
  710. "blood_access_part_opera": blood_access_part_opera,
  711. "blood_access_part": blood_access_part,
  712. })
  713. return
  714. }
  715. }
  716. func (this *DoctorsApiController) GetInspectionMajorItem() {
  717. other_start_time := this.GetString("other_start_time")
  718. last_time := this.GetString("last_time")
  719. timeLayout := "2006-01-02"
  720. loc, _ := time.LoadLocation("Local")
  721. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", other_start_time+" 23:59:59", loc)
  722. lastTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", last_time+" 00:00:00", loc)
  723. patient_id, _ := this.GetInt64("patient_id")
  724. adminUserInfo := this.GetAdminUserInfo()
  725. orgId := adminUserInfo.CurrentOrgId
  726. list, err := service.GetInspectionMajorItem(startTime.Unix(), lastTime.Unix(), orgId, patient_id)
  727. if err == nil {
  728. this.ServeSuccessJSON(map[string]interface{}{
  729. "list": list,
  730. })
  731. return
  732. }
  733. }
  734. func (this *DoctorsApiController) GetInspectionDetailByProject() {
  735. project_id, _ := this.GetInt64("project_id")
  736. patient_id, _ := this.GetInt64("patient_id")
  737. inspect_date, _ := this.GetInt64("inspect_date")
  738. orgId := this.GetAdminUserInfo().CurrentOrgId
  739. list, err := service.GetInspectionDetailByProject(project_id, patient_id, inspect_date, orgId)
  740. if err == nil {
  741. this.ServeSuccessJSON(map[string]interface{}{
  742. "list": list,
  743. })
  744. return
  745. }
  746. }
  747. func (this *DoctorsApiController) GetInspectionItemlist() {
  748. patient_id, _ := this.GetInt64("patient_id")
  749. ids := this.GetString("ids")
  750. inspect_date := this.GetString("inspect_date")
  751. idSplit := strings.Split(ids, ",")
  752. indateSplit := strings.Split(inspect_date, ",")
  753. list, err := service.GetInspectionItemlist(patient_id, indateSplit, idSplit)
  754. if err == nil {
  755. this.ServeSuccessJSON(map[string]interface{}{
  756. "list": list,
  757. })
  758. return
  759. }
  760. }
  761. func (this *DoctorsApiController) GetInitDateList() {
  762. patient_id, _ := this.GetInt64("patient_id")
  763. start_time := this.GetString("start_time")
  764. timeLayout := "2006-01-02"
  765. loc, _ := time.LoadLocation("Local")
  766. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  767. end_time := this.GetString("end_time")
  768. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  769. fmt.Println("endtime2323232233223232332", endTime)
  770. prescription_list, _ := service.GetDialysisPrescriptionDataList(patient_id, startTime.Unix(), endTime.Unix())
  771. befor_list, err := service.GetDialysisBeforInitDateList(patient_id, startTime.Unix(), endTime.Unix())
  772. after_list, err := service.GetDialysisAssementAfter(patient_id, startTime.Unix(), endTime.Unix())
  773. orgId := this.GetAdminUserInfo().CurrentOrgId
  774. //统计透析次数
  775. modelist, err := service.GetDialysisDialysisMode(patient_id, startTime.Unix(), endTime.Unix(), orgId)
  776. docList, _ := service.GetAllDoctorThree(orgId)
  777. stockType, err := service.GetStockType(orgId)
  778. summaryList, err := service.GetTemplateSummary(orgId)
  779. planList, err := service.GetTemplatePlan(orgId)
  780. if err == nil {
  781. this.ServeSuccessJSON(map[string]interface{}{
  782. "beforlist": befor_list,
  783. "prescription_list": prescription_list,
  784. "after_list": after_list,
  785. "modelist": modelist,
  786. "docList": docList,
  787. "stockType": stockType,
  788. "summaryList": summaryList,
  789. "planList": planList,
  790. })
  791. return
  792. }
  793. }
  794. func (this *DoctorsApiController) SaveCreationInspection() {
  795. dataBody := make(map[string]interface{}, 0)
  796. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  797. if err != nil {
  798. utils.ErrorLog(err.Error())
  799. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  800. return
  801. }
  802. title := dataBody["title"].(string)
  803. dryWeight := dataBody["dry_weight"].(string)
  804. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  805. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  806. hd_count := int64(dataBody["hd_count"].(float64))
  807. hdf_count := int64(dataBody["hdf_count"].(float64))
  808. hp_count := int64(dataBody["hp_count"].(float64))
  809. other_count := int64(dataBody["other_count"].(float64))
  810. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  811. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  812. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  813. kaliumstr := dataBody["kalium"].(string)
  814. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  815. autunitestr := dataBody["autunite"].(string)
  816. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  817. natriumstr := dataBody["natrium"].(string)
  818. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  819. hour := int64(dataBody["hour"].(float64))
  820. minute := int64(dataBody["minute"].(float64))
  821. beforWeight := dataBody["befor_weight"].(string)
  822. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  823. afterWeight := dataBody["after_weight"].(string)
  824. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  825. befor_pressure := dataBody["befor_pressure"].(string)
  826. template_summary_content := dataBody["template_summary_content"].(string)
  827. template_plan_content := dataBody["template_plan_content"].(string)
  828. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  829. record_time := dataBody["record_time"].(string)
  830. timeLayout := "2006-01-02"
  831. loc, _ := time.LoadLocation("Local")
  832. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  833. after_pressure := dataBody["after_pressure"].(string)
  834. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  835. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  836. patient_id := int64(dataBody["patient_id"].(float64))
  837. orgId := this.GetAdminUserInfo().CurrentOrgId
  838. inspect_date := dataBody["inspect_date"].(string)
  839. project_id := dataBody["project_id"].(string)
  840. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  841. //title := this.GetString("title")
  842. //dryWeight := this.GetString("dry_weight")
  843. //dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  844. //dialysis_count, _ := this.GetInt64("dialysis_count")
  845. //hd_count, _ := this.GetInt64("hd_count")
  846. //hdf_count, _ := this.GetInt64("hdf_count")
  847. //hp_count, _ := this.GetInt64("hp_count")
  848. //other_count, _ := this.GetInt64("other_count")
  849. //dialzer_apparatus := this.GetString("dialzer_apparatus")
  850. //perfusion_apparatus := this.GetString("perfusion_apparatus")
  851. //anticoagulant, _ := this.GetInt64("anticoagulant")
  852. //kaliumstr := this.GetString("kalium")
  853. //kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  854. //
  855. //autunitestr := this.GetString("autunite")
  856. //autunite, _ := strconv.ParseFloat(autunitestr, 64)
  857. //natriumstr := this.GetString("natrium")
  858. //natrium, _ := strconv.ParseFloat(natriumstr, 64)
  859. //hour, _ := this.GetInt64("hour")
  860. //minute, _ := this.GetInt64("minute")
  861. //beforWeight := this.GetString("befor_weight")
  862. //befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  863. //afterWeight := this.GetString("after_weight")
  864. //after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  865. //befor_pressure := this.GetString("befor_pressure")
  866. //template_summary_content := this.GetString("template_summary_content")
  867. //template_plan_content := this.GetString("template_plan_content")
  868. //admin_user_id, _ := this.GetInt64("admin_user_id")
  869. //record_time := this.GetString("record_time")
  870. //timeLayout := "2006-01-02"
  871. //loc, _ := time.LoadLocation("Local")
  872. //recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  873. //after_pressure := this.GetString("after_pressure")
  874. //template_summary_id, _ := this.GetInt64("template_summary_id")
  875. //template_plan_id, _ := this.GetInt64("template_plan_id")
  876. //template_inspection_id, _ := this.GetInt64("template_inspection_id")
  877. //patient_id, _ := this.GetInt64("patient_id")
  878. //fmt.Println("patient_id", patient_id)
  879. //orgId := this.GetAdminUserInfo().CurrentOrgId
  880. //inspect_date := this.GetString("inspect_date")
  881. //project_id := this.GetString("project_id")
  882. summary := models.XtTemplateSummary{
  883. StartYear: 0,
  884. StartMonth: 0,
  885. Radio: 0,
  886. Quarter: 0,
  887. DryWeight: dry_weight,
  888. DialysisCount: dialysis_count,
  889. HdCount: hd_count,
  890. HdfCount: hdf_count,
  891. HpCount: hp_count,
  892. OtherCount: other_count,
  893. DialzerApparatus: dialzer_apparatus,
  894. PerfusionApparatus: perfusion_apparatus,
  895. Anticoagulant: anticoagulant,
  896. Kalium: kalium,
  897. Autunite: autunite,
  898. Natrium: natrium,
  899. Hour: hour,
  900. Minute: minute,
  901. BeforWeight: befor_weight,
  902. AfterWeight: after_weight,
  903. BeforPressure: befor_pressure,
  904. AfterPressure: after_pressure,
  905. TemplateSummaryId: template_summary_id,
  906. TemplateSummaryContent: template_summary_content,
  907. TemplatePlanId: template_plan_id,
  908. TemplatePlanContent: template_plan_content,
  909. TemplateInspectionId: template_inspection_id,
  910. AdminUserId: admin_user_id,
  911. RecordTime: recordTime.Unix(),
  912. PatientId: patient_id,
  913. UserOrgId: orgId,
  914. Status: 1,
  915. Ctime: time.Now().Unix(),
  916. Mtime: 0,
  917. Title: title,
  918. InspectDate: inspect_date,
  919. ProjectId: project_id,
  920. }
  921. err = service.CreateSummary(&summary)
  922. if err == nil {
  923. this.ServeSuccessJSON(map[string]interface{}{
  924. "summary": summary,
  925. })
  926. return
  927. }
  928. }
  929. func (this *DoctorsApiController) GetTemplateSummaryList() {
  930. patient_id, _ := this.GetInt64("patient_id")
  931. start_time := this.GetString("start_time")
  932. timeLayout := "2006-01-02"
  933. loc, _ := time.LoadLocation("Local")
  934. end_time := this.GetString("end_time")
  935. orgId := this.GetAdminUserInfo().CurrentOrgId
  936. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  937. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  938. list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
  939. if err == nil {
  940. this.ServeSuccessJSON(map[string]interface{}{
  941. "list": list,
  942. })
  943. return
  944. }
  945. }
  946. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  947. id, _ := this.GetInt64("id")
  948. list, err := service.GetTemplateSummaryDetail(id)
  949. ids := strings.Split(list.ProjectId, ",")
  950. datelist := strings.Split(list.InspectDate, ",")
  951. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  952. if err == nil {
  953. this.ServeSuccessJSON(map[string]interface{}{
  954. "list": list,
  955. "inspectlist": inspectlist,
  956. })
  957. return
  958. }
  959. }
  960. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  961. id, _ := this.GetInt64("id")
  962. list, err := service.GetTemplateSummaryPrintDetail(id)
  963. ids := strings.Split(list.ProjectId, ",")
  964. datelist := strings.Split(list.InspectDate, ",")
  965. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  966. orgId := this.GetAdminUserInfo().CurrentOrgId
  967. doctorList, _ := service.GetAllDoctorThree(orgId)
  968. if err == nil {
  969. this.ServeSuccessJSON(map[string]interface{}{
  970. "list": list,
  971. "doctorList": doctorList,
  972. "inspectlist": inspectlist,
  973. })
  974. return
  975. }
  976. }
  977. func (this *DoctorsApiController) UpdateTempalteSummary() {
  978. dataBody := make(map[string]interface{}, 0)
  979. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  980. if err != nil {
  981. utils.ErrorLog(err.Error())
  982. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  983. return
  984. }
  985. id, _ := this.GetInt64("id")
  986. title := this.GetString("title")
  987. dryWeight := this.GetString("dry_weight")
  988. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  989. dialysis_count, _ := this.GetInt64("dialysis_count")
  990. hd_count, _ := this.GetInt64("hd_count")
  991. hdf_count, _ := this.GetInt64("hdf_count")
  992. hp_count, _ := this.GetInt64("hp_count")
  993. other_count, _ := this.GetInt64("other_count")
  994. dialzer_apparatus := this.GetString("dialzer_apparatus")
  995. perfusion_apparatus := this.GetString("perfusion_apparatus")
  996. anticoagulant, _ := this.GetInt64("anticoagulant")
  997. kaliumstr := this.GetString("kalium")
  998. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  999. autunitestr := this.GetString("autunite")
  1000. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  1001. natriumstr := this.GetString("natrium")
  1002. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  1003. hour, _ := this.GetInt64("hour")
  1004. minute, _ := this.GetInt64("minute")
  1005. beforWeight := this.GetString("befor_weight")
  1006. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  1007. afterWeight := this.GetString("after_weight")
  1008. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  1009. befor_pressure := this.GetString("befor_pressure")
  1010. template_summary_content := this.GetString("template_summary_content")
  1011. template_plan_content := this.GetString("template_plan_content")
  1012. admin_user_id, _ := this.GetInt64("admin_user_id")
  1013. record_time := this.GetString("record_time")
  1014. timeLayout := "2006-01-02"
  1015. loc, _ := time.LoadLocation("Local")
  1016. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  1017. after_pressure := this.GetString("after_pressure")
  1018. template_summary_id, _ := this.GetInt64("template_summary_id")
  1019. template_plan_id, _ := this.GetInt64("template_plan_id")
  1020. template_inspection_id, _ := this.GetInt64("template_inspection_id")
  1021. patient_id, _ := this.GetInt64("patient_id")
  1022. fmt.Println("patient_id", patient_id)
  1023. orgId := this.GetAdminUserInfo().CurrentOrgId
  1024. inspect_date := this.GetString("inspect_date")
  1025. project_id := this.GetString("project_id")
  1026. summary := models.XtTemplateSummary{
  1027. ID: id,
  1028. StartYear: 0,
  1029. StartMonth: 0,
  1030. Radio: 0,
  1031. Quarter: 0,
  1032. DryWeight: dry_weight,
  1033. DialysisCount: dialysis_count,
  1034. HdCount: hd_count,
  1035. HdfCount: hdf_count,
  1036. HpCount: hp_count,
  1037. OtherCount: other_count,
  1038. DialzerApparatus: dialzer_apparatus,
  1039. PerfusionApparatus: perfusion_apparatus,
  1040. Anticoagulant: anticoagulant,
  1041. Kalium: kalium,
  1042. Autunite: autunite,
  1043. Natrium: natrium,
  1044. Hour: hour,
  1045. Minute: minute,
  1046. BeforWeight: befor_weight,
  1047. AfterWeight: after_weight,
  1048. BeforPressure: befor_pressure,
  1049. AfterPressure: after_pressure,
  1050. TemplateSummaryId: template_summary_id,
  1051. TemplateSummaryContent: template_summary_content,
  1052. TemplatePlanId: template_plan_id,
  1053. TemplatePlanContent: template_plan_content,
  1054. TemplateInspectionId: template_inspection_id,
  1055. AdminUserId: admin_user_id,
  1056. RecordTime: recordTime.Unix(),
  1057. PatientId: patient_id,
  1058. UserOrgId: orgId,
  1059. Status: 1,
  1060. Ctime: time.Now().Unix(),
  1061. Mtime: 0,
  1062. Title: title,
  1063. ProjectId: project_id,
  1064. InspectDate: inspect_date,
  1065. }
  1066. err = service.UpdateTempalteSummary(&summary)
  1067. if err == nil {
  1068. this.ServeSuccessJSON(map[string]interface{}{
  1069. "list": summary,
  1070. })
  1071. return
  1072. }
  1073. }
  1074. func (this *DoctorsApiController) DeleteSummary() {
  1075. ids := this.GetString("ids")
  1076. idsplit := strings.Split(ids, ",")
  1077. err := service.DeleteSummary(idsplit)
  1078. fmt.Println(err)
  1079. returnData := make(map[string]interface{}, 0)
  1080. returnData["msg"] = "ok"
  1081. this.ServeSuccessJSON(returnData)
  1082. return
  1083. }
  1084. func (this *DoctorsApiController) HospitalSummary() {
  1085. timeLayout := "2006-01-02"
  1086. loc, _ := time.LoadLocation("Local")
  1087. dataBody := make(map[string]interface{}, 0)
  1088. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1089. fmt.Print("err", err)
  1090. admission_time := dataBody["admission_time"].(string)
  1091. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1092. admissiontime := admissionTimes.Unix()
  1093. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1094. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1095. connecticut := dataBody["connecticut"].(string)
  1096. dean := int64(dataBody["dean"].(float64))
  1097. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1098. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1099. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1100. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1101. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1102. discharge_advice := dataBody["discharge_advice"].(string)
  1103. discharge_time := dataBody["discharge_time"].(string)
  1104. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1105. dischargetime := dischargeTimes.Unix()
  1106. doctor := int64(dataBody["doctor"].(float64))
  1107. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1108. illness_discharge := dataBody["illness_discharge"].(string)
  1109. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1110. pathology := dataBody["pathology"].(string)
  1111. record_date := dataBody["record_date"].(string)
  1112. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1113. recordtime := recordDates.Unix()
  1114. sick_personnel := dataBody["sick_personnel"].(string)
  1115. title := dataBody["title"].(string)
  1116. treatment_id := dataBody["treatment_id"].(string)
  1117. treatment := dataBody["treatment"].(string)
  1118. ultrasound := dataBody["ultrasound"].(string)
  1119. xray := dataBody["xray"].(string)
  1120. patient_id := int64(dataBody["patient_id"].(float64))
  1121. orgId := this.GetAdminUserInfo().CurrentOrgId
  1122. summary := models.XtHospitalSummary{
  1123. PatientId: patient_id,
  1124. AdmissionTime: admissiontime,
  1125. DischargeTime: dischargetime,
  1126. SickPersonnel: sick_personnel,
  1127. Xray: xray,
  1128. Connecticut: connecticut,
  1129. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1130. Ultrasound: ultrasound,
  1131. Pathology: pathology,
  1132. AdmittingDiagnosisId: admitting_diagnosis_id,
  1133. AdmittingDiagnosis: admitting_diagnosis,
  1134. DischargeDiagnosis: discharge_diagnosis,
  1135. DiagnosisAdmissionId: diagnosis_admission_id,
  1136. DiagnosisAdmission: diagnosis_admission,
  1137. TreatmentId: treatment_id,
  1138. Treatment: treatment,
  1139. IllnessDischargeId: illness_discharge_id,
  1140. IllnessDischarge: illness_discharge,
  1141. DischargeAdviceId: discharge_advice_id,
  1142. DischargeAdvice: discharge_advice,
  1143. UserOrgId: orgId,
  1144. Status: 1,
  1145. Ctime: time.Now().Unix(),
  1146. Mtime: 0,
  1147. RecordTime: recordtime,
  1148. Title: title,
  1149. Doctor: doctor,
  1150. RecordDate: recordtime,
  1151. DeanId: dean,
  1152. DischargeDiagnosisId: discharge_diagnosis_id,
  1153. }
  1154. service.CreateHisSummary(&summary)
  1155. this.ServeSuccessJSON(map[string]interface{}{
  1156. "list": summary,
  1157. })
  1158. return
  1159. }
  1160. func (this *DoctorsApiController) GetHospitalSummaryList() {
  1161. timeLayout := "2006-01-02"
  1162. loc, _ := time.LoadLocation("Local")
  1163. orgId := this.GetAdminUserInfo().CurrentOrgId
  1164. patient_id, _ := this.GetInt64("patient_id")
  1165. start_time := this.GetString("start_time")
  1166. fmt.Println("start_tim232232323232323232323232332", start_time)
  1167. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1168. startime := dischargeTimes.Unix()
  1169. fmt.Println("startime1111111111111111111111", startime)
  1170. end_time := this.GetString("end_time")
  1171. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1172. endtime := endTimes.Unix()
  1173. list, err := service.GetHospitalSummaryList(orgId, patient_id, startime, endtime)
  1174. if err == nil {
  1175. this.ServeSuccessJSON(map[string]interface{}{
  1176. "list": list,
  1177. })
  1178. return
  1179. }
  1180. }
  1181. func (this *DoctorsApiController) GetHospitalSummaryDetail() {
  1182. id, _ := this.GetInt64("id")
  1183. detail, err := service.GetHospitalSummaryDetail(id)
  1184. if err == nil {
  1185. this.ServeSuccessJSON(map[string]interface{}{
  1186. "detail": detail,
  1187. })
  1188. return
  1189. }
  1190. }
  1191. func (this *DoctorsApiController) UpdateHospitalSummary() {
  1192. timeLayout := "2006-01-02"
  1193. loc, _ := time.LoadLocation("Local")
  1194. dataBody := make(map[string]interface{}, 0)
  1195. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1196. fmt.Print("err", err)
  1197. admission_time := dataBody["admission_time"].(string)
  1198. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1199. admissiontime := admissionTimes.Unix()
  1200. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1201. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1202. connecticut := dataBody["connecticut"].(string)
  1203. dean := int64(dataBody["dean"].(float64))
  1204. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1205. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1206. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1207. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1208. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1209. discharge_advice := dataBody["discharge_advice"].(string)
  1210. discharge_time := dataBody["discharge_time"].(string)
  1211. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1212. dischargetime := dischargeTimes.Unix()
  1213. doctor := int64(dataBody["doctor"].(float64))
  1214. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1215. illness_discharge := dataBody["illness_discharge"].(string)
  1216. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1217. pathology := dataBody["pathology"].(string)
  1218. record_date := dataBody["record_date"].(string)
  1219. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1220. recordtime := recordDates.Unix()
  1221. sick_personnel := dataBody["sick_personnel"].(string)
  1222. title := dataBody["title"].(string)
  1223. treatment_id := dataBody["treatment_id"].(string)
  1224. treatment := dataBody["treatment"].(string)
  1225. ultrasound := dataBody["ultrasound"].(string)
  1226. xray := dataBody["xray"].(string)
  1227. patient_id := int64(dataBody["patient_id"].(float64))
  1228. id := int64(dataBody["id"].(float64))
  1229. summary := models.XtHospitalSummary{
  1230. PatientId: patient_id,
  1231. AdmissionTime: admissiontime,
  1232. DischargeTime: dischargetime,
  1233. SickPersonnel: sick_personnel,
  1234. Xray: xray,
  1235. Connecticut: connecticut,
  1236. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1237. Ultrasound: ultrasound,
  1238. Pathology: pathology,
  1239. AdmittingDiagnosisId: admitting_diagnosis_id,
  1240. AdmittingDiagnosis: admitting_diagnosis,
  1241. DischargeDiagnosis: discharge_diagnosis,
  1242. DiagnosisAdmissionId: diagnosis_admission_id,
  1243. DiagnosisAdmission: diagnosis_admission,
  1244. TreatmentId: treatment_id,
  1245. Treatment: treatment,
  1246. IllnessDischargeId: illness_discharge_id,
  1247. IllnessDischarge: illness_discharge,
  1248. DischargeAdviceId: discharge_advice_id,
  1249. DischargeAdvice: discharge_advice,
  1250. Mtime: time.Now().Unix(),
  1251. RecordTime: recordtime,
  1252. Title: title,
  1253. Doctor: doctor,
  1254. RecordDate: recordtime,
  1255. DeanId: dean,
  1256. DischargeDiagnosisId: discharge_diagnosis_id,
  1257. }
  1258. err = service.UpdateHospital(id, summary)
  1259. if err == nil {
  1260. this.ServeSuccessJSON(map[string]interface{}{
  1261. "detail": summary,
  1262. })
  1263. return
  1264. }
  1265. }
  1266. func (this *DoctorsApiController) DeleteHospitalSummary() {
  1267. schIDStr := this.GetString("ids")
  1268. idStrs := strings.Split(schIDStr, ",")
  1269. err := service.DeleteHospitalSummary(idStrs)
  1270. fmt.Println(err)
  1271. returnData := make(map[string]interface{}, 0)
  1272. returnData["msg"] = "ok"
  1273. this.ServeSuccessJSON(returnData)
  1274. return
  1275. }
  1276. func (this *DoctorsApiController) GetPatientInfo() {
  1277. patient_id, _ := this.GetInt64("patient_id")
  1278. orgId := this.GetAdminUserInfo().CurrentOrgId
  1279. detail, err := service.GetPatientDetail(patient_id, orgId)
  1280. if err == nil {
  1281. this.ServeSuccessJSON(map[string]interface{}{
  1282. "patient": detail,
  1283. })
  1284. return
  1285. }
  1286. }