doctors_api_controller.go 51KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  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. excution_way, _ := c.GetInt64("excution_way")
  68. if adviceType != 1 && adviceType != 3 && adviceType != 2 {
  69. adviceType = 0
  70. }
  71. if patientType != 1 && patientType != 2 {
  72. patientType = 0
  73. }
  74. date, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", schedualDate)
  75. if parseDateErr != nil {
  76. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  77. return
  78. }
  79. adminUserInfo := c.GetAdminUserInfo()
  80. orgID := adminUserInfo.CurrentOrgId
  81. scheduals, err := service.MobileGetScheduleDoctorAdvicesOne(orgID, date.Unix(), adviceType, patientType, adminUserInfo.AdminUser.Id, delivery_way, schedule_type, partition_type, patient_id, excution_way)
  82. hisAdvices, _ := service.GetHisDoctorAdvicesOne(orgID, date.Unix(), delivery_way, schedule_type, partition_type, patient_id, excution_way)
  83. project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id, excution_way)
  84. //project, _ := service.GetPCHisPrescriptionProject(orgID, date.Unix(), delivery_way, patientType, partition_type, patient_id)
  85. for _, item := range project {
  86. index := 0
  87. for _, subItem := range item.HisPrescriptionTeamProject {
  88. if subItem.HisProject.CostClassify != 3 {
  89. subItem.IsCheckTeam = 2
  90. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  91. }
  92. if subItem.HisProject.CostClassify == 3 {
  93. subItem.IsCheckTeam = 1
  94. index = index + 1
  95. if index == 1 {
  96. item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  97. }
  98. }
  99. }
  100. }
  101. //for _, item := range project {
  102. // index := 0
  103. // for _, subItem := range item.HisPrescriptionTeamProject {
  104. //
  105. // //获取所有的患者
  106. // patients, _ := service.GetAllPatientListByListTwo(orgID)
  107. //
  108. // //获取所有床位
  109. // numberList, _ := service.GetAllDeviceNumberByListOne(orgID)
  110. //
  111. // //获取透析处方
  112. // prescriptions, _ := service.GetAllPrescriptionByListOne(orgID, date.Unix())
  113. //
  114. // //获取上机
  115. // dialysisOrders, _ := service.GetAllDialysisOrdersByListTwo(orgID, date.Unix())
  116. // for key, item := range project {
  117. // for _, patient := range patients {
  118. // if item.PatientId == patient.ID {
  119. // project[key].SchedualPatient = patient
  120. // break
  121. // }
  122. // }
  123. // // 获取床位信息
  124. // for _, it := range numberList {
  125. // if item.BedId == it.ID {
  126. // project[key].DeviceNumber = it
  127. // break
  128. // }
  129. // }
  130. //
  131. // // 获取处方
  132. // for _, it := range prescriptions {
  133. // if item.PatientId == it.PatientId {
  134. // project[key].Prescription = it
  135. // break
  136. // }
  137. // }
  138. //
  139. // //获取上机
  140. // for _, it := range dialysisOrders {
  141. // if item.PatientId == it.PatientId {
  142. // project[key].DialysisOrder = it
  143. // break
  144. // }
  145. // }
  146. // }
  147. // if subItem.HisProject.CostClassify != 3 {
  148. // subItem.IsCheckTeam = 2
  149. // item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  150. // }
  151. //
  152. // if subItem.HisProject.CostClassify == 3 {
  153. // subItem.IsCheckTeam = 1
  154. // index = index + 1
  155. // if index == 1 {
  156. // item.HisPrescriptionProject = append(item.HisPrescriptionProject, subItem)
  157. // }
  158. // }
  159. // }
  160. //}
  161. config, _ := service.GetHisDoctorConfig(orgID)
  162. project_config, _ := service.GetHisProjectConfig(orgID)
  163. adminUser, _ := service.GetAllAdminUsers(orgID, adminUserInfo.CurrentAppId)
  164. if err != nil {
  165. c.ErrorLog("获取排班信息失败:%v", err)
  166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  167. } else {
  168. filtedScheduals := []*service.MScheduleDoctorAdviceVM{}
  169. for _, schedual := range scheduals {
  170. if len(schedual.DoctorAdvices) > 0 {
  171. filtedScheduals = append(filtedScheduals, schedual)
  172. }
  173. }
  174. c.ServeSuccessJSON(map[string]interface{}{
  175. "scheduals": filtedScheduals,
  176. "adminUser": adminUser,
  177. "hisAdvices": hisAdvices,
  178. "config": config,
  179. "project_config": project_config,
  180. "project": project,
  181. })
  182. }
  183. }
  184. func (c *DoctorsApiController) GetAllDoctorAndNurse() {
  185. adminUserInfo := c.GetAdminUserInfo()
  186. doctors, nursers, _ := service.GetAllDoctorAndNurse(adminUserInfo.CurrentOrgId, adminUserInfo.CurrentAppId)
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "doctors": doctors,
  189. "nursers": nursers,
  190. })
  191. return
  192. }
  193. func (c *DoctorsApiController) GetAllAdminUsers() {
  194. adminUserInfo := c.GetAdminUserInfo()
  195. users, _ := service.GetAllAdminUsersTwo(adminUserInfo.CurrentOrgId)
  196. c.ServeSuccessJSON(map[string]interface{}{
  197. "users": users,
  198. })
  199. return
  200. }
  201. func (c *DoctorsApiController) GetDryWeightData() {
  202. adminUserInfo := c.GetAdminUserInfo()
  203. orgid := adminUserInfo.CurrentOrgId
  204. patientid, _ := c.GetInt64("patientid")
  205. fmt.Println("patientid", patientid)
  206. id := adminUserInfo.AdminUser.Id
  207. fmt.Println("id", id)
  208. recordDateStr := time.Now().Format("2006-01-02")
  209. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  210. fmt.Scan("parseDateErr", parseDateErr)
  211. nowtime := recordDate.Unix()
  212. fmt.Println("nowtime", nowtime)
  213. pre, err := service.GetDryWeightByPatientId(patientid, orgid)
  214. fmt.Println("错误", err)
  215. c.ServeSuccessJSON(map[string]interface{}{
  216. "pre": pre,
  217. })
  218. }
  219. func (c *DoctorsApiController) GetAllDoctor() {
  220. adminUserInfo := c.GetAdminUserInfo()
  221. orgid := adminUserInfo.CurrentOrgId
  222. appid := adminUserInfo.CurrentAppId
  223. fmt.Println("appid", appid)
  224. appRole, err := service.GetAllDoctor(orgid, appid)
  225. fmt.Println("appRole", appRole)
  226. fmt.Println("错误", err)
  227. c.ServeSuccessJSON(map[string]interface{}{
  228. "appRole": appRole,
  229. })
  230. }
  231. func (c *DoctorsApiController) UpdatedDryWeightData() {
  232. adminUserInfo := c.GetAdminUserInfo()
  233. orgid := adminUserInfo.CurrentOrgId
  234. userid := adminUserInfo.AdminUser.Id
  235. dry_weight, _ := c.GetFloat("dry_weight")
  236. doctors, _ := c.GetInt64("doctors")
  237. remarks := c.GetString("remarks")
  238. patientid, _ := c.GetInt64("patient_id")
  239. //透前数据
  240. dryweight, _ := c.GetFloat("dryweight")
  241. var weight = dryweight - dry_weight
  242. weights := fmt.Sprintf("%.1f", weight)
  243. var sum string
  244. _, errcode := service.QueryDryWeight(orgid, patientid)
  245. if errcode == gorm.ErrRecordNotFound {
  246. sum = "/"
  247. patientDryweight := models.SgjPatientDryweight{
  248. DryWeight: dry_weight,
  249. Creator: doctors,
  250. Remakes: remarks,
  251. AdjustedValue: sum,
  252. PatientId: patientid,
  253. Ctime: time.Now().Unix(),
  254. UserOrgId: orgid,
  255. Status: 1,
  256. UserId: userid,
  257. }
  258. err := service.CreatePatientWeight(&patientDryweight)
  259. loc, _ := time.LoadLocation("Local")
  260. nowTime := time.Now()
  261. nowDay := nowTime.Format("2006-01-02")
  262. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  263. redis := service.RedisClient()
  264. keyTwo := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":last_dry_weight"
  265. redis.Set(keyTwo, "", time.Second)
  266. prescription := models.PredialysisEvaluation{
  267. DryWeight: dry_weight,
  268. AssessmentDate: dayTime.Unix(),
  269. }
  270. if orgid != 10016 && orgid != 9882 && orgid != 9671 {
  271. errors := service.UpdateDialysisPrescription(patientid, orgid, dryweight, prescription)
  272. fmt.Println(errors)
  273. }
  274. keyThree := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(patientid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_before_dislysis"
  275. redis.Set(keyThree, "", time.Second)
  276. keyFive := strconv.FormatInt(orgid, 10) + ":" + strconv.FormatInt(dayTime.Unix(), 10) + ":assessment_befores_list_all"
  277. redis.Set(keyFive, "", time.Second)
  278. redis.Close()
  279. fmt.Println("err", err)
  280. c.ServeSuccessJSON(map[string]interface{}{
  281. "patientDryweight": patientDryweight,
  282. })
  283. return
  284. }
  285. fmt.Println("sum", sum)
  286. if weight == 0 {
  287. sum = "/"
  288. }
  289. if weight > 0 {
  290. sum = weights + "(" + "下调" + ")"
  291. }
  292. if weight < 0 {
  293. var sums = dry_weight - dryweight
  294. float := fmt.Sprintf("%.1f", sums)
  295. //float := strconv.FormatFloat(sums, 'E', -1, 64)
  296. sum = float + "(" + "上调" + ")"
  297. }
  298. patientDryweight := models.SgjPatientDryweight{
  299. DryWeight: dry_weight,
  300. Creator: doctors,
  301. Remakes: remarks,
  302. AdjustedValue: sum,
  303. PatientId: patientid,
  304. Ctime: time.Now().Unix(),
  305. UserOrgId: orgid,
  306. Status: 1,
  307. UserId: userid,
  308. }
  309. err := service.CreatePatientWeight(&patientDryweight)
  310. recordDateStr := time.Now().Format("2006-01-02")
  311. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  312. fmt.Scan("parseDateErr", parseDateErr)
  313. nowtime := recordDate.Unix()
  314. fmt.Println("nowtime", nowtime)
  315. loc, _ := time.LoadLocation("Local")
  316. nowTime := time.Now()
  317. nowDay := nowTime.Format("2006-01-02")
  318. dayTime, _ := time.ParseInLocation("2006-01-02 15:04:05", nowDay+" 00:00:00", loc)
  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 && orgid != 9671 {
  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. summary := models.XtTemplateSummary{
  842. StartYear: 0,
  843. StartMonth: 0,
  844. Radio: 0,
  845. Quarter: 0,
  846. DryWeight: dry_weight,
  847. DialysisCount: dialysis_count,
  848. HdCount: hd_count,
  849. HdfCount: hdf_count,
  850. HpCount: hp_count,
  851. OtherCount: other_count,
  852. DialzerApparatus: dialzer_apparatus,
  853. PerfusionApparatus: perfusion_apparatus,
  854. Anticoagulant: anticoagulant,
  855. Kalium: kalium,
  856. Autunite: autunite,
  857. Natrium: natrium,
  858. Hour: hour,
  859. Minute: minute,
  860. BeforWeight: befor_weight,
  861. AfterWeight: after_weight,
  862. BeforPressure: befor_pressure,
  863. AfterPressure: after_pressure,
  864. TemplateSummaryId: template_summary_id,
  865. TemplateSummaryContent: template_summary_content,
  866. TemplatePlanId: template_plan_id,
  867. TemplatePlanContent: template_plan_content,
  868. TemplateInspectionId: template_inspection_id,
  869. AdminUserId: admin_user_id,
  870. RecordTime: recordTime.Unix(),
  871. PatientId: patient_id,
  872. UserOrgId: orgId,
  873. Status: 1,
  874. Ctime: time.Now().Unix(),
  875. Mtime: 0,
  876. Title: title,
  877. InspectDate: inspect_date,
  878. ProjectId: project_id,
  879. }
  880. err = service.CreateSummary(&summary)
  881. if err == nil {
  882. this.ServeSuccessJSON(map[string]interface{}{
  883. "summary": summary,
  884. })
  885. return
  886. }
  887. }
  888. func (this *DoctorsApiController) GetTemplateSummaryList() {
  889. patient_id, _ := this.GetInt64("patient_id")
  890. start_time := this.GetString("start_time")
  891. timeLayout := "2006-01-02"
  892. loc, _ := time.LoadLocation("Local")
  893. end_time := this.GetString("end_time")
  894. orgId := this.GetAdminUserInfo().CurrentOrgId
  895. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  896. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  897. list, err := service.GetTemplateSummaryList(patient_id, orgId, startTime.Unix(), endTime.Unix())
  898. if err == nil {
  899. this.ServeSuccessJSON(map[string]interface{}{
  900. "list": list,
  901. })
  902. return
  903. }
  904. }
  905. func (this *DoctorsApiController) GetTemplateSummaryDetail() {
  906. id, _ := this.GetInt64("id")
  907. list, err := service.GetTemplateSummaryDetail(id)
  908. ids := strings.Split(list.ProjectId, ",")
  909. datelist := strings.Split(list.InspectDate, ",")
  910. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  911. if err == nil {
  912. this.ServeSuccessJSON(map[string]interface{}{
  913. "list": list,
  914. "inspectlist": inspectlist,
  915. })
  916. return
  917. }
  918. }
  919. func (this *DoctorsApiController) GetTemplateSummaryPrintDetail() {
  920. id, _ := this.GetInt64("id")
  921. list, err := service.GetTemplateSummaryPrintDetail(id)
  922. ids := strings.Split(list.ProjectId, ",")
  923. datelist := strings.Split(list.InspectDate, ",")
  924. inspectlist, err := service.GetInspectionItemlist(list.PatientId, datelist, ids)
  925. orgId := this.GetAdminUserInfo().CurrentOrgId
  926. doctorList, _ := service.GetAllDoctorThree(orgId)
  927. if err == nil {
  928. this.ServeSuccessJSON(map[string]interface{}{
  929. "list": list,
  930. "doctorList": doctorList,
  931. "inspectlist": inspectlist,
  932. })
  933. return
  934. }
  935. }
  936. func (this *DoctorsApiController) UpdateTempalteSummary() {
  937. dataBody := make(map[string]interface{}, 0)
  938. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  939. if err != nil {
  940. utils.ErrorLog(err.Error())
  941. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  942. return
  943. }
  944. id := int64(dataBody["id"].(float64))
  945. title := dataBody["title"].(string)
  946. dryWeight := dataBody["dry_weight"].(string)
  947. dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  948. dialysis_count := int64(dataBody["dialysis_count"].(float64))
  949. hd_count := int64(dataBody["hd_count"].(float64))
  950. hdf_count := int64(dataBody["hdf_count"].(float64))
  951. hp_count := int64(dataBody["hp_count"].(float64))
  952. other_count := int64(dataBody["other_count"].(float64))
  953. dialzer_apparatus := dataBody["dialzer_apparatus"].(string)
  954. perfusion_apparatus := dataBody["perfusion_apparatus"].(string)
  955. anticoagulant := int64(dataBody["anticoagulant"].(float64))
  956. kaliumstr := dataBody["kalium"].(string)
  957. kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  958. autunitestr := dataBody["autunite"].(string)
  959. autunite, _ := strconv.ParseFloat(autunitestr, 64)
  960. natriumstr := dataBody["natrium"].(string)
  961. natrium, _ := strconv.ParseFloat(natriumstr, 64)
  962. hour := int64(dataBody["hour"].(float64))
  963. minute := int64(dataBody["minute"].(float64))
  964. beforWeight := dataBody["befor_weight"].(string)
  965. befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  966. afterWeight := dataBody["after_weight"].(string)
  967. after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  968. befor_pressure := dataBody["befor_pressure"].(string)
  969. template_summary_content := dataBody["template_summary_content"].(string)
  970. template_plan_content := dataBody["template_plan_content"].(string)
  971. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  972. record_time := dataBody["record_time"].(string)
  973. timeLayout := "2006-01-02"
  974. loc, _ := time.LoadLocation("Local")
  975. recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  976. after_pressure := dataBody["after_pressure"].(string)
  977. template_summary_id := int64(dataBody["template_summary_id"].(float64))
  978. template_plan_id := int64(dataBody["template_plan_id"].(float64))
  979. patient_id := int64(dataBody["patient_id"].(float64))
  980. orgId := this.GetAdminUserInfo().CurrentOrgId
  981. inspect_date := dataBody["inspect_date"].(string)
  982. project_id := dataBody["project_id"].(string)
  983. template_inspection_id := int64(dataBody["template_inspection_id"].(float64))
  984. //dryWeight := this.GetString("dry_weight")
  985. //dry_weight, _ := strconv.ParseFloat(dryWeight, 64)
  986. //dialysis_count, _ := this.GetInt64("dialysis_count")
  987. //hd_count, _ := this.GetInt64("hd_count")
  988. //hdf_count, _ := this.GetInt64("hdf_count")
  989. //hp_count, _ := this.GetInt64("hp_count")
  990. //other_count, _ := this.GetInt64("other_count")
  991. //dialzer_apparatus := this.GetString("dialzer_apparatus")
  992. //perfusion_apparatus := this.GetString("perfusion_apparatus")
  993. //anticoagulant, _ := this.GetInt64("anticoagulant")
  994. //kaliumstr := this.GetString("kalium")
  995. //kalium, _ := strconv.ParseFloat(kaliumstr, 64)
  996. //
  997. //autunitestr := this.GetString("autunite")
  998. //autunite, _ := strconv.ParseFloat(autunitestr, 64)
  999. //natriumstr := this.GetString("natrium")
  1000. //natrium, _ := strconv.ParseFloat(natriumstr, 64)
  1001. //hour, _ := this.GetInt64("hour")
  1002. //minute, _ := this.GetInt64("minute")
  1003. //beforWeight := this.GetString("befor_weight")
  1004. //befor_weight, _ := strconv.ParseFloat(beforWeight, 64)
  1005. //afterWeight := this.GetString("after_weight")
  1006. //after_weight, _ := strconv.ParseFloat(afterWeight, 64)
  1007. //befor_pressure := this.GetString("befor_pressure")
  1008. //template_summary_content := this.GetString("template_summary_content")
  1009. //template_plan_content := this.GetString("template_plan_content")
  1010. //admin_user_id, _ := this.GetInt64("admin_user_id")
  1011. //record_time := this.GetString("record_time")
  1012. //timeLayout := "2006-01-02"
  1013. //loc, _ := time.LoadLocation("Local")
  1014. //recordTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time, loc)
  1015. //after_pressure := this.GetString("after_pressure")
  1016. //template_summary_id, _ := this.GetInt64("template_summary_id")
  1017. //template_plan_id, _ := this.GetInt64("template_plan_id")
  1018. //template_inspection_id, _ := this.GetInt64("template_inspection_id")
  1019. //patient_id, _ := this.GetInt64("patient_id")
  1020. //fmt.Println("patient_id", patient_id)
  1021. //orgId := this.GetAdminUserInfo().CurrentOrgId
  1022. //inspect_date := this.GetString("inspect_date")
  1023. //project_id := this.GetString("project_id")
  1024. summary := models.XtTemplateSummary{
  1025. ID: id,
  1026. StartYear: 0,
  1027. StartMonth: 0,
  1028. Radio: 0,
  1029. Quarter: 0,
  1030. DryWeight: dry_weight,
  1031. DialysisCount: dialysis_count,
  1032. HdCount: hd_count,
  1033. HdfCount: hdf_count,
  1034. HpCount: hp_count,
  1035. OtherCount: other_count,
  1036. DialzerApparatus: dialzer_apparatus,
  1037. PerfusionApparatus: perfusion_apparatus,
  1038. Anticoagulant: anticoagulant,
  1039. Kalium: kalium,
  1040. Autunite: autunite,
  1041. Natrium: natrium,
  1042. Hour: hour,
  1043. Minute: minute,
  1044. BeforWeight: befor_weight,
  1045. AfterWeight: after_weight,
  1046. BeforPressure: befor_pressure,
  1047. AfterPressure: after_pressure,
  1048. TemplateSummaryId: template_summary_id,
  1049. TemplateSummaryContent: template_summary_content,
  1050. TemplatePlanId: template_plan_id,
  1051. TemplatePlanContent: template_plan_content,
  1052. TemplateInspectionId: template_inspection_id,
  1053. AdminUserId: admin_user_id,
  1054. RecordTime: recordTime.Unix(),
  1055. PatientId: patient_id,
  1056. UserOrgId: orgId,
  1057. Status: 1,
  1058. Ctime: time.Now().Unix(),
  1059. Mtime: 0,
  1060. Title: title,
  1061. ProjectId: project_id,
  1062. InspectDate: inspect_date,
  1063. }
  1064. err = service.UpdateTempalteSummary(&summary)
  1065. if err == nil {
  1066. this.ServeSuccessJSON(map[string]interface{}{
  1067. "list": summary,
  1068. })
  1069. return
  1070. }
  1071. }
  1072. func (this *DoctorsApiController) DeleteSummary() {
  1073. ids := this.GetString("ids")
  1074. idsplit := strings.Split(ids, ",")
  1075. err := service.DeleteSummary(idsplit)
  1076. fmt.Println(err)
  1077. returnData := make(map[string]interface{}, 0)
  1078. returnData["msg"] = "ok"
  1079. this.ServeSuccessJSON(returnData)
  1080. return
  1081. }
  1082. func (this *DoctorsApiController) HospitalSummary() {
  1083. timeLayout := "2006-01-02"
  1084. loc, _ := time.LoadLocation("Local")
  1085. dataBody := make(map[string]interface{}, 0)
  1086. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1087. fmt.Print("err", err)
  1088. admission_time := dataBody["admission_time"].(string)
  1089. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1090. admissiontime := admissionTimes.Unix()
  1091. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1092. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1093. connecticut := dataBody["connecticut"].(string)
  1094. dean := int64(dataBody["dean"].(float64))
  1095. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1096. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1097. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1098. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1099. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1100. discharge_advice := dataBody["discharge_advice"].(string)
  1101. discharge_time := dataBody["discharge_time"].(string)
  1102. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1103. dischargetime := dischargeTimes.Unix()
  1104. doctor := int64(dataBody["doctor"].(float64))
  1105. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1106. illness_discharge := dataBody["illness_discharge"].(string)
  1107. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1108. pathology := dataBody["pathology"].(string)
  1109. record_date := dataBody["record_date"].(string)
  1110. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1111. recordtime := recordDates.Unix()
  1112. sick_personnel := dataBody["sick_personnel"].(string)
  1113. title := dataBody["title"].(string)
  1114. treatment_id := dataBody["treatment_id"].(string)
  1115. treatment := dataBody["treatment"].(string)
  1116. ultrasound := dataBody["ultrasound"].(string)
  1117. xray := dataBody["xray"].(string)
  1118. patient_id := int64(dataBody["patient_id"].(float64))
  1119. orgId := this.GetAdminUserInfo().CurrentOrgId
  1120. summary := models.XtHospitalSummary{
  1121. PatientId: patient_id,
  1122. AdmissionTime: admissiontime,
  1123. DischargeTime: dischargetime,
  1124. SickPersonnel: sick_personnel,
  1125. Xray: xray,
  1126. Connecticut: connecticut,
  1127. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1128. Ultrasound: ultrasound,
  1129. Pathology: pathology,
  1130. AdmittingDiagnosisId: admitting_diagnosis_id,
  1131. AdmittingDiagnosis: admitting_diagnosis,
  1132. DischargeDiagnosis: discharge_diagnosis,
  1133. DiagnosisAdmissionId: diagnosis_admission_id,
  1134. DiagnosisAdmission: diagnosis_admission,
  1135. TreatmentId: treatment_id,
  1136. Treatment: treatment,
  1137. IllnessDischargeId: illness_discharge_id,
  1138. IllnessDischarge: illness_discharge,
  1139. DischargeAdviceId: discharge_advice_id,
  1140. DischargeAdvice: discharge_advice,
  1141. UserOrgId: orgId,
  1142. Status: 1,
  1143. Ctime: time.Now().Unix(),
  1144. Mtime: 0,
  1145. RecordTime: recordtime,
  1146. Title: title,
  1147. Doctor: doctor,
  1148. RecordDate: recordtime,
  1149. DeanId: dean,
  1150. DischargeDiagnosisId: discharge_diagnosis_id,
  1151. }
  1152. service.CreateHisSummary(&summary)
  1153. this.ServeSuccessJSON(map[string]interface{}{
  1154. "list": summary,
  1155. })
  1156. return
  1157. }
  1158. func (this *DoctorsApiController) GetHospitalSummaryList() {
  1159. timeLayout := "2006-01-02"
  1160. loc, _ := time.LoadLocation("Local")
  1161. orgId := this.GetAdminUserInfo().CurrentOrgId
  1162. patient_id, _ := this.GetInt64("patient_id")
  1163. start_time := this.GetString("start_time")
  1164. fmt.Println("start_tim232232323232323232323232332", start_time)
  1165. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1166. startime := dischargeTimes.Unix()
  1167. fmt.Println("startime1111111111111111111111", startime)
  1168. end_time := this.GetString("end_time")
  1169. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  1170. endtime := endTimes.Unix()
  1171. list, err := service.GetHospitalSummaryList(orgId, patient_id, startime, endtime)
  1172. if err == nil {
  1173. this.ServeSuccessJSON(map[string]interface{}{
  1174. "list": list,
  1175. })
  1176. return
  1177. }
  1178. }
  1179. func (this *DoctorsApiController) GetHospitalSummaryDetail() {
  1180. id, _ := this.GetInt64("id")
  1181. detail, err := service.GetHospitalSummaryDetail(id)
  1182. if err == nil {
  1183. this.ServeSuccessJSON(map[string]interface{}{
  1184. "detail": detail,
  1185. })
  1186. return
  1187. }
  1188. }
  1189. func (this *DoctorsApiController) UpdateHospitalSummary() {
  1190. timeLayout := "2006-01-02"
  1191. loc, _ := time.LoadLocation("Local")
  1192. dataBody := make(map[string]interface{}, 0)
  1193. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1194. fmt.Print("err", err)
  1195. admission_time := dataBody["admission_time"].(string)
  1196. admissionTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", admission_time+" 00:00:00", loc)
  1197. admissiontime := admissionTimes.Unix()
  1198. admitting_diagnosis := dataBody["admitting_diagnosis"].(string)
  1199. admitting_diagnosis_id := dataBody["admitting_diagnosis_id"].(string)
  1200. connecticut := dataBody["connecticut"].(string)
  1201. dean := int64(dataBody["dean"].(float64))
  1202. discharge_diagnosis := dataBody["discharge_diagnosis"].(string)
  1203. discharge_diagnosis_id := dataBody["discharge_diagnosis_id"].(string)
  1204. diagnosis_admission := dataBody["diagnosis_admission"].(string)
  1205. diagnosis_admission_id := dataBody["diagnosis_admission_id"].(string)
  1206. discharge_advice_id := dataBody["discharge_advice_id"].(string)
  1207. discharge_advice := dataBody["discharge_advice"].(string)
  1208. discharge_time := dataBody["discharge_time"].(string)
  1209. dischargeTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", discharge_time+" 00:00:00", loc)
  1210. dischargetime := dischargeTimes.Unix()
  1211. doctor := int64(dataBody["doctor"].(float64))
  1212. illness_discharge_id := dataBody["illness_discharge_id"].(string)
  1213. illness_discharge := dataBody["illness_discharge"].(string)
  1214. nuclear_magnetic_resonance := dataBody["nuclear_magnetic_resonance"].(string)
  1215. pathology := dataBody["pathology"].(string)
  1216. record_date := dataBody["record_date"].(string)
  1217. recordDates, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  1218. recordtime := recordDates.Unix()
  1219. sick_personnel := dataBody["sick_personnel"].(string)
  1220. title := dataBody["title"].(string)
  1221. treatment_id := dataBody["treatment_id"].(string)
  1222. treatment := dataBody["treatment"].(string)
  1223. ultrasound := dataBody["ultrasound"].(string)
  1224. xray := dataBody["xray"].(string)
  1225. patient_id := int64(dataBody["patient_id"].(float64))
  1226. id := int64(dataBody["id"].(float64))
  1227. summary := models.XtHospitalSummary{
  1228. PatientId: patient_id,
  1229. AdmissionTime: admissiontime,
  1230. DischargeTime: dischargetime,
  1231. SickPersonnel: sick_personnel,
  1232. Xray: xray,
  1233. Connecticut: connecticut,
  1234. NuclearMagneticResonance: nuclear_magnetic_resonance,
  1235. Ultrasound: ultrasound,
  1236. Pathology: pathology,
  1237. AdmittingDiagnosisId: admitting_diagnosis_id,
  1238. AdmittingDiagnosis: admitting_diagnosis,
  1239. DischargeDiagnosis: discharge_diagnosis,
  1240. DiagnosisAdmissionId: diagnosis_admission_id,
  1241. DiagnosisAdmission: diagnosis_admission,
  1242. TreatmentId: treatment_id,
  1243. Treatment: treatment,
  1244. IllnessDischargeId: illness_discharge_id,
  1245. IllnessDischarge: illness_discharge,
  1246. DischargeAdviceId: discharge_advice_id,
  1247. DischargeAdvice: discharge_advice,
  1248. Mtime: time.Now().Unix(),
  1249. RecordTime: recordtime,
  1250. Title: title,
  1251. Doctor: doctor,
  1252. RecordDate: recordtime,
  1253. DeanId: dean,
  1254. DischargeDiagnosisId: discharge_diagnosis_id,
  1255. }
  1256. err = service.UpdateHospital(id, summary)
  1257. if err == nil {
  1258. this.ServeSuccessJSON(map[string]interface{}{
  1259. "detail": summary,
  1260. })
  1261. return
  1262. }
  1263. }
  1264. func (this *DoctorsApiController) DeleteHospitalSummary() {
  1265. schIDStr := this.GetString("ids")
  1266. idStrs := strings.Split(schIDStr, ",")
  1267. err := service.DeleteHospitalSummary(idStrs)
  1268. fmt.Println(err)
  1269. returnData := make(map[string]interface{}, 0)
  1270. returnData["msg"] = "ok"
  1271. this.ServeSuccessJSON(returnData)
  1272. return
  1273. }
  1274. func (this *DoctorsApiController) GetPatientInfo() {
  1275. patient_id, _ := this.GetInt64("patient_id")
  1276. orgId := this.GetAdminUserInfo().CurrentOrgId
  1277. detail, err := service.GetPatientDetail(patient_id, orgId)
  1278. if err == nil {
  1279. this.ServeSuccessJSON(map[string]interface{}{
  1280. "patient": detail,
  1281. })
  1282. return
  1283. }
  1284. }