common_api_controller.go 45KB

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