common_api_controller.go 50KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447
  1. package new_mobile_api_controllers
  2. import (
  3. "XT_New/controllers"
  4. "XT_New/enums"
  5. "XT_New/models"
  6. "XT_New/service"
  7. "XT_New/utils"
  8. "encoding/json"
  9. "fmt"
  10. "github.com/jinzhu/gorm"
  11. "strconv"
  12. "time"
  13. )
  14. type CommonApiController struct {
  15. controllers.BaseAuthAPIController
  16. }
  17. func (this *CommonApiController) GetInspectionMajor() {
  18. adminInfo := this.GetAdminUserInfo()
  19. orgid := adminInfo.CurrentOrgId
  20. major, err := service.GetInspectionMajor(orgid)
  21. if len(major) == 0 {
  22. major, _ := service.GetInspectionMajor(0)
  23. if err != nil {
  24. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  25. return
  26. }
  27. this.ServeSuccessJSON(map[string]interface{}{
  28. "inspection": major,
  29. })
  30. }
  31. if err != nil {
  32. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  33. return
  34. }
  35. this.ServeSuccessJSON(map[string]interface{}{
  36. "inspection": major,
  37. })
  38. }
  39. func (this *CommonApiController) GetInspectionMinor() {
  40. id, _ := this.GetInt64("id")
  41. adminInfo := this.GetAdminUserInfo()
  42. orgId := adminInfo.CurrentOrgId
  43. //查询该机构是否存在小项
  44. major, _ := service.GetInspectionMajor(orgId)
  45. if len(major) == 0 {
  46. minor, err := service.GetInspectionMinor(id, 0)
  47. if err != nil {
  48. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  49. return
  50. }
  51. this.ServeSuccessJSON(map[string]interface{}{
  52. "inspection": minor,
  53. })
  54. } else {
  55. minor, err := service.GetInspectionMinor(id, orgId)
  56. if err != nil {
  57. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  58. return
  59. }
  60. this.ServeSuccessJSON(map[string]interface{}{
  61. "inspection": minor,
  62. })
  63. }
  64. }
  65. func (this *CommonApiController) GetInspectionRange() {
  66. id, _ := this.GetInt64("id")
  67. fmt.Println("id", id)
  68. inspectionRange, err := service.GetInspectionRange(id)
  69. if err != nil {
  70. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  71. return
  72. }
  73. this.ServeSuccessJSON(map[string]interface{}{
  74. "inspectionRange": inspectionRange,
  75. })
  76. }
  77. func (this *CommonApiController) SaveConfiguration() {
  78. adminInfo := this.GetAdminUserInfo()
  79. orgid := adminInfo.CurrentOrgId
  80. dataBody := make(map[string]interface{}, 0)
  81. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  82. fmt.Println("err", err)
  83. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  84. fmt.Println("大项", inspectionmajor)
  85. inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
  86. fmt.Println("小项", inspectionMinor)
  87. minrange := dataBody["min_range"].(string)
  88. fmt.Println("minragne", minrange)
  89. largerange := dataBody["large_range"].(string)
  90. fmt.Println("largerange", largerange)
  91. sort := dataBody["sort"].(string)
  92. sorts, err := strconv.ParseInt(sort, 10, 64)
  93. fmt.Println("sort", sort)
  94. checktype := int64(dataBody["check_type"].(float64))
  95. fmt.Println("检查类型", checktype)
  96. rangvalue := dataBody["range_value"].(string)
  97. fmt.Println("rangvalue", rangvalue)
  98. if rangvalue == "0" {
  99. rangvalue = ""
  100. }
  101. _, errcode := service.GetConfigurationById(inspectionmajor, inspectionMinor, orgid)
  102. if errcode == gorm.ErrRecordNotFound {
  103. standard := models.XtQualityControlStandard{
  104. InspectionMajor: inspectionmajor,
  105. InspectionMinor: inspectionMinor,
  106. MinRange: minrange,
  107. LargeRange: largerange,
  108. Sort: sorts,
  109. UserOrgId: orgid,
  110. Status: 1,
  111. RangeType: checktype,
  112. RangeValue: rangvalue,
  113. CreatedTime: time.Now().Unix(),
  114. }
  115. fmt.Println(standard)
  116. err = service.SaveInspection(&standard)
  117. if err != nil {
  118. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  119. return
  120. }
  121. this.ServeSuccessJSON(map[string]interface{}{
  122. "standard": standard,
  123. })
  124. } else if errcode == nil {
  125. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  126. return
  127. }
  128. }
  129. func (this *CommonApiController) GetConfigurationlist() {
  130. limit, _ := this.GetInt64("limit")
  131. page, _ := this.GetInt64("page")
  132. adminUser := this.GetAdminUserInfo()
  133. orgid := adminUser.CurrentOrgId
  134. configurationlist, total, err := service.GetConfigurationlist(orgid, limit, page)
  135. if err != nil {
  136. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  137. return
  138. }
  139. this.ServeSuccessJSON(map[string]interface{}{
  140. "configurationlist": configurationlist,
  141. "total": total,
  142. })
  143. }
  144. func (this *CommonApiController) GetConfigurationDetail() {
  145. id, _ := this.GetInt64("id")
  146. fmt.Println("id是", id)
  147. detail, err := service.GetConfigurationDetail(id)
  148. if err != nil {
  149. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  150. return
  151. }
  152. this.ServeSuccessJSON(map[string]interface{}{
  153. "configurationdetail": detail,
  154. })
  155. }
  156. func (this *CommonApiController) GetAllInspectionminor() {
  157. minor, err := service.GetAllInspectionMinor(0)
  158. if err != nil {
  159. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  160. return
  161. }
  162. this.ServeSuccessJSON(map[string]interface{}{
  163. "minor": minor,
  164. })
  165. }
  166. func (this *CommonApiController) UpdateConfiguration() {
  167. id, _ := this.GetInt64("id")
  168. fmt.Println("id", id)
  169. dataBody := make(map[string]interface{}, 0)
  170. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  171. fmt.Println("err", err)
  172. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  173. fmt.Println("大项", inspectionmajor)
  174. inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
  175. fmt.Println("小项", inspectionMinor)
  176. minrange := dataBody["min_range"].(string)
  177. fmt.Println("minragne", minrange)
  178. largerange := dataBody["large_range"].(string)
  179. fmt.Println("largerange", largerange)
  180. sort := int64(dataBody["sort"].(float64))
  181. fmt.Println("排序", sort)
  182. rangvalue := dataBody["range_value"].(string)
  183. fmt.Println("范围", rangvalue)
  184. if rangvalue == "0" {
  185. rangvalue = ""
  186. }
  187. rangtype := int64(dataBody["check_type"].(float64))
  188. adminInfo := this.GetAdminUserInfo()
  189. orgId := adminInfo.CurrentOrgId
  190. configuration, err := service.GetConfigurationByIdTwo(inspectionmajor, inspectionMinor, orgId)
  191. fmt.Println("err", err)
  192. if configuration.ID > 0 && configuration.ID != id {
  193. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  194. return
  195. }
  196. standard := models.XtQualityControlStandard{
  197. InspectionMajor: inspectionmajor,
  198. InspectionMinor: inspectionMinor,
  199. MinRange: minrange,
  200. LargeRange: largerange,
  201. Sort: sort,
  202. RangeValue: rangvalue,
  203. RangeType: rangtype,
  204. Status: 1,
  205. UserOrgId: orgId,
  206. CreatedTime: time.Now().Unix(),
  207. UpdatedTime: time.Now().Unix(),
  208. }
  209. err = service.UpdarteConfiguration(&standard, id)
  210. if err != nil {
  211. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  212. return
  213. }
  214. this.ServeSuccessJSON(map[string]interface{}{
  215. "standard": standard,
  216. })
  217. }
  218. func (this *CommonApiController) DeleteConfiguration() {
  219. id, _ := this.GetInt64("id")
  220. err := service.DeleteConfiguration(id)
  221. if err != nil {
  222. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  223. return
  224. }
  225. returnData := make(map[string]interface{}, 0)
  226. returnData["msg"] = "ok"
  227. this.ServeSuccessJSON(returnData)
  228. return
  229. }
  230. func (this *CommonApiController) GetAllInspectiondata() {
  231. adminUser := this.GetAdminUserInfo()
  232. orgid := adminUser.CurrentOrgId
  233. //查询该机构是否有数据
  234. _, errcode := service.GetAllInspectionData(orgid)
  235. if errcode == gorm.ErrRecordNotFound {
  236. inspection, err := service.GetAllInspectiondatatwo(0)
  237. if err != nil {
  238. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  239. return
  240. }
  241. this.ServeSuccessJSON(map[string]interface{}{
  242. "inspection": inspection,
  243. })
  244. } else if errcode == nil {
  245. inspection, err := service.GetAllInspectiondatatwo(orgid)
  246. if err != nil {
  247. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  248. return
  249. }
  250. this.ServeSuccessJSON(map[string]interface{}{
  251. "inspection": inspection,
  252. })
  253. }
  254. }
  255. func (this *CommonApiController) SaveCheckConfiguration() {
  256. dataBody := make(map[string]interface{}, 0)
  257. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  258. fmt.Println("err", err)
  259. adminUser := this.GetAdminUserInfo()
  260. orgid := adminUser.CurrentOrgId
  261. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  262. fmt.Println("大项", inspectionmajor)
  263. frequency := dataBody["frequency"].(string)
  264. fmt.Println("凭次", frequency)
  265. sort := dataBody["sort"].(string)
  266. sorts, err := strconv.ParseInt(sort, 10, 64)
  267. fmt.Println("sort", sort)
  268. _, errcode := service.GetInspectionMajorById(inspectionmajor, orgid)
  269. if errcode == gorm.ErrRecordNotFound {
  270. configuration := models.XtCheckConfiguration{
  271. InspectionMajor: inspectionmajor,
  272. InspectionFrequency: frequency,
  273. Sort: sorts,
  274. UserOrgId: orgid,
  275. Status: 1,
  276. CreatedTime: time.Now().Unix(),
  277. }
  278. err := service.CreateCheckConfiguration(&configuration)
  279. if err != nil {
  280. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  281. return
  282. }
  283. this.ServeSuccessJSON(map[string]interface{}{
  284. "configuration": configuration,
  285. })
  286. } else if errcode == nil {
  287. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  288. return
  289. }
  290. }
  291. func (this *CommonApiController) GetAllCheckList() {
  292. adminUser := this.GetAdminUserInfo()
  293. orgid := adminUser.CurrentOrgId
  294. fmt.Println("org", orgid)
  295. page, _ := this.GetInt64("page")
  296. limit, _ := this.GetInt64("limit")
  297. checkList, total, err := service.GetAllCheckList(orgid, page, limit)
  298. if err != nil {
  299. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  300. return
  301. }
  302. this.ServeSuccessJSON(map[string]interface{}{
  303. "checklist": checkList,
  304. "total": total,
  305. })
  306. }
  307. func (this *CommonApiController) GetCheckdetail() {
  308. id, _ := this.GetInt64("id")
  309. detail, err := service.GetCheckDetail(id)
  310. if err != nil {
  311. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  312. return
  313. }
  314. this.ServeSuccessJSON(map[string]interface{}{
  315. "checkdetail": detail,
  316. })
  317. }
  318. func (this *CommonApiController) UpdateCheck() {
  319. id, _ := this.GetInt64("id")
  320. fmt.Println(id)
  321. dataBody := make(map[string]interface{}, 0)
  322. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  323. fmt.Println(err)
  324. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  325. fmt.Println("大项", inspectionmajor)
  326. frequency := dataBody["frequency"].(string)
  327. fmt.Println("凭次", frequency)
  328. sort := int64(dataBody["sort"].(float64))
  329. fmt.Println("sort", sort)
  330. adminInfo := this.GetAdminUserInfo()
  331. orgId := adminInfo.CurrentOrgId
  332. Inspection, err := service.GetInspectionMajorByIdTwo(inspectionmajor, orgId)
  333. if Inspection.ID > 0 && Inspection.ID != id {
  334. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  335. return
  336. }
  337. configuration := models.XtCheckConfiguration{
  338. InspectionMajor: inspectionmajor,
  339. InspectionFrequency: frequency,
  340. Sort: sort,
  341. }
  342. err = service.UpdateCheck(&configuration, id)
  343. if err != nil {
  344. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  345. return
  346. }
  347. this.ServeSuccessJSON(map[string]interface{}{
  348. "configuration": configuration,
  349. })
  350. }
  351. func (this *CommonApiController) DeleteCheck() {
  352. id, _ := this.GetInt64("id")
  353. err := service.DeleteCheck(id)
  354. if err != nil {
  355. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  356. return
  357. }
  358. returnData := make(map[string]interface{}, 0)
  359. returnData["msg"] = "ok"
  360. this.ServeSuccessJSON(returnData)
  361. return
  362. }
  363. func (this *CommonApiController) GetDialysisModeType() {
  364. timeLayout := "2006-01-02"
  365. loc, _ := time.LoadLocation("Local")
  366. startime := this.GetString("startime")
  367. endtime := this.GetString("endtime")
  368. fmt.Println("endtime", endtime)
  369. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  370. startimes := startTimes.Unix()
  371. // fmt.Println("startime",startimes)
  372. endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  373. endtimeData := endtimes.Unix()
  374. // fmt.Println("结束日期",endtimeData)
  375. adminUser := this.GetAdminUserInfo()
  376. orgid := adminUser.CurrentOrgId
  377. //统计透析总量
  378. _, total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid)
  379. modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid)
  380. if err != nil {
  381. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  382. return
  383. }
  384. this.ServeSuccessJSON(map[string]interface{}{
  385. "total": total,
  386. "modetype": modeType,
  387. })
  388. }
  389. func (this *CommonApiController) GetTotalLapseCount() {
  390. timeLayout := "2006-01-02"
  391. loc, _ := time.LoadLocation("Local")
  392. adminUser := this.GetAdminUserInfo()
  393. orgid := adminUser.CurrentOrgId
  394. startime := this.GetString("startime")
  395. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  396. startnunix := startTimes.Unix()
  397. //fmt.Println("开始时间==========",startnunix)
  398. endtime := this.GetString("endtime")
  399. endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
  400. endunix := endtimes.Unix()
  401. //fmt.Println("结束日期========",endunix)
  402. //统计一个月内转出的病人
  403. //patients, total, err := service.GetTotalRollOut(startime, endtime, orgid)
  404. //统计该机构的转出人数
  405. patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix)
  406. //统计该机构转出病人
  407. patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix)
  408. //统计总共病人
  409. // _, count, _ := service.GetPatientTotalCountTwo(orgid, startime, endtime)
  410. count := service.GetPatientTotalCount(orgid)
  411. if err != nil {
  412. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  413. return
  414. }
  415. this.ServeSuccessJSON(map[string]interface{}{
  416. "patients": patients,
  417. "count": count,
  418. "patienttwo": patienttwo,
  419. })
  420. }
  421. func (this *CommonApiController) GetTotalSexCount() {
  422. adminUser := this.GetAdminUserInfo()
  423. orgid := adminUser.CurrentOrgId
  424. fmt.Println("orgid", orgid)
  425. startime, _ := this.GetInt64("startime")
  426. fmt.Println("开始时间", startime)
  427. endtime, _ := this.GetInt64("endtime")
  428. fmt.Println("结束时间", endtime)
  429. total := service.GetPatientTotalCount(orgid)
  430. _, totalSex, err := service.GetManPatientTotal(orgid)
  431. if err != nil {
  432. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  433. return
  434. }
  435. this.ServeSuccessJSON(map[string]interface{}{
  436. "total": total,
  437. "totalSex": totalSex,
  438. })
  439. }
  440. func (this *CommonApiController) GetTotalInfectiouscount() {
  441. adminUser := this.GetAdminUserInfo()
  442. orgid := adminUser.CurrentOrgId
  443. fmt.Println("orgid", orgid)
  444. timeLayout := "2006-01-02"
  445. loc, _ := time.LoadLocation("Local")
  446. startime := this.GetString("startime")
  447. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  448. startnunix := startTimes.Unix()
  449. endtime := this.GetString("endtime")
  450. endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
  451. endunix := endtimes.Unix()
  452. //统计透析总人数
  453. total := service.GetPatientTotalCount(orgid)
  454. //统计透析人数传染病所占比例
  455. count, err := service.GetPatientInfectiousCount(orgid, startnunix, endunix)
  456. //统计其他
  457. _, otherTotal, err := service.GetPatientOtherInfectious(orgid)
  458. if err != nil {
  459. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  460. return
  461. }
  462. this.ServeSuccessJSON(map[string]interface{}{
  463. "total": total,
  464. "count": count,
  465. "otherTotal": otherTotal,
  466. })
  467. }
  468. func (this *CommonApiController) GetTotalAgeCount() {
  469. adminUser := this.GetAdminUserInfo()
  470. orgid := adminUser.CurrentOrgId
  471. fmt.Println("orgid", orgid)
  472. startime, _ := this.GetInt64("startime")
  473. fmt.Println("开始时间", startime)
  474. endtime, _ := this.GetInt64("endtime")
  475. fmt.Println("结束时间", endtime)
  476. //统计透析总人数
  477. total := service.GetPatientTotalCount(orgid)
  478. agecount, err := service.GetTotalAgeCount(orgid)
  479. //two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
  480. if err != nil {
  481. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  482. return
  483. }
  484. this.ServeSuccessJSON(map[string]interface{}{
  485. "total": total,
  486. "ageCount": agecount,
  487. })
  488. }
  489. func (this *CommonApiController) GetTotalDialysisCount() {
  490. adminUser := this.GetAdminUserInfo()
  491. orgid := adminUser.CurrentOrgId
  492. fmt.Println("org", orgid)
  493. startime, _ := this.GetInt64("startime")
  494. fmt.Println(startime)
  495. endtime, _ := this.GetInt64("endtime")
  496. fmt.Println(endtime)
  497. recordDateStr := time.Now().Format("2006-01-02")
  498. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  499. fmt.Println("parseDateErr", parseDateErr)
  500. nowtime := recordDate.Unix()
  501. //统计透析总人数
  502. total := service.GetPatientTotalCount(orgid)
  503. fmt.Println("total", total)
  504. //获取该机构下的所有病人数据
  505. patients, err := service.GetTotalDialysisAgeCount(orgid)
  506. fmt.Println("patients", patients)
  507. //统计透年龄
  508. dataage, _ := service.GetDialysisAgeData(orgid)
  509. if err != nil {
  510. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  511. return
  512. }
  513. this.ServeSuccessJSON(map[string]interface{}{
  514. "total": total,
  515. "patients": patients,
  516. "nowtime": nowtime,
  517. "dataage": dataage,
  518. })
  519. }
  520. func (this *CommonApiController) GetCurentOrgPatients() {
  521. adminUser := this.GetAdminUserInfo()
  522. orgid := adminUser.CurrentOrgId
  523. patients, err := service.GetCurentOrgPatients(orgid)
  524. if err != nil {
  525. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  526. return
  527. }
  528. this.ServeSuccessJSON(map[string]interface{}{
  529. "patients": patients,
  530. })
  531. }
  532. func (this *CommonApiController) GetDialysislist() {
  533. startime := this.GetString("startime")
  534. fmt.Println("startime", startime)
  535. endtime := this.GetString("endtime")
  536. fmt.Println("enditme", endtime)
  537. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  538. fmt.Println("parseDateErr", parseDateErr)
  539. statime := startDate.Unix()
  540. fmt.Println("开始时间", statime)
  541. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  542. entime := endDate.Unix()
  543. fmt.Println("开始时间", statime)
  544. page, _ := this.GetInt64("page")
  545. fmt.Println("page", page)
  546. limit, _ := this.GetInt64("limit")
  547. fmt.Println("limit", limit)
  548. adminUser := this.GetAdminUserInfo()
  549. orgId := adminUser.CurrentOrgId
  550. count, _ := service.TotalDialysisCount(statime, entime, orgId)
  551. dialysislist, total, err := service.GetDialysisList(statime, entime, page, limit, orgId)
  552. prescriptionList, _ := service.GetAllDialysisList(statime, entime, orgId)
  553. list, totallist, _ := service.GetDialysisPatientList(statime, entime, page, limit, orgId)
  554. fmt.Println("err", err)
  555. if err != nil {
  556. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  557. return
  558. }
  559. this.ServeSuccessJSON(map[string]interface{}{
  560. "dialysislist": dialysislist,
  561. "total": total,
  562. "list": list,
  563. "totallist": totallist,
  564. "prescriptionList": prescriptionList,
  565. "count": count,
  566. })
  567. }
  568. func (this *CommonApiController) GetLastSort() {
  569. adminUser := this.GetAdminUserInfo()
  570. orgid := adminUser.CurrentOrgId
  571. standard, err := service.GetLastSort(orgid)
  572. if err != nil {
  573. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  574. return
  575. }
  576. this.ServeSuccessJSON(map[string]interface{}{
  577. "standard": standard,
  578. })
  579. }
  580. func (this *CommonApiController) GetLastCheckList() {
  581. adminUser := this.GetAdminUserInfo()
  582. orgid := adminUser.CurrentOrgId
  583. checkList, err := service.GetLastCheckList(orgid)
  584. if err != nil {
  585. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  586. return
  587. }
  588. this.ServeSuccessJSON(map[string]interface{}{
  589. "checkList": checkList,
  590. })
  591. }
  592. func (this *CommonApiController) GetDialysisDetailById() {
  593. adminUser := this.GetAdminUserInfo()
  594. orgId := adminUser.CurrentOrgId
  595. id, _ := this.GetInt64("id")
  596. fmt.Println("id", id)
  597. startime := this.GetString("startime")
  598. fmt.Println(startime)
  599. endtime := this.GetString("endtime")
  600. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  601. fmt.Println("parseDateErr", parseDateErr)
  602. statime := startDate.Unix()
  603. fmt.Println("开始时间", statime)
  604. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  605. entime := endDate.Unix()
  606. fmt.Println("开始时间", statime)
  607. fmt.Println(endtime)
  608. limit, _ := this.GetInt64("limit")
  609. fmt.Println("limit", limit)
  610. page, _ := this.GetInt64("page")
  611. fmt.Println("page", page)
  612. patients, total, err := service.GetDialysisDetailById(id, orgId, statime, entime, limit, page)
  613. if err != nil {
  614. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  615. return
  616. }
  617. this.ServeSuccessJSON(map[string]interface{}{
  618. "patients": patients,
  619. "total": total,
  620. })
  621. }
  622. func (this *CommonApiController) GetPrescritionByName() {
  623. adminUser := this.GetAdminUserInfo()
  624. orgId := adminUser.CurrentOrgId
  625. //keyword := this.GetString("keyword")
  626. patientid, _ := this.GetInt64("patientid")
  627. startime := this.GetString("startime")
  628. fmt.Println(startime)
  629. endtime := this.GetString("endtime")
  630. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  631. fmt.Println("parseDateErr", parseDateErr)
  632. statime := startDate.Unix()
  633. fmt.Println("开始时间", statime)
  634. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  635. entime := endDate.Unix()
  636. fmt.Println("开始时间", statime)
  637. fmt.Println(endtime)
  638. limit, _ := this.GetInt64("limit")
  639. fmt.Println("limit", limit)
  640. page, _ := this.GetInt64("page")
  641. fmt.Println("page", page)
  642. patient, total, err := service.GetPrescritionByName(orgId, patientid, statime, entime, limit, page)
  643. if err != nil {
  644. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  645. return
  646. }
  647. this.ServeSuccessJSON(map[string]interface{}{
  648. "patient": patient,
  649. "total": total,
  650. })
  651. }
  652. func (this *CommonApiController) GetStatistics() {
  653. adminUser := this.GetAdminUserInfo()
  654. orgId := adminUser.CurrentOrgId
  655. fmt.Println("orgid", orgId)
  656. startime := this.GetString("start_time")
  657. fmt.Println(startime)
  658. endtime := this.GetString("end_time")
  659. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  660. fmt.Println("parseDateErr", parseDateErr)
  661. statime := startDate.Unix()
  662. fmt.Println("开始时间", statime)
  663. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  664. entime := endDate.Unix()
  665. fmt.Println("结束日期", entime)
  666. value, _ := this.GetInt64("value")
  667. fmt.Println("value", value)
  668. limit, _ := this.GetInt64("limit")
  669. fmt.Println("limit", limit)
  670. page, _ := this.GetInt64("page")
  671. fmt.Println("page", page)
  672. modeId, _ := this.GetInt64("mode_id")
  673. treatinfo, total, err := service.GetTreateInfo(orgId, statime, entime, value, limit, page)
  674. statistics, ttd, _ := service.GetStatistics(orgId, statime, entime, modeId)
  675. if err != nil {
  676. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  677. return
  678. }
  679. this.ServeSuccessJSON(map[string]interface{}{
  680. "statistics": statistics,
  681. "ttd": ttd,
  682. "total": total,
  683. "treatinfo": treatinfo,
  684. })
  685. }
  686. func (this *CommonApiController) GetInspectionTatolCount() {
  687. adminUser := this.GetAdminUserInfo()
  688. orgid := adminUser.CurrentOrgId
  689. startime := this.GetString("startime")
  690. fmt.Println(startime)
  691. endtime := this.GetString("endtime")
  692. fmt.Print("endtime", endtime)
  693. patientid, _ := this.GetInt64("patientid")
  694. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  695. fmt.Println("parseDateErr", parseDateErr)
  696. statime := startDate.Unix()
  697. secondQuarterEndStr := endtime + " 23:59:59"
  698. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  699. entime := secondQuarterEnds.Unix()
  700. references, err := service.GetInspectionTotalCount(orgid)
  701. if err != nil {
  702. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  703. return
  704. }
  705. counts, err := service.GetInspectionProjectCount(orgid, statime, entime, patientid)
  706. this.ServeSuccessJSON(map[string]interface{}{
  707. "Inspection": references,
  708. "counts": counts,
  709. })
  710. }
  711. func (this *CommonApiController) GetInspectionDetailById() {
  712. adminUser := this.GetAdminUserInfo()
  713. orgId := adminUser.CurrentOrgId
  714. id, _ := this.GetInt64("id")
  715. fmt.Println("id", id)
  716. startime := this.GetString("startime")
  717. endtime := this.GetString("endtime")
  718. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  719. fmt.Println("parseDateErr", parseDateErr)
  720. statime := startDate.Unix()
  721. fmt.Println("开始时间", statime)
  722. secondQuarterEndStr := endtime + " 23:59:59"
  723. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  724. entime := secondQuarterEnds.Unix()
  725. patientdetail, err := service.GetInspectionDetailById(id, orgId, statime, entime)
  726. if err != nil {
  727. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  728. return
  729. }
  730. this.ServeSuccessJSON(map[string]interface{}{
  731. "patientdetail": patientdetail,
  732. })
  733. }
  734. func (this *CommonApiController) GetSearchPatientInfo() {
  735. adminUser := this.GetAdminUserInfo()
  736. orgId := adminUser.CurrentOrgId
  737. //keyword := this.GetString("keyword")
  738. //fmt.Println("keyword", keyword)
  739. patientid, _ := this.GetInt64("patientid")
  740. startime := this.GetString("startime")
  741. endtime := this.GetString("endtime")
  742. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  743. fmt.Println("parseDateErr", parseDateErr)
  744. statime := startDate.Unix()
  745. fmt.Println("开始时间", statime)
  746. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  747. //entime := endDate.Unix()
  748. //fmt.Println("结束日期", entime)
  749. secondQuarterEndStr := endtime + " 23:59:59"
  750. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  751. entime := secondQuarterEnds.Unix()
  752. PatientsInfo, err := service.GetSearchPatientInfo(orgId, patientid, statime, entime)
  753. if err != nil {
  754. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  755. return
  756. }
  757. this.ServeSuccessJSON(map[string]interface{}{
  758. "PatientsInfo": PatientsInfo,
  759. })
  760. }
  761. func (this *CommonApiController) GetAllMajorInspection() {
  762. adminUser := this.GetAdminUserInfo()
  763. orgid := adminUser.CurrentOrgId
  764. inspection, err := service.GetMajorInspectionByOrgid(orgid)
  765. if len(inspection) == 0 {
  766. inspect, err := service.GetDefaultByOrgId(0)
  767. if err != nil {
  768. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  769. return
  770. }
  771. this.ServeSuccessJSON(map[string]interface{}{
  772. "inspection": inspect,
  773. })
  774. } else {
  775. if err != nil {
  776. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  777. return
  778. }
  779. this.ServeSuccessJSON(map[string]interface{}{
  780. "inspection": inspection,
  781. })
  782. }
  783. }
  784. func (this *CommonApiController) GetPatientList() {
  785. adminUser := this.GetAdminUserInfo()
  786. orgid := adminUser.CurrentOrgId
  787. startime := this.GetString("startime")
  788. endtime := this.GetString("endtime")
  789. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  790. fmt.Println("parseDateErr", parseDateErr)
  791. statime := startDate.Unix()
  792. fmt.Println("开始时间", statime)
  793. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  794. // //entime := endDate.Unix()
  795. endTimeYMDHmsStr := endtime + " 23:59:59"
  796. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  797. entime := endDate.Unix()
  798. fmt.Println("结束日期", entime)
  799. limit, _ := this.GetInt64("limit")
  800. fmt.Println("limit", limit)
  801. page, _ := this.GetInt64("page")
  802. fmt.Println("page", page)
  803. patientInfo, total, err := service.GetPatientListData(orgid, statime, entime, limit, page)
  804. info, _ := service.GetPatientListInfo(orgid, statime, entime, limit, page)
  805. if err != nil {
  806. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  807. return
  808. }
  809. this.ServeSuccessJSON(map[string]interface{}{
  810. "patientInfo": patientInfo,
  811. "total": total,
  812. "list": info,
  813. })
  814. }
  815. func (this *CommonApiController) GetPatientDetailCheck() {
  816. adminUser := this.GetAdminUserInfo()
  817. orgid := adminUser.CurrentOrgId
  818. id, _ := this.GetInt64("id")
  819. startime := this.GetString("startime")
  820. endtime := this.GetString("endtime")
  821. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  822. fmt.Println("parseDateErr", parseDateErr)
  823. statime := startDate.Unix()
  824. fmt.Println("开始时间", statime)
  825. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  826. //entime := endDate.Unix()
  827. //fmt.Println("结束日期", entime)
  828. endTimeYMDHmsStr := endtime + " 23:59:59"
  829. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  830. entime := endDate.Unix()
  831. checkDetail, err := service.GetPatientDetailCheck(id, orgid, statime, entime)
  832. if err != nil {
  833. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  834. return
  835. }
  836. this.ServeSuccessJSON(map[string]interface{}{
  837. "checkDetail": checkDetail,
  838. })
  839. }
  840. func (this *CommonApiController) GetSearchDetailCheck() {
  841. adminUser := this.GetAdminUserInfo()
  842. orgid := adminUser.CurrentOrgId
  843. keyword := this.GetString("keyword")
  844. startime := this.GetString("startime")
  845. endtime := this.GetString("endtime")
  846. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  847. fmt.Println("parseDateErr", parseDateErr)
  848. statime := startDate.Unix()
  849. fmt.Println("开始时间", statime)
  850. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  851. entime := endDate.Unix()
  852. fmt.Println("结束日期", entime)
  853. checkDetail, err := service.GetSearchDetailCheck(orgid, keyword, statime, entime)
  854. if err != nil {
  855. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  856. return
  857. }
  858. this.ServeSuccessJSON(map[string]interface{}{
  859. "checkDetail": checkDetail,
  860. })
  861. }
  862. func (this *CommonApiController) GetNormData() {
  863. orgid := this.GetAdminUserInfo().CurrentOrgId
  864. //获取系统数据
  865. normdata, err := service.GetNormDataByOrgId(orgid)
  866. if len(normdata) == 0 {
  867. normdata, err := service.GetNormData(0)
  868. if err != nil {
  869. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  870. return
  871. }
  872. this.ServeSuccessJSON(map[string]interface{}{
  873. "normdata": normdata,
  874. })
  875. }
  876. if err != nil {
  877. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  878. return
  879. }
  880. this.ServeSuccessJSON(map[string]interface{}{
  881. "normdata": normdata,
  882. })
  883. }
  884. func (this *CommonApiController) GetFirstQuarter() {
  885. orgid := this.GetAdminUserInfo().CurrentOrgId
  886. lapseto, _ := this.GetInt64("lapseto")
  887. fmt.Println("转归", lapseto)
  888. startime := this.GetString("startime")
  889. fmt.Println("startime", startime)
  890. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  891. fmt.Println("parseDateErr", parseDateErr)
  892. statime := startDate.Unix()
  893. fmt.Println("开始时间", statime)
  894. endtime := this.GetString("endtime")
  895. fmt.Println("endtime", endtime)
  896. endTimeYMDHmsStr := endtime + " 23:59:59"
  897. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  898. entime := endDate.Unix()
  899. fmt.Println("结束日期", entime)
  900. //group, parseDateErr := service.GetItemNameGroup(orgid, statime, entime)
  901. //quarter, err := service.GetFirstQuarter(orgid, statime, entime)
  902. //统计数值类型的数据
  903. count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
  904. //统计rang_type== 2
  905. countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto)
  906. if err != nil {
  907. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  908. return
  909. }
  910. this.ServeSuccessJSON(map[string]interface{}{
  911. "count": count,
  912. "countwo": countwo,
  913. })
  914. }
  915. func (this *CommonApiController) GetProjectList() {
  916. startime := this.GetString("startime")
  917. fmt.Println("startime", startime)
  918. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  919. fmt.Println("parseDateErr", parseDateErr)
  920. statime := startDate.Unix()
  921. fmt.Println("开始时间", statime)
  922. endtime := this.GetString("endtime")
  923. fmt.Println("endtime", endtime)
  924. endTimeYMDHmsStr := endtime + " 23:59:59"
  925. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  926. entime := endDate.Unix()
  927. fmt.Println("结束日期", entime)
  928. adminInfo := this.GetAdminUserInfo()
  929. orgid := adminInfo.CurrentOrgId
  930. fmt.Println("orgid", orgid)
  931. lapseto, _ := this.GetInt64("lapseto")
  932. fmt.Println("lapseto", lapseto)
  933. itemtype, _ := this.GetInt64("itemtype")
  934. fmt.Println("type", itemtype)
  935. modetype, _ := this.GetInt64("modetype")
  936. fmt.Println("modetype", modetype)
  937. firstQuarterStart := this.GetString("first_quarter_start")
  938. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  939. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  940. fmt.Println("第一季度开始时间", firstQuarterStartUnix)
  941. fisrtQuarterEnd := this.GetString("first_qurter_end")
  942. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  943. fisrtQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  944. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  945. fmt.Println("第一季度结束时间", fisrtQuarterEndStrUnix)
  946. secondeQuarterStart := this.GetString("second_qurter_start")
  947. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  948. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  949. fmt.Println("第二季度开始时间", secondeQuarterStartUnix)
  950. secondQuarterEnd := this.GetString("second_qurter_end")
  951. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  952. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  953. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  954. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  955. threeQuarterStart := this.GetString("three_qurter_start")
  956. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  957. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  958. fmt.Println("第三季度开始时间", threeQuarterStartUnix)
  959. threeQuarterEnd := this.GetString("three_qurter_end")
  960. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  961. threeQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  962. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  963. fmt.Println("第三季度结束时间", threeQuarterEndStrUnix)
  964. fourQuarterStart := this.GetString("four_qurter_start")
  965. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  966. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  967. fmt.Println("第四季度开始时间", fourQuarterStartUnix)
  968. fourQuarterEnd := this.GetString("four_qurter_end")
  969. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  970. fourQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  971. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  972. //fmt.Println("第四季度结束时间", fourQuarterEndStrUnix)
  973. rangetype, parseDateErr := this.GetInt64("range_type")
  974. //按季度统计
  975. if rangetype == 1 {
  976. //统计总共
  977. list, err := service.GetProjectList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  978. //统计达标个数
  979. standList, err := service.GetProjectStandList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  980. if err != nil {
  981. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  982. return
  983. }
  984. this.ServeSuccessJSON(map[string]interface{}{
  985. "list": list,
  986. "standList": standList,
  987. })
  988. }
  989. if rangetype == 2 {
  990. list, err := service.GetProjectListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  991. //统计达标个数
  992. standList, err := service.GetProjectStandListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  993. if err != nil {
  994. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  995. return
  996. }
  997. this.ServeSuccessJSON(map[string]interface{}{
  998. "list": list,
  999. "standList": standList,
  1000. })
  1001. }
  1002. }
  1003. func (this *CommonApiController) GetMonthProjectList() {
  1004. adminUser := this.GetAdminUserInfo()
  1005. orgid := adminUser.CurrentOrgId
  1006. fmt.Println("orgid", orgid)
  1007. lapseto, _ := this.GetInt64("lapseto")
  1008. fmt.Println("lapseto", lapseto)
  1009. itemtype, _ := this.GetInt64("itemtype")
  1010. fmt.Println("itemtype", itemtype)
  1011. modetype, _ := this.GetInt64("modetype")
  1012. fmt.Println("modetype", modetype)
  1013. januaryStart := this.GetString("januaryStart")
  1014. fmt.Println("一月始", januaryStart)
  1015. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  1016. januaryStartStrUnix := januaryStartStr.Unix()
  1017. fmt.Println("一月使", januaryStartStrUnix)
  1018. januaryEnd := this.GetString("januaryEnd")
  1019. fmt.Println("一月末", januaryEnd)
  1020. januaryEndStr := januaryEnd + " 23:59:59"
  1021. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  1022. januaryEndStrUnix := januaryEndStrs.Unix()
  1023. fmt.Println("一月末", januaryEndStrUnix)
  1024. febStart := this.GetString("febStart")
  1025. fmt.Println("二月始", febStart)
  1026. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  1027. febStartStrStrUnix := febStartStr.Unix()
  1028. fmt.Println("二月使", febStartStrStrUnix)
  1029. febEnd := this.GetString("febEnd")
  1030. fmt.Println("二月末", febEnd)
  1031. febEndStr := febEnd + " 23:59:59"
  1032. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  1033. febEndStrUnix := febEndStrs.Unix()
  1034. fmt.Println("二月末", febEndStrUnix)
  1035. marchStart := this.GetString("marchStart")
  1036. fmt.Println("三月始", marchStart)
  1037. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  1038. marchStartStrUnix := marchStartStr.Unix()
  1039. fmt.Println("三月使", marchStartStrUnix)
  1040. marchEnd := this.GetString("marchEnd")
  1041. fmt.Println("三月末", febEnd)
  1042. marchEndStr := marchEnd + " 23:59:59"
  1043. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  1044. marchEndStrUnix := marchEndStrs.Unix()
  1045. fmt.Println("三月末", marchEndStrUnix)
  1046. aprStart := this.GetString("aprStart")
  1047. fmt.Println("四月始", aprStart)
  1048. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  1049. aprStartStrUnix := aprStartStr.Unix()
  1050. fmt.Println("四月使", aprStartStrUnix)
  1051. aprEnd := this.GetString("aprEnd")
  1052. fmt.Println("四月末", aprEnd)
  1053. aprEndStr := aprEnd + " 23:59:59"
  1054. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  1055. aprEndStrsUnix := aprEndStrs.Unix()
  1056. fmt.Println("四月末", aprEndStrsUnix)
  1057. mayStart := this.GetString("mayStart")
  1058. fmt.Println("五月始", mayStart)
  1059. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1060. mayStartStrUnix := mayStartStr.Unix()
  1061. fmt.Println("五月使", mayStartStrUnix)
  1062. mayEnd := this.GetString("mayEnd")
  1063. fmt.Println("五月末", mayEnd)
  1064. mayEndStr := mayEnd + " 23:59:59"
  1065. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1066. mayEndStrsUnix := mayEndStrs.Unix()
  1067. fmt.Println("五月末", mayEndStrsUnix)
  1068. junStart := this.GetString("junStart")
  1069. fmt.Println("六月始", mayStart)
  1070. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1071. junStartStrUnix := junStartStr.Unix()
  1072. fmt.Println("六月使", junStartStrUnix)
  1073. junEnd := this.GetString("junEnd")
  1074. fmt.Println("六月末", junEnd)
  1075. junEndStr := junEnd + " 23:59:59"
  1076. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1077. junEndStrsUnix := junEndStrs.Unix()
  1078. fmt.Println("六月末", junEndStrsUnix)
  1079. julStart := this.GetString("julStart")
  1080. fmt.Println("七月始", julStart)
  1081. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1082. julStartStrUnix := julStartStr.Unix()
  1083. fmt.Println("七月使", julStartStrUnix)
  1084. julEnd := this.GetString("julEnd")
  1085. fmt.Println("七月末", julEnd)
  1086. julEndStr := julEnd + " 23:59:59"
  1087. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1088. julEndStrsUnix := julEndStrs.Unix()
  1089. fmt.Println("七月末", julEndStrsUnix)
  1090. augStart := this.GetString("augStart")
  1091. fmt.Println("八月始", augStart)
  1092. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1093. augStartStrUnix := augStartStr.Unix()
  1094. fmt.Println("八月使", augStartStrUnix)
  1095. augEnd := this.GetString("augEnd")
  1096. fmt.Println("八月末", augEnd)
  1097. augEndStr := augEnd + " 23:59:59"
  1098. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1099. augEndStrsUnix := augEndStrs.Unix()
  1100. fmt.Println("八月末", augEndStrsUnix)
  1101. sepStart := this.GetString("sepStart")
  1102. fmt.Println("九月始", sepStart)
  1103. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1104. sepStartStrUnix := sepStartStr.Unix()
  1105. fmt.Println("九月使", sepStartStrUnix)
  1106. sepEnd := this.GetString("sepEnd")
  1107. fmt.Println("九月末", sepEnd)
  1108. sepEndStr := sepEnd + " 23:59:59"
  1109. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1110. sepEndStrsUnix := sepEndStrs.Unix()
  1111. fmt.Println("九月末", sepEndStrsUnix)
  1112. octStart := this.GetString("octStart")
  1113. fmt.Println("10月始", octStart)
  1114. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1115. octStartStrUnix := octStartStr.Unix()
  1116. fmt.Println("10月使", octStartStrUnix)
  1117. octEnd := this.GetString("octEnd")
  1118. fmt.Println("10月末", octEnd)
  1119. octEndStr := octEnd + " 23:59:59"
  1120. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1121. octEndStrsUnix := octEndStrs.Unix()
  1122. fmt.Println("10月末", octEndStrsUnix)
  1123. novStart := this.GetString("novStart")
  1124. fmt.Println("11月始", novStart)
  1125. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1126. novStartStrUnix := novStartStr.Unix()
  1127. fmt.Println("11月使", novStartStrUnix)
  1128. novEnd := this.GetString("novEnd")
  1129. fmt.Println("11月末", novEnd)
  1130. novEndStr := novEnd + " 23:59:59"
  1131. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1132. novEndStrsUnix := novEndStrs.Unix()
  1133. fmt.Println("10月末", novEndStrsUnix)
  1134. decStart := this.GetString("decStart")
  1135. fmt.Println("12月始", novStart)
  1136. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1137. decStartStrUnix := decStartStr.Unix()
  1138. fmt.Println("12月使", decStartStrUnix)
  1139. decEnd := this.GetString("decEnd")
  1140. fmt.Println("12月末", novEnd)
  1141. decEndStr := decEnd + " 23:59:59"
  1142. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1143. decEndStrsUnix := decEndStrs.Unix()
  1144. fmt.Println("12月末", decEndStrsUnix)
  1145. rangetype, _ := this.GetInt64("range_type")
  1146. fmt.Println("range_type", rangetype)
  1147. if rangetype == 1 {
  1148. //统计总共
  1149. monthlist, err := service.GetMonthProjectList(orgid, lapseto, modetype, januaryStartStrUnix, januaryEndStrUnix, febStartStrStrUnix, febEndStrUnix, marchStartStrUnix, marchEndStrUnix, aprStartStrUnix, aprEndStrsUnix, mayStartStrUnix, mayEndStrsUnix, junStartStrUnix, junEndStrsUnix, julStartStrUnix, julEndStrsUnix, augStartStrUnix, augEndStrsUnix, sepStartStrUnix, sepEndStrsUnix, octStartStrUnix, octEndStrsUnix, novStartStrUnix, novEndStrsUnix, decStartStrUnix, decEndStrsUnix)
  1150. //统计不合格
  1151. monthNolist, err := service.GetMonthProjectListTwo(orgid, lapseto, modetype, januaryStartStrUnix, januaryEndStrUnix, febStartStrStrUnix, febEndStrUnix, marchStartStrUnix, marchEndStrUnix, aprStartStrUnix, aprEndStrsUnix, mayStartStrUnix, mayEndStrsUnix, junStartStrUnix, junEndStrsUnix, julStartStrUnix, julEndStrsUnix, augStartStrUnix, augEndStrsUnix, sepStartStrUnix, sepEndStrsUnix, octStartStrUnix, octEndStrsUnix, novStartStrUnix, novEndStrsUnix, decStartStrUnix, decEndStrsUnix)
  1152. fmt.Println("monthnolist", monthNolist)
  1153. if err != nil {
  1154. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1155. return
  1156. }
  1157. this.ServeSuccessJSON(map[string]interface{}{
  1158. "monthlist": monthlist,
  1159. "monthNolist": monthNolist,
  1160. })
  1161. }
  1162. if rangetype == 2 {
  1163. monthlist, err := service.GetMonthProjectListOne(orgid, lapseto, modetype, januaryStartStrUnix, januaryEndStrUnix, febStartStrStrUnix, febEndStrUnix, marchStartStrUnix, marchEndStrUnix, aprStartStrUnix, aprEndStrsUnix, mayStartStrUnix, mayEndStrsUnix, junStartStrUnix, junEndStrsUnix, julStartStrUnix, julEndStrsUnix, augStartStrUnix, augEndStrsUnix, sepStartStrUnix, sepEndStrsUnix, octStartStrUnix, octEndStrsUnix, novStartStrUnix, novEndStrsUnix, decStartStrUnix, decEndStrsUnix)
  1164. monthNolist, err := service.GetMonthProjectListThree(orgid, lapseto, modetype, januaryStartStrUnix, januaryEndStrUnix, febStartStrStrUnix, febEndStrUnix, marchStartStrUnix, marchEndStrUnix, aprStartStrUnix, aprEndStrsUnix, mayStartStrUnix, mayEndStrsUnix, junStartStrUnix, junEndStrsUnix, julStartStrUnix, julEndStrsUnix, augStartStrUnix, augEndStrsUnix, sepStartStrUnix, sepEndStrsUnix, octStartStrUnix, octEndStrsUnix, novStartStrUnix, novEndStrsUnix, decStartStrUnix, decEndStrsUnix)
  1165. if err != nil {
  1166. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1167. return
  1168. }
  1169. this.ServeSuccessJSON(map[string]interface{}{
  1170. "monthlist": monthlist,
  1171. "monthNolist": monthNolist,
  1172. })
  1173. }
  1174. }
  1175. func (this *CommonApiController) GetPatientscontrol() {
  1176. adminUser := this.GetAdminUserInfo()
  1177. orgid := adminUser.CurrentOrgId
  1178. fmt.Println("org", orgid)
  1179. lapstor, _ := this.GetInt64("lapstor")
  1180. fmt.Println("lapstor", lapstor)
  1181. startime := this.GetString("startime")
  1182. fmt.Println("开始时间", startime)
  1183. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1184. startimeStrUnix := startimeStr.Unix()
  1185. fmt.Println("时间搓", startimeStrUnix)
  1186. endtime := this.GetString("endtime")
  1187. fmt.Println("结束时间", endtime)
  1188. endtimeStr := endtime + " 23:59:59"
  1189. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1190. endtimeStrsUnix := endtimeStrs.Unix()
  1191. fmt.Println("结束时间搓", endtimeStrsUnix)
  1192. page, _ := this.GetInt64("page")
  1193. fmt.Println("page", page)
  1194. limit, _ := this.GetInt64("limit")
  1195. fmt.Println("limit", limit)
  1196. patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1197. fmt.Println("============================================================")
  1198. control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1199. //获取最后一次数据
  1200. if err != nil {
  1201. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1202. return
  1203. }
  1204. this.ServeSuccessJSON(map[string]interface{}{
  1205. "patients": patients,
  1206. "total": total,
  1207. "control": control,
  1208. })
  1209. }
  1210. func (this *CommonApiController) GetCartogramList() {
  1211. adminUser := this.GetAdminUserInfo()
  1212. orgid := adminUser.CurrentOrgId
  1213. fmt.Println("orgid", orgid)
  1214. lapstor, _ := this.GetInt64("lapstor")
  1215. fmt.Println("lapstor", lapstor)
  1216. startime := this.GetString("startime")
  1217. fmt.Println("开始时间", startime)
  1218. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1219. startimeStrUnix := startimeStr.Unix()
  1220. fmt.Println("时间搓", startimeStrUnix)
  1221. endtime := this.GetString("endtime")
  1222. fmt.Println("结束时间", endtime)
  1223. endtimeStr := endtime + " 23:59:59"
  1224. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1225. endtimeStrsUnix := endtimeStrs.Unix()
  1226. fmt.Println("结束时间搓", endtimeStrsUnix)
  1227. limit, _ := this.GetInt64("limit")
  1228. page, _ := this.GetInt64("page")
  1229. cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1230. _, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1231. if err != nil {
  1232. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1233. return
  1234. }
  1235. this.ServeSuccessJSON(map[string]interface{}{
  1236. "cartogramlist": cartogramlist,
  1237. "total": total,
  1238. })
  1239. }
  1240. func (this *CommonApiController) GetPatientContor() {
  1241. adminUser := this.GetAdminUserInfo()
  1242. orgid := adminUser.CurrentOrgId
  1243. fmt.Println(orgid)
  1244. lapstor, _ := this.GetInt64("lapstor")
  1245. fmt.Println("lapstor", lapstor)
  1246. patientid, _ := this.GetInt64("patientid")
  1247. startime := this.GetString("startime")
  1248. fmt.Println("开始时间", startime)
  1249. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1250. startimeStrUnix := startimeStr.Unix()
  1251. fmt.Println("时间搓", startimeStrUnix)
  1252. endtime := this.GetString("endtime")
  1253. fmt.Println("结束时间", endtime)
  1254. endtimeStr := endtime + " 23:59:59"
  1255. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1256. endtimeStrsUnix := endtimeStrs.Unix()
  1257. fmt.Println("结束时间搓", endtimeStrsUnix)
  1258. patients, err := service.GetPatientNames(orgid, patientid)
  1259. patientcontorDetail, err := service.GetLastPatientsControlTwo(orgid, patientid, startimeStrUnix, endtimeStrsUnix)
  1260. if err != nil {
  1261. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1262. return
  1263. }
  1264. this.ServeSuccessJSON(map[string]interface{}{
  1265. "patientcontorDetail": patientcontorDetail,
  1266. "name": patients.Name,
  1267. })
  1268. }
  1269. func (this *CommonApiController) GetQualityControl() {
  1270. adminUser := this.GetAdminUserInfo()
  1271. orgid := adminUser.CurrentOrgId
  1272. fmt.Println(orgid)
  1273. patientid, _ := this.GetInt64("patientid")
  1274. startime, _ := this.GetInt64("startime")
  1275. fmt.Println("startime", startime)
  1276. endtime, _ := this.GetInt64("endtime")
  1277. fmt.Println("endtime", endtime)
  1278. itemid, _ := this.GetInt64("itemid")
  1279. fmt.Println("itemid", itemid)
  1280. inspectdate, _ := this.GetInt64("inspectdate")
  1281. list, err := service.GetQualityControlById(orgid, patientid, startime, endtime, itemid, inspectdate)
  1282. if err != nil {
  1283. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1284. return
  1285. }
  1286. this.ServeSuccessJSON(map[string]interface{}{
  1287. "list": list,
  1288. })
  1289. }
  1290. func (this *CommonApiController) GetTreatlist() {
  1291. adminuser := this.GetAdminUserInfo()
  1292. orgId := adminuser.CurrentOrgId
  1293. startime := this.GetString("start_time")
  1294. fmt.Println(startime)
  1295. endtime := this.GetString("end_time")
  1296. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1297. fmt.Println("parseDateErr", parseDateErr)
  1298. statime := startDate.Unix()
  1299. fmt.Println("开始时间", statime)
  1300. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  1301. entime := endDate.Unix()
  1302. fmt.Println("结束日期", entime)
  1303. value, _ := this.GetInt64("value")
  1304. fmt.Println("value", value)
  1305. list, err := service.GetTreatList(orgId, statime, entime, value)
  1306. if err != nil {
  1307. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1308. return
  1309. }
  1310. this.ServeSuccessJSON(map[string]interface{}{
  1311. "list": list,
  1312. })
  1313. }
  1314. func (this *CommonApiController) GetPatientComplianceDetail() {
  1315. adminUser := this.GetAdminUserInfo()
  1316. orgid := adminUser.CurrentOrgId
  1317. fmt.Println(orgid)
  1318. patientid, _ := this.GetInt64("patientid")
  1319. startime, _ := this.GetInt64("startime")
  1320. fmt.Println("startime", startime)
  1321. endtime, _ := this.GetInt64("endtime")
  1322. fmt.Println("endtime", endtime)
  1323. itemid, _ := this.GetInt64("itemid")
  1324. fmt.Println("itemid", itemid)
  1325. list, err := service.GetPatientComplianceDetail(orgid, patientid, startime, endtime, itemid)
  1326. if err != nil {
  1327. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1328. return
  1329. }
  1330. this.ServeSuccessJSON(map[string]interface{}{
  1331. "list": list,
  1332. })
  1333. }