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==========", endunix)
  402. //统计该机构的转出人数
  403. patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix)
  404. //统计该机构转出病人
  405. patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix)
  406. count := service.GetPatientTotalCount(orgid)
  407. if err != nil {
  408. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  409. return
  410. }
  411. this.ServeSuccessJSON(map[string]interface{}{
  412. "patients": patients,
  413. "count": count,
  414. "patienttwo": patienttwo,
  415. })
  416. }
  417. func (this *CommonApiController) GetTotalSexCount() {
  418. adminUser := this.GetAdminUserInfo()
  419. orgid := adminUser.CurrentOrgId
  420. fmt.Println("orgid", orgid)
  421. startime, _ := this.GetInt64("startime")
  422. fmt.Println("开始时间", startime)
  423. endtime, _ := this.GetInt64("endtime")
  424. fmt.Println("结束时间", endtime)
  425. total := service.GetPatientTotalCount(orgid)
  426. _, totalSex, err := service.GetManPatientTotal(orgid)
  427. if err != nil {
  428. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  429. return
  430. }
  431. this.ServeSuccessJSON(map[string]interface{}{
  432. "total": total,
  433. "totalSex": totalSex,
  434. })
  435. }
  436. func (this *CommonApiController) GetTotalInfectiouscount() {
  437. adminUser := this.GetAdminUserInfo()
  438. orgid := adminUser.CurrentOrgId
  439. fmt.Println("orgid", orgid)
  440. timeLayout := "2006-01-02"
  441. loc, _ := time.LoadLocation("Local")
  442. startime := this.GetString("startime")
  443. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  444. startnunix := startTimes.Unix()
  445. endtime := this.GetString("endtime")
  446. endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
  447. endunix := endtimes.Unix()
  448. //统计透析总人数
  449. total := service.GetPatientTotalCount(orgid)
  450. //统计透析人数传染病所占比例
  451. count, err := service.GetPatientInfectiousCount(orgid, startnunix, endunix)
  452. //统计其他
  453. _, otherTotal, err := service.GetPatientOtherInfectious(orgid)
  454. if err != nil {
  455. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  456. return
  457. }
  458. this.ServeSuccessJSON(map[string]interface{}{
  459. "total": total,
  460. "count": count,
  461. "otherTotal": otherTotal,
  462. })
  463. }
  464. func (this *CommonApiController) GetTotalAgeCount() {
  465. adminUser := this.GetAdminUserInfo()
  466. orgid := adminUser.CurrentOrgId
  467. fmt.Println("orgid", orgid)
  468. startime, _ := this.GetInt64("startime")
  469. fmt.Println("开始时间", startime)
  470. endtime, _ := this.GetInt64("endtime")
  471. fmt.Println("结束时间", endtime)
  472. //统计透析总人数
  473. total := service.GetPatientTotalCount(orgid)
  474. agecount, err := service.GetTotalAgeCount(orgid)
  475. //two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
  476. if err != nil {
  477. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  478. return
  479. }
  480. this.ServeSuccessJSON(map[string]interface{}{
  481. "total": total,
  482. "ageCount": agecount,
  483. })
  484. }
  485. func (this *CommonApiController) GetTotalDialysisCount() {
  486. adminUser := this.GetAdminUserInfo()
  487. orgid := adminUser.CurrentOrgId
  488. fmt.Println("org", orgid)
  489. startime, _ := this.GetInt64("startime")
  490. fmt.Println(startime)
  491. endtime, _ := this.GetInt64("endtime")
  492. fmt.Println(endtime)
  493. recordDateStr := time.Now().Format("2006-01-02")
  494. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  495. fmt.Println("parseDateErr", parseDateErr)
  496. nowtime := recordDate.Unix()
  497. //统计透析总人数
  498. total := service.GetPatientTotalCount(orgid)
  499. fmt.Println("total", total)
  500. //获取该机构下的所有病人数据
  501. patients, err := service.GetTotalDialysisAgeCount(orgid)
  502. fmt.Println("patients", patients)
  503. //统计透年龄
  504. dataage, _ := service.GetDialysisAgeData(orgid)
  505. if err != nil {
  506. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  507. return
  508. }
  509. this.ServeSuccessJSON(map[string]interface{}{
  510. "total": total,
  511. "patients": patients,
  512. "nowtime": nowtime,
  513. "dataage": dataage,
  514. })
  515. }
  516. func (this *CommonApiController) GetCurentOrgPatients() {
  517. adminUser := this.GetAdminUserInfo()
  518. orgid := adminUser.CurrentOrgId
  519. patients, err := service.GetCurentOrgPatients(orgid)
  520. if err != nil {
  521. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  522. return
  523. }
  524. this.ServeSuccessJSON(map[string]interface{}{
  525. "patients": patients,
  526. })
  527. }
  528. func (this *CommonApiController) GetDialysislist() {
  529. startime := this.GetString("startime")
  530. fmt.Println("startime", startime)
  531. endtime := this.GetString("endtime")
  532. fmt.Println("enditme", endtime)
  533. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  534. fmt.Println("parseDateErr", parseDateErr)
  535. statime := startDate.Unix()
  536. fmt.Println("开始时间", statime)
  537. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  538. entime := endDate.Unix()
  539. fmt.Println("开始时间", statime)
  540. page, _ := this.GetInt64("page")
  541. fmt.Println("page", page)
  542. limit, _ := this.GetInt64("limit")
  543. fmt.Println("limit", limit)
  544. adminUser := this.GetAdminUserInfo()
  545. orgId := adminUser.CurrentOrgId
  546. count, _ := service.TotalDialysisCount(statime, entime, orgId)
  547. dialysislist, total, err := service.GetDialysisList(statime, entime, page, limit, orgId)
  548. prescriptionList, _ := service.GetAllDialysisList(statime, entime, orgId)
  549. list, totallist, _ := service.GetDialysisPatientList(statime, entime, page, limit, orgId)
  550. fmt.Println("err", err)
  551. if err != nil {
  552. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  553. return
  554. }
  555. this.ServeSuccessJSON(map[string]interface{}{
  556. "dialysislist": dialysislist,
  557. "total": total,
  558. "list": list,
  559. "totallist": totallist,
  560. "prescriptionList": prescriptionList,
  561. "count": count,
  562. })
  563. }
  564. func (this *CommonApiController) GetLastSort() {
  565. adminUser := this.GetAdminUserInfo()
  566. orgid := adminUser.CurrentOrgId
  567. standard, err := service.GetLastSort(orgid)
  568. if err != nil {
  569. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  570. return
  571. }
  572. this.ServeSuccessJSON(map[string]interface{}{
  573. "standard": standard,
  574. })
  575. }
  576. func (this *CommonApiController) GetLastCheckList() {
  577. adminUser := this.GetAdminUserInfo()
  578. orgid := adminUser.CurrentOrgId
  579. checkList, err := service.GetLastCheckList(orgid)
  580. if err != nil {
  581. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  582. return
  583. }
  584. this.ServeSuccessJSON(map[string]interface{}{
  585. "checkList": checkList,
  586. })
  587. }
  588. func (this *CommonApiController) GetDialysisDetailById() {
  589. adminUser := this.GetAdminUserInfo()
  590. orgId := adminUser.CurrentOrgId
  591. id, _ := this.GetInt64("id")
  592. fmt.Println("id", id)
  593. startime := this.GetString("startime")
  594. fmt.Println(startime)
  595. endtime := this.GetString("endtime")
  596. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  597. fmt.Println("parseDateErr", parseDateErr)
  598. statime := startDate.Unix()
  599. fmt.Println("开始时间", statime)
  600. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  601. entime := endDate.Unix()
  602. fmt.Println("开始时间", statime)
  603. fmt.Println(endtime)
  604. limit, _ := this.GetInt64("limit")
  605. fmt.Println("limit", limit)
  606. page, _ := this.GetInt64("page")
  607. fmt.Println("page", page)
  608. patients, total, err := service.GetDialysisDetailById(id, orgId, statime, entime, limit, page)
  609. if err != nil {
  610. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  611. return
  612. }
  613. this.ServeSuccessJSON(map[string]interface{}{
  614. "patients": patients,
  615. "total": total,
  616. })
  617. }
  618. func (this *CommonApiController) GetPrescritionByName() {
  619. adminUser := this.GetAdminUserInfo()
  620. orgId := adminUser.CurrentOrgId
  621. //keyword := this.GetString("keyword")
  622. patientid, _ := this.GetInt64("patientid")
  623. startime := this.GetString("startime")
  624. fmt.Println(startime)
  625. endtime := this.GetString("endtime")
  626. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  627. fmt.Println("parseDateErr", parseDateErr)
  628. statime := startDate.Unix()
  629. fmt.Println("开始时间", statime)
  630. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  631. entime := endDate.Unix()
  632. //fmt.Println("开始时间", statime)
  633. //fmt.Println(endtime)
  634. limit, _ := this.GetInt64("limit")
  635. //fmt.Println("limit", limit)
  636. page, _ := this.GetInt64("page")
  637. //fmt.Println("page", page)
  638. patient, total, err := service.GetPrescritionByName(orgId, patientid, statime, entime, limit, page)
  639. if err != nil {
  640. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  641. return
  642. }
  643. this.ServeSuccessJSON(map[string]interface{}{
  644. "patient": patient,
  645. "total": total,
  646. })
  647. }
  648. func (this *CommonApiController) GetStatistics() {
  649. adminUser := this.GetAdminUserInfo()
  650. orgId := adminUser.CurrentOrgId
  651. //fmt.Println("orgid", orgId)
  652. startime := this.GetString("start_time")
  653. //fmt.Println(startime)
  654. endtime := this.GetString("end_time")
  655. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  656. fmt.Println("parseDateErr", parseDateErr)
  657. statime := startDate.Unix()
  658. //fmt.Println("开始时间", statime)
  659. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  660. entime := endDate.Unix()
  661. //fmt.Println("结束日期", entime)
  662. value, _ := this.GetInt64("value")
  663. //fmt.Println("value", value)
  664. limit, _ := this.GetInt64("limit")
  665. //fmt.Println("limit", limit)
  666. page, _ := this.GetInt64("page")
  667. //fmt.Println("page", page)
  668. modeId, _ := this.GetInt64("mode_id")
  669. treatinfo, total, err := service.GetTreateInfo(orgId, statime, entime, value, limit, page)
  670. statistics, ttd, _ := service.GetStatistics(orgId, statime, entime, modeId)
  671. if err != nil {
  672. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  673. return
  674. }
  675. this.ServeSuccessJSON(map[string]interface{}{
  676. "statistics": statistics,
  677. "ttd": ttd,
  678. "total": total,
  679. "treatinfo": treatinfo,
  680. })
  681. }
  682. func (this *CommonApiController) GetInspectionTatolCount() {
  683. adminUser := this.GetAdminUserInfo()
  684. orgid := adminUser.CurrentOrgId
  685. startime := this.GetString("startime")
  686. fmt.Println(startime)
  687. endtime := this.GetString("endtime")
  688. fmt.Print("endtime", endtime)
  689. patientid, _ := this.GetInt64("patientid")
  690. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  691. fmt.Println("parseDateErr", parseDateErr)
  692. statime := startDate.Unix()
  693. secondQuarterEndStr := endtime + " 23:59:59"
  694. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  695. entime := secondQuarterEnds.Unix()
  696. references, err := service.GetInspectionTotalCount(orgid)
  697. if err != nil {
  698. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  699. return
  700. }
  701. counts, err := service.GetInspectionProjectCount(orgid, statime, entime, patientid)
  702. this.ServeSuccessJSON(map[string]interface{}{
  703. "Inspection": references,
  704. "counts": counts,
  705. })
  706. }
  707. func (this *CommonApiController) GetInspectionDetailById() {
  708. adminUser := this.GetAdminUserInfo()
  709. orgId := adminUser.CurrentOrgId
  710. id, _ := this.GetInt64("id")
  711. fmt.Println("id", id)
  712. startime := this.GetString("startime")
  713. endtime := this.GetString("endtime")
  714. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  715. fmt.Println("parseDateErr", parseDateErr)
  716. statime := startDate.Unix()
  717. fmt.Println("开始时间", statime)
  718. secondQuarterEndStr := endtime + " 23:59:59"
  719. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  720. entime := secondQuarterEnds.Unix()
  721. patientdetail, err := service.GetInspectionDetailById(id, orgId, statime, entime)
  722. if err != nil {
  723. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  724. return
  725. }
  726. this.ServeSuccessJSON(map[string]interface{}{
  727. "patientdetail": patientdetail,
  728. })
  729. }
  730. func (this *CommonApiController) GetSearchPatientInfo() {
  731. adminUser := this.GetAdminUserInfo()
  732. orgId := adminUser.CurrentOrgId
  733. //keyword := this.GetString("keyword")
  734. //fmt.Println("keyword", keyword)
  735. patientid, _ := this.GetInt64("patientid")
  736. startime := this.GetString("startime")
  737. endtime := this.GetString("endtime")
  738. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  739. fmt.Println("parseDateErr", parseDateErr)
  740. statime := startDate.Unix()
  741. fmt.Println("开始时间", statime)
  742. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  743. //entime := endDate.Unix()
  744. //fmt.Println("结束日期", entime)
  745. secondQuarterEndStr := endtime + " 23:59:59"
  746. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  747. entime := secondQuarterEnds.Unix()
  748. PatientsInfo, err := service.GetSearchPatientInfo(orgId, patientid, statime, entime)
  749. if err != nil {
  750. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  751. return
  752. }
  753. this.ServeSuccessJSON(map[string]interface{}{
  754. "PatientsInfo": PatientsInfo,
  755. })
  756. }
  757. func (this *CommonApiController) GetAllMajorInspection() {
  758. adminUser := this.GetAdminUserInfo()
  759. orgid := adminUser.CurrentOrgId
  760. inspection, err := service.GetMajorInspectionByOrgid(orgid)
  761. if len(inspection) == 0 {
  762. inspect, err := service.GetDefaultByOrgId(0)
  763. if err != nil {
  764. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  765. return
  766. }
  767. this.ServeSuccessJSON(map[string]interface{}{
  768. "inspection": inspect,
  769. })
  770. } else {
  771. if err != nil {
  772. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  773. return
  774. }
  775. this.ServeSuccessJSON(map[string]interface{}{
  776. "inspection": inspection,
  777. })
  778. }
  779. }
  780. func (this *CommonApiController) GetPatientList() {
  781. adminUser := this.GetAdminUserInfo()
  782. orgid := adminUser.CurrentOrgId
  783. startime := this.GetString("startime")
  784. endtime := this.GetString("endtime")
  785. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  786. fmt.Println("parseDateErr", parseDateErr)
  787. statime := startDate.Unix()
  788. fmt.Println("开始时间", statime)
  789. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  790. // //entime := endDate.Unix()
  791. endTimeYMDHmsStr := endtime + " 23:59:59"
  792. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  793. entime := endDate.Unix()
  794. fmt.Println("结束日期", entime)
  795. limit, _ := this.GetInt64("limit")
  796. fmt.Println("limit", limit)
  797. page, _ := this.GetInt64("page")
  798. fmt.Println("page", page)
  799. patientInfo, total, err := service.GetPatientListData(orgid, statime, entime, limit, page)
  800. info, _ := service.GetPatientListInfo(orgid, statime, entime, limit, page)
  801. if err != nil {
  802. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  803. return
  804. }
  805. this.ServeSuccessJSON(map[string]interface{}{
  806. "patientInfo": patientInfo,
  807. "total": total,
  808. "list": info,
  809. })
  810. }
  811. func (this *CommonApiController) GetPatientDetailCheck() {
  812. adminUser := this.GetAdminUserInfo()
  813. orgid := adminUser.CurrentOrgId
  814. id, _ := this.GetInt64("id")
  815. startime := this.GetString("startime")
  816. endtime := this.GetString("endtime")
  817. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  818. fmt.Println("parseDateErr", parseDateErr)
  819. statime := startDate.Unix()
  820. fmt.Println("开始时间", statime)
  821. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  822. //entime := endDate.Unix()
  823. //fmt.Println("结束日期", entime)
  824. endTimeYMDHmsStr := endtime + " 23:59:59"
  825. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  826. entime := endDate.Unix()
  827. checkDetail, err := service.GetPatientDetailCheck(id, orgid, statime, entime)
  828. if err != nil {
  829. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  830. return
  831. }
  832. this.ServeSuccessJSON(map[string]interface{}{
  833. "checkDetail": checkDetail,
  834. })
  835. }
  836. func (this *CommonApiController) GetSearchDetailCheck() {
  837. adminUser := this.GetAdminUserInfo()
  838. orgid := adminUser.CurrentOrgId
  839. keyword := this.GetString("keyword")
  840. startime := this.GetString("startime")
  841. endtime := this.GetString("endtime")
  842. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  843. fmt.Println("parseDateErr", parseDateErr)
  844. statime := startDate.Unix()
  845. fmt.Println("开始时间", statime)
  846. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  847. entime := endDate.Unix()
  848. fmt.Println("结束日期", entime)
  849. checkDetail, err := service.GetSearchDetailCheck(orgid, keyword, statime, entime)
  850. if err != nil {
  851. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  852. return
  853. }
  854. this.ServeSuccessJSON(map[string]interface{}{
  855. "checkDetail": checkDetail,
  856. })
  857. }
  858. func (this *CommonApiController) GetNormData() {
  859. orgid := this.GetAdminUserInfo().CurrentOrgId
  860. //获取系统数据
  861. normdata, err := service.GetNormDataByOrgId(orgid)
  862. if len(normdata) == 0 {
  863. normdata, err := service.GetNormData(0)
  864. if err != nil {
  865. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  866. return
  867. }
  868. this.ServeSuccessJSON(map[string]interface{}{
  869. "normdata": normdata,
  870. })
  871. }
  872. if err != nil {
  873. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  874. return
  875. }
  876. this.ServeSuccessJSON(map[string]interface{}{
  877. "normdata": normdata,
  878. })
  879. }
  880. func (this *CommonApiController) GetFirstQuarter() {
  881. orgid := this.GetAdminUserInfo().CurrentOrgId
  882. lapseto, _ := this.GetInt64("lapseto")
  883. fmt.Println("转归", lapseto)
  884. startime := this.GetString("startime")
  885. fmt.Println("startime", startime)
  886. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  887. fmt.Println("parseDateErr", parseDateErr)
  888. statime := startDate.Unix()
  889. fmt.Println("开始时间", statime)
  890. endtime := this.GetString("endtime")
  891. fmt.Println("endtime", endtime)
  892. endTimeYMDHmsStr := endtime + " 23:59:59"
  893. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  894. entime := endDate.Unix()
  895. fmt.Println("结束日期", entime)
  896. //group, parseDateErr := service.GetItemNameGroup(orgid, statime, entime)
  897. //quarter, err := service.GetFirstQuarter(orgid, statime, entime)
  898. //统计数值类型的数据
  899. count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
  900. //统计rang_type== 2
  901. countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto)
  902. if err != nil {
  903. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  904. return
  905. }
  906. this.ServeSuccessJSON(map[string]interface{}{
  907. "count": count,
  908. "countwo": countwo,
  909. })
  910. }
  911. func (this *CommonApiController) GetProjectList() {
  912. startime := this.GetString("startime")
  913. fmt.Println("startime", startime)
  914. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  915. fmt.Println("parseDateErr", parseDateErr)
  916. statime := startDate.Unix()
  917. fmt.Println("开始时间", statime)
  918. endtime := this.GetString("endtime")
  919. fmt.Println("endtime", endtime)
  920. endTimeYMDHmsStr := endtime + " 23:59:59"
  921. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  922. entime := endDate.Unix()
  923. fmt.Println("结束日期", entime)
  924. adminInfo := this.GetAdminUserInfo()
  925. orgid := adminInfo.CurrentOrgId
  926. fmt.Println("orgid", orgid)
  927. lapseto, _ := this.GetInt64("lapseto")
  928. fmt.Println("lapseto", lapseto)
  929. itemtype, _ := this.GetInt64("itemtype")
  930. fmt.Println("type", itemtype)
  931. modetype, _ := this.GetInt64("modetype")
  932. fmt.Println("modetype", modetype)
  933. firstQuarterStart := this.GetString("first_quarter_start")
  934. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  935. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  936. fmt.Println("第一季度开始时间", firstQuarterStartUnix)
  937. fisrtQuarterEnd := this.GetString("first_qurter_end")
  938. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  939. fisrtQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  940. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  941. fmt.Println("第一季度结束时间", fisrtQuarterEndStrUnix)
  942. secondeQuarterStart := this.GetString("second_qurter_start")
  943. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  944. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  945. fmt.Println("第二季度开始时间", secondeQuarterStartUnix)
  946. secondQuarterEnd := this.GetString("second_qurter_end")
  947. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  948. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  949. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  950. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  951. threeQuarterStart := this.GetString("three_qurter_start")
  952. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  953. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  954. fmt.Println("第三季度开始时间", threeQuarterStartUnix)
  955. threeQuarterEnd := this.GetString("three_qurter_end")
  956. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  957. threeQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  958. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  959. fmt.Println("第三季度结束时间", threeQuarterEndStrUnix)
  960. fourQuarterStart := this.GetString("four_qurter_start")
  961. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  962. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  963. fmt.Println("第四季度开始时间", fourQuarterStartUnix)
  964. fourQuarterEnd := this.GetString("four_qurter_end")
  965. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  966. fourQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  967. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  968. //fmt.Println("第四季度结束时间", fourQuarterEndStrUnix)
  969. rangetype, parseDateErr := this.GetInt64("range_type")
  970. //按季度统计
  971. if rangetype == 1 {
  972. //统计总共
  973. list, err := service.GetProjectList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  974. //统计达标个数
  975. standList, err := service.GetProjectStandList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  976. if err != nil {
  977. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  978. return
  979. }
  980. this.ServeSuccessJSON(map[string]interface{}{
  981. "list": list,
  982. "standList": standList,
  983. })
  984. }
  985. if rangetype == 2 {
  986. list, err := service.GetProjectListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  987. //统计达标个数
  988. standList, err := service.GetProjectStandListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  989. if err != nil {
  990. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  991. return
  992. }
  993. this.ServeSuccessJSON(map[string]interface{}{
  994. "list": list,
  995. "standList": standList,
  996. })
  997. }
  998. }
  999. func (this *CommonApiController) GetMonthProjectList() {
  1000. adminUser := this.GetAdminUserInfo()
  1001. orgid := adminUser.CurrentOrgId
  1002. fmt.Println("orgid", orgid)
  1003. lapseto, _ := this.GetInt64("lapseto")
  1004. fmt.Println("lapseto", lapseto)
  1005. itemtype, _ := this.GetInt64("itemtype")
  1006. fmt.Println("itemtype", itemtype)
  1007. modetype, _ := this.GetInt64("modetype")
  1008. fmt.Println("modetype", modetype)
  1009. januaryStart := this.GetString("januaryStart")
  1010. fmt.Println("一月始", januaryStart)
  1011. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  1012. januaryStartStrUnix := januaryStartStr.Unix()
  1013. fmt.Println("一月使", januaryStartStrUnix)
  1014. januaryEnd := this.GetString("januaryEnd")
  1015. fmt.Println("一月末", januaryEnd)
  1016. januaryEndStr := januaryEnd + " 23:59:59"
  1017. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  1018. januaryEndStrUnix := januaryEndStrs.Unix()
  1019. fmt.Println("一月末", januaryEndStrUnix)
  1020. febStart := this.GetString("febStart")
  1021. fmt.Println("二月始", febStart)
  1022. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  1023. febStartStrStrUnix := febStartStr.Unix()
  1024. fmt.Println("二月使", febStartStrStrUnix)
  1025. febEnd := this.GetString("febEnd")
  1026. fmt.Println("二月末", febEnd)
  1027. febEndStr := febEnd + " 23:59:59"
  1028. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  1029. febEndStrUnix := febEndStrs.Unix()
  1030. fmt.Println("二月末", febEndStrUnix)
  1031. marchStart := this.GetString("marchStart")
  1032. fmt.Println("三月始", marchStart)
  1033. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  1034. marchStartStrUnix := marchStartStr.Unix()
  1035. fmt.Println("三月使", marchStartStrUnix)
  1036. marchEnd := this.GetString("marchEnd")
  1037. fmt.Println("三月末", febEnd)
  1038. marchEndStr := marchEnd + " 23:59:59"
  1039. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  1040. marchEndStrUnix := marchEndStrs.Unix()
  1041. fmt.Println("三月末", marchEndStrUnix)
  1042. aprStart := this.GetString("aprStart")
  1043. fmt.Println("四月始", aprStart)
  1044. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  1045. aprStartStrUnix := aprStartStr.Unix()
  1046. fmt.Println("四月使", aprStartStrUnix)
  1047. aprEnd := this.GetString("aprEnd")
  1048. fmt.Println("四月末", aprEnd)
  1049. aprEndStr := aprEnd + " 23:59:59"
  1050. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  1051. aprEndStrsUnix := aprEndStrs.Unix()
  1052. fmt.Println("四月末", aprEndStrsUnix)
  1053. mayStart := this.GetString("mayStart")
  1054. fmt.Println("五月始", mayStart)
  1055. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1056. mayStartStrUnix := mayStartStr.Unix()
  1057. fmt.Println("五月使", mayStartStrUnix)
  1058. mayEnd := this.GetString("mayEnd")
  1059. fmt.Println("五月末", mayEnd)
  1060. mayEndStr := mayEnd + " 23:59:59"
  1061. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1062. mayEndStrsUnix := mayEndStrs.Unix()
  1063. fmt.Println("五月末", mayEndStrsUnix)
  1064. junStart := this.GetString("junStart")
  1065. fmt.Println("六月始", mayStart)
  1066. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1067. junStartStrUnix := junStartStr.Unix()
  1068. fmt.Println("六月使", junStartStrUnix)
  1069. junEnd := this.GetString("junEnd")
  1070. fmt.Println("六月末", junEnd)
  1071. junEndStr := junEnd + " 23:59:59"
  1072. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1073. junEndStrsUnix := junEndStrs.Unix()
  1074. fmt.Println("六月末", junEndStrsUnix)
  1075. julStart := this.GetString("julStart")
  1076. fmt.Println("七月始", julStart)
  1077. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1078. julStartStrUnix := julStartStr.Unix()
  1079. fmt.Println("七月使", julStartStrUnix)
  1080. julEnd := this.GetString("julEnd")
  1081. fmt.Println("七月末", julEnd)
  1082. julEndStr := julEnd + " 23:59:59"
  1083. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1084. julEndStrsUnix := julEndStrs.Unix()
  1085. fmt.Println("七月末", julEndStrsUnix)
  1086. augStart := this.GetString("augStart")
  1087. fmt.Println("八月始", augStart)
  1088. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1089. augStartStrUnix := augStartStr.Unix()
  1090. fmt.Println("八月使", augStartStrUnix)
  1091. augEnd := this.GetString("augEnd")
  1092. fmt.Println("八月末", augEnd)
  1093. augEndStr := augEnd + " 23:59:59"
  1094. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1095. augEndStrsUnix := augEndStrs.Unix()
  1096. fmt.Println("八月末", augEndStrsUnix)
  1097. sepStart := this.GetString("sepStart")
  1098. fmt.Println("九月始", sepStart)
  1099. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1100. sepStartStrUnix := sepStartStr.Unix()
  1101. fmt.Println("九月使", sepStartStrUnix)
  1102. sepEnd := this.GetString("sepEnd")
  1103. fmt.Println("九月末", sepEnd)
  1104. sepEndStr := sepEnd + " 23:59:59"
  1105. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1106. sepEndStrsUnix := sepEndStrs.Unix()
  1107. fmt.Println("九月末", sepEndStrsUnix)
  1108. octStart := this.GetString("octStart")
  1109. fmt.Println("10月始", octStart)
  1110. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1111. octStartStrUnix := octStartStr.Unix()
  1112. fmt.Println("10月使", octStartStrUnix)
  1113. octEnd := this.GetString("octEnd")
  1114. fmt.Println("10月末", octEnd)
  1115. octEndStr := octEnd + " 23:59:59"
  1116. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1117. octEndStrsUnix := octEndStrs.Unix()
  1118. fmt.Println("10月末", octEndStrsUnix)
  1119. novStart := this.GetString("novStart")
  1120. fmt.Println("11月始", novStart)
  1121. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1122. novStartStrUnix := novStartStr.Unix()
  1123. fmt.Println("11月使", novStartStrUnix)
  1124. novEnd := this.GetString("novEnd")
  1125. fmt.Println("11月末", novEnd)
  1126. novEndStr := novEnd + " 23:59:59"
  1127. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1128. novEndStrsUnix := novEndStrs.Unix()
  1129. fmt.Println("10月末", novEndStrsUnix)
  1130. decStart := this.GetString("decStart")
  1131. fmt.Println("12月始", novStart)
  1132. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1133. decStartStrUnix := decStartStr.Unix()
  1134. fmt.Println("12月使", decStartStrUnix)
  1135. decEnd := this.GetString("decEnd")
  1136. fmt.Println("12月末", novEnd)
  1137. decEndStr := decEnd + " 23:59:59"
  1138. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1139. decEndStrsUnix := decEndStrs.Unix()
  1140. fmt.Println("12月末", decEndStrsUnix)
  1141. rangetype, _ := this.GetInt64("range_type")
  1142. fmt.Println("range_type", rangetype)
  1143. if rangetype == 1 {
  1144. //统计总共
  1145. 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)
  1146. //统计不合格
  1147. 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)
  1148. fmt.Println("monthnolist", monthNolist)
  1149. if err != nil {
  1150. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1151. return
  1152. }
  1153. this.ServeSuccessJSON(map[string]interface{}{
  1154. "monthlist": monthlist,
  1155. "monthNolist": monthNolist,
  1156. })
  1157. }
  1158. if rangetype == 2 {
  1159. 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)
  1160. 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)
  1161. if err != nil {
  1162. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1163. return
  1164. }
  1165. this.ServeSuccessJSON(map[string]interface{}{
  1166. "monthlist": monthlist,
  1167. "monthNolist": monthNolist,
  1168. })
  1169. }
  1170. }
  1171. func (this *CommonApiController) GetPatientscontrol() {
  1172. adminUser := this.GetAdminUserInfo()
  1173. orgid := adminUser.CurrentOrgId
  1174. fmt.Println("org", orgid)
  1175. lapstor, _ := this.GetInt64("lapstor")
  1176. fmt.Println("lapstor", lapstor)
  1177. startime := this.GetString("startime")
  1178. fmt.Println("开始时间", startime)
  1179. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1180. startimeStrUnix := startimeStr.Unix()
  1181. fmt.Println("时间搓", startimeStrUnix)
  1182. endtime := this.GetString("endtime")
  1183. fmt.Println("结束时间", endtime)
  1184. endtimeStr := endtime + " 23:59:59"
  1185. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1186. endtimeStrsUnix := endtimeStrs.Unix()
  1187. fmt.Println("结束时间搓", endtimeStrsUnix)
  1188. page, _ := this.GetInt64("page")
  1189. fmt.Println("page", page)
  1190. limit, _ := this.GetInt64("limit")
  1191. fmt.Println("limit", limit)
  1192. patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1193. //统计非传染病类型
  1194. control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1195. //统计传染病类型
  1196. infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1197. if err != nil {
  1198. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1199. return
  1200. }
  1201. this.ServeSuccessJSON(map[string]interface{}{
  1202. "patients": patients,
  1203. "total": total,
  1204. "control": control,
  1205. "infectiousControl": infectiousControl,
  1206. })
  1207. }
  1208. func (this *CommonApiController) GetCartogramList() {
  1209. adminUser := this.GetAdminUserInfo()
  1210. orgid := adminUser.CurrentOrgId
  1211. fmt.Println("orgid", orgid)
  1212. lapstor, _ := this.GetInt64("lapstor")
  1213. fmt.Println("lapstor", lapstor)
  1214. startime := this.GetString("startime")
  1215. fmt.Println("开始时间", startime)
  1216. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1217. startimeStrUnix := startimeStr.Unix()
  1218. fmt.Println("时间搓", startimeStrUnix)
  1219. endtime := this.GetString("endtime")
  1220. fmt.Println("结束时间", endtime)
  1221. endtimeStr := endtime + " 23:59:59"
  1222. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1223. endtimeStrsUnix := endtimeStrs.Unix()
  1224. fmt.Println("结束时间搓", endtimeStrsUnix)
  1225. limit, _ := this.GetInt64("limit")
  1226. page, _ := this.GetInt64("page")
  1227. cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1228. infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1229. _, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1230. if err != nil {
  1231. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1232. return
  1233. }
  1234. this.ServeSuccessJSON(map[string]interface{}{
  1235. "cartogramlist": cartogramlist,
  1236. "total": total,
  1237. "infectiouscontrol": infectiouscontrol,
  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. }