common_api_controller.go 45KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339
  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. fmt.Println("结束日期", entime)
  667. references, err := service.GetInspectionTotalCount(orgid)
  668. if err != nil {
  669. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  670. return
  671. }
  672. counts, err := service.GetInspectionProjectCount(orgid, statime, entime)
  673. this.ServeSuccessJSON(map[string]interface{}{
  674. "Inspection": references,
  675. "counts": counts,
  676. })
  677. }
  678. func (this *CommonApiController) GetInspectionDetailById() {
  679. adminUser := this.GetAdminUserInfo()
  680. orgId := adminUser.CurrentOrgId
  681. id, _ := this.GetInt64("id")
  682. fmt.Println("id", id)
  683. startime := this.GetString("startime")
  684. endtime := this.GetString("endtime")
  685. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  686. fmt.Println("parseDateErr", parseDateErr)
  687. statime := startDate.Unix()
  688. fmt.Println("开始时间", statime)
  689. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  690. entime := endDate.Unix()
  691. fmt.Println("结束日期", entime)
  692. patientdetail, err := service.GetInspectionDetailById(id, orgId, statime, entime)
  693. if err != nil {
  694. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  695. return
  696. }
  697. this.ServeSuccessJSON(map[string]interface{}{
  698. "patientdetail": patientdetail,
  699. })
  700. }
  701. func (this *CommonApiController) GetSearchPatientInfo() {
  702. adminUser := this.GetAdminUserInfo()
  703. orgId := adminUser.CurrentOrgId
  704. //keyword := this.GetString("keyword")
  705. //fmt.Println("keyword", keyword)
  706. patientid, _ := this.GetInt64("patientid")
  707. startime := this.GetString("startime")
  708. endtime := this.GetString("endtime")
  709. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  710. fmt.Println("parseDateErr", parseDateErr)
  711. statime := startDate.Unix()
  712. fmt.Println("开始时间", statime)
  713. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  714. entime := endDate.Unix()
  715. fmt.Println("结束日期", entime)
  716. PatientsInfo, err := service.GetSearchPatientInfo(orgId, patientid, statime, entime)
  717. if err != nil {
  718. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  719. return
  720. }
  721. this.ServeSuccessJSON(map[string]interface{}{
  722. "PatientsInfo": PatientsInfo,
  723. })
  724. }
  725. func (this *CommonApiController) GetAllMajorInspection() {
  726. adminUser := this.GetAdminUserInfo()
  727. orgid := adminUser.CurrentOrgId
  728. inspection, err := service.GetMajorInspectionByOrgid(orgid)
  729. if len(inspection) == 0 {
  730. inspect, err := service.GetDefaultByOrgId(0)
  731. if err != nil {
  732. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  733. return
  734. }
  735. this.ServeSuccessJSON(map[string]interface{}{
  736. "inspection": inspect,
  737. })
  738. } else {
  739. if err != nil {
  740. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  741. return
  742. }
  743. this.ServeSuccessJSON(map[string]interface{}{
  744. "inspection": inspection,
  745. })
  746. }
  747. }
  748. func (this *CommonApiController) GetPatientList() {
  749. adminUser := this.GetAdminUserInfo()
  750. orgid := adminUser.CurrentOrgId
  751. startime := this.GetString("startime")
  752. endtime := this.GetString("endtime")
  753. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  754. fmt.Println("parseDateErr", parseDateErr)
  755. statime := startDate.Unix()
  756. fmt.Println("开始时间", statime)
  757. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  758. entime := endDate.Unix()
  759. fmt.Println("结束日期", entime)
  760. limit, _ := this.GetInt64("limit")
  761. fmt.Println("limit", limit)
  762. page, _ := this.GetInt64("page")
  763. fmt.Println("page", page)
  764. patientInfo, total, err := service.GetPatientListData(orgid, statime, entime, limit, page)
  765. info, _ := service.GetPatientListInfo(orgid, statime, entime)
  766. if err != nil {
  767. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  768. return
  769. }
  770. this.ServeSuccessJSON(map[string]interface{}{
  771. "patientInfo": patientInfo,
  772. "total": total,
  773. "list": info,
  774. })
  775. }
  776. func (this *CommonApiController) GetPatientDetailCheck() {
  777. adminUser := this.GetAdminUserInfo()
  778. orgid := adminUser.CurrentOrgId
  779. id, _ := this.GetInt64("id")
  780. startime := this.GetString("startime")
  781. endtime := this.GetString("endtime")
  782. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  783. fmt.Println("parseDateErr", parseDateErr)
  784. statime := startDate.Unix()
  785. fmt.Println("开始时间", statime)
  786. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  787. entime := endDate.Unix()
  788. fmt.Println("结束日期", entime)
  789. checkDetail, err := service.GetPatientDetailCheck(id, orgid, statime, entime)
  790. if err != nil {
  791. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  792. return
  793. }
  794. this.ServeSuccessJSON(map[string]interface{}{
  795. "checkDetail": checkDetail,
  796. })
  797. }
  798. func (this *CommonApiController) GetSearchDetailCheck() {
  799. adminUser := this.GetAdminUserInfo()
  800. orgid := adminUser.CurrentOrgId
  801. keyword := this.GetString("keyword")
  802. startime := this.GetString("startime")
  803. endtime := this.GetString("endtime")
  804. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  805. fmt.Println("parseDateErr", parseDateErr)
  806. statime := startDate.Unix()
  807. fmt.Println("开始时间", statime)
  808. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  809. entime := endDate.Unix()
  810. fmt.Println("结束日期", entime)
  811. checkDetail, err := service.GetSearchDetailCheck(orgid, keyword, statime, entime)
  812. if err != nil {
  813. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  814. return
  815. }
  816. this.ServeSuccessJSON(map[string]interface{}{
  817. "checkDetail": checkDetail,
  818. })
  819. }
  820. func (this *CommonApiController) GetNormData() {
  821. orgid := this.GetAdminUserInfo().CurrentOrgId
  822. //获取系统数据
  823. normdata, err := service.GetNormDataByOrgId(orgid)
  824. if len(normdata) == 0 {
  825. normdata, err := service.GetNormData(0)
  826. if err != nil {
  827. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  828. return
  829. }
  830. this.ServeSuccessJSON(map[string]interface{}{
  831. "normdata": normdata,
  832. })
  833. }
  834. if err != nil {
  835. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  836. return
  837. }
  838. this.ServeSuccessJSON(map[string]interface{}{
  839. "normdata": normdata,
  840. })
  841. }
  842. func (this *CommonApiController) GetFirstQuarter() {
  843. orgid := this.GetAdminUserInfo().CurrentOrgId
  844. lapseto, _ := this.GetInt64("lapseto")
  845. fmt.Println("转归", lapseto)
  846. startime := this.GetString("startime")
  847. fmt.Println("startime", startime)
  848. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  849. fmt.Println("parseDateErr", parseDateErr)
  850. statime := startDate.Unix()
  851. fmt.Println("开始时间", statime)
  852. endtime := this.GetString("endtime")
  853. fmt.Println("endtime", endtime)
  854. endTimeYMDHmsStr := endtime + " 23:59:59"
  855. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  856. entime := endDate.Unix()
  857. fmt.Println("结束日期", entime)
  858. //group, parseDateErr := service.GetItemNameGroup(orgid, statime, entime)
  859. //quarter, err := service.GetFirstQuarter(orgid, statime, entime)
  860. count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
  861. if err != nil {
  862. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  863. return
  864. }
  865. this.ServeSuccessJSON(map[string]interface{}{
  866. "count": count,
  867. })
  868. }
  869. func (this *CommonApiController) GetProjectList() {
  870. startime := this.GetString("startime")
  871. fmt.Println("startime", startime)
  872. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  873. fmt.Println("parseDateErr", parseDateErr)
  874. statime := startDate.Unix()
  875. fmt.Println("开始时间", statime)
  876. endtime := this.GetString("endtime")
  877. fmt.Println("endtime", endtime)
  878. endTimeYMDHmsStr := endtime + " 23:59:59"
  879. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  880. entime := endDate.Unix()
  881. fmt.Println("结束日期", entime)
  882. adminInfo := this.GetAdminUserInfo()
  883. orgid := adminInfo.CurrentOrgId
  884. fmt.Println("orgid", orgid)
  885. lapseto, _ := this.GetInt64("lapseto")
  886. fmt.Println("lapseto", lapseto)
  887. itemtype, _ := this.GetInt64("itemtype")
  888. fmt.Println("type", itemtype)
  889. modetype, _ := this.GetInt64("modetype")
  890. fmt.Println("modetype", modetype)
  891. firstQuarterStart := this.GetString("first_quarter_start")
  892. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  893. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  894. fmt.Println("第一季度开始时间", firstQuarterStartUnix)
  895. fisrtQuarterEnd := this.GetString("first_qurter_end")
  896. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  897. fisrtQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  898. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  899. fmt.Println("第一季度结束时间", fisrtQuarterEndStrUnix)
  900. secondeQuarterStart := this.GetString("second_qurter_start")
  901. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  902. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  903. fmt.Println("第二季度开始时间", secondeQuarterStartUnix)
  904. secondQuarterEnd := this.GetString("second_qurter_end")
  905. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  906. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  907. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  908. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  909. threeQuarterStart := this.GetString("three_qurter_start")
  910. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  911. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  912. fmt.Println("第三季度开始时间", threeQuarterStartUnix)
  913. threeQuarterEnd := this.GetString("three_qurter_end")
  914. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  915. threeQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  916. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  917. fmt.Println("第三季度结束时间", threeQuarterEndStrUnix)
  918. fourQuarterStart := this.GetString("four_qurter_start")
  919. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  920. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  921. fmt.Println("第四季度开始时间", fourQuarterStartUnix)
  922. fourQuarterEnd := this.GetString("four_qurter_end")
  923. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  924. fourQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  925. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  926. fmt.Println("第四季度结束时间", fourQuarterEndStrUnix)
  927. //按季度统计
  928. if itemtype == 1 {
  929. //统计总共
  930. list, err := service.GetProjectList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  931. //统计达标个数
  932. standList, err := service.GetProjectStandList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  933. if err != nil {
  934. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  935. return
  936. }
  937. this.ServeSuccessJSON(map[string]interface{}{
  938. "list": list,
  939. "standList": standList,
  940. })
  941. }
  942. }
  943. func (this *CommonApiController) GetMonthProjectList() {
  944. adminUser := this.GetAdminUserInfo()
  945. orgid := adminUser.CurrentOrgId
  946. fmt.Println("orgid", orgid)
  947. lapseto, _ := this.GetInt64("lapseto")
  948. fmt.Println("lapseto", lapseto)
  949. itemtype, _ := this.GetInt64("itemtype")
  950. fmt.Println("itemtype", itemtype)
  951. modetype, _ := this.GetInt64("modetype")
  952. fmt.Println("modetype", modetype)
  953. januaryStart := this.GetString("januaryStart")
  954. fmt.Println("一月始", januaryStart)
  955. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  956. januaryStartStrUnix := januaryStartStr.Unix()
  957. fmt.Println("一月使", januaryStartStrUnix)
  958. januaryEnd := this.GetString("januaryEnd")
  959. fmt.Println("一月末", januaryEnd)
  960. januaryEndStr := januaryEnd + " 23:59:59"
  961. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  962. januaryEndStrUnix := januaryEndStrs.Unix()
  963. fmt.Println("一月末", januaryEndStrUnix)
  964. febStart := this.GetString("febStart")
  965. fmt.Println("二月始", febStart)
  966. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  967. febStartStrStrUnix := febStartStr.Unix()
  968. fmt.Println("二月使", febStartStrStrUnix)
  969. febEnd := this.GetString("febEnd")
  970. fmt.Println("二月末", febEnd)
  971. febEndStr := febEnd + " 23:59:59"
  972. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  973. febEndStrUnix := febEndStrs.Unix()
  974. fmt.Println("二月末", febEndStrUnix)
  975. marchStart := this.GetString("marchStart")
  976. fmt.Println("三月始", marchStart)
  977. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  978. marchStartStrUnix := marchStartStr.Unix()
  979. fmt.Println("三月使", marchStartStrUnix)
  980. marchEnd := this.GetString("marchEnd")
  981. fmt.Println("三月末", febEnd)
  982. marchEndStr := marchEnd + " 23:59:59"
  983. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  984. marchEndStrUnix := marchEndStrs.Unix()
  985. fmt.Println("三月末", marchEndStrUnix)
  986. aprStart := this.GetString("aprStart")
  987. fmt.Println("四月始", aprStart)
  988. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  989. aprStartStrUnix := aprStartStr.Unix()
  990. fmt.Println("四月使", aprStartStrUnix)
  991. aprEnd := this.GetString("aprEnd")
  992. fmt.Println("四月末", aprEnd)
  993. aprEndStr := aprEnd + " 23:59:59"
  994. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  995. aprEndStrsUnix := aprEndStrs.Unix()
  996. fmt.Println("四月末", aprEndStrsUnix)
  997. mayStart := this.GetString("mayStart")
  998. fmt.Println("五月始", mayStart)
  999. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1000. mayStartStrUnix := mayStartStr.Unix()
  1001. fmt.Println("五月使", mayStartStrUnix)
  1002. mayEnd := this.GetString("mayEnd")
  1003. fmt.Println("五月末", mayEnd)
  1004. mayEndStr := mayEnd + " 23:59:59"
  1005. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1006. mayEndStrsUnix := mayEndStrs.Unix()
  1007. fmt.Println("五月末", mayEndStrsUnix)
  1008. junStart := this.GetString("junStart")
  1009. fmt.Println("六月始", mayStart)
  1010. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1011. junStartStrUnix := junStartStr.Unix()
  1012. fmt.Println("六月使", junStartStrUnix)
  1013. junEnd := this.GetString("junEnd")
  1014. fmt.Println("六月末", junEnd)
  1015. junEndStr := junEnd + " 23:59:59"
  1016. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1017. junEndStrsUnix := junEndStrs.Unix()
  1018. fmt.Println("六月末", junEndStrsUnix)
  1019. julStart := this.GetString("julStart")
  1020. fmt.Println("七月始", julStart)
  1021. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1022. julStartStrUnix := julStartStr.Unix()
  1023. fmt.Println("七月使", julStartStrUnix)
  1024. julEnd := this.GetString("julEnd")
  1025. fmt.Println("七月末", julEnd)
  1026. julEndStr := julEnd + " 23:59:59"
  1027. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1028. julEndStrsUnix := julEndStrs.Unix()
  1029. fmt.Println("七月末", julEndStrsUnix)
  1030. augStart := this.GetString("augStart")
  1031. fmt.Println("八月始", augStart)
  1032. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1033. augStartStrUnix := augStartStr.Unix()
  1034. fmt.Println("八月使", augStartStrUnix)
  1035. augEnd := this.GetString("augEnd")
  1036. fmt.Println("八月末", augEnd)
  1037. augEndStr := augEnd + " 23:59:59"
  1038. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1039. augEndStrsUnix := augEndStrs.Unix()
  1040. fmt.Println("八月末", augEndStrsUnix)
  1041. sepStart := this.GetString("sepStart")
  1042. fmt.Println("九月始", sepStart)
  1043. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1044. sepStartStrUnix := sepStartStr.Unix()
  1045. fmt.Println("九月使", sepStartStrUnix)
  1046. sepEnd := this.GetString("sepEnd")
  1047. fmt.Println("九月末", sepEnd)
  1048. sepEndStr := sepEnd + " 23:59:59"
  1049. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1050. sepEndStrsUnix := sepEndStrs.Unix()
  1051. fmt.Println("九月末", sepEndStrsUnix)
  1052. octStart := this.GetString("octStart")
  1053. fmt.Println("10月始", octStart)
  1054. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1055. octStartStrUnix := octStartStr.Unix()
  1056. fmt.Println("10月使", octStartStrUnix)
  1057. octEnd := this.GetString("octEnd")
  1058. fmt.Println("10月末", octEnd)
  1059. octEndStr := octEnd + " 23:59:59"
  1060. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1061. octEndStrsUnix := octEndStrs.Unix()
  1062. fmt.Println("10月末", octEndStrsUnix)
  1063. novStart := this.GetString("novStart")
  1064. fmt.Println("11月始", novStart)
  1065. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1066. novStartStrUnix := novStartStr.Unix()
  1067. fmt.Println("11月使", novStartStrUnix)
  1068. novEnd := this.GetString("novEnd")
  1069. fmt.Println("11月末", novEnd)
  1070. novEndStr := novEnd + " 23:59:59"
  1071. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1072. novEndStrsUnix := novEndStrs.Unix()
  1073. fmt.Println("10月末", novEndStrsUnix)
  1074. decStart := this.GetString("decStart")
  1075. fmt.Println("12月始", novStart)
  1076. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1077. decStartStrUnix := decStartStr.Unix()
  1078. fmt.Println("12月使", decStartStrUnix)
  1079. decEnd := this.GetString("decEnd")
  1080. fmt.Println("12月末", novEnd)
  1081. decEndStr := decEnd + " 23:59:59"
  1082. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1083. decEndStrsUnix := decEndStrs.Unix()
  1084. fmt.Println("12月末", decEndStrsUnix)
  1085. //统计总共
  1086. 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)
  1087. //统计不合格
  1088. 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)
  1089. fmt.Println("monthnolist=====", monthNolist)
  1090. if err != nil {
  1091. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1092. return
  1093. }
  1094. this.ServeSuccessJSON(map[string]interface{}{
  1095. "monthlist": monthlist,
  1096. "monthNolist": monthNolist,
  1097. })
  1098. }
  1099. func (this *CommonApiController) GetPatientscontrol() {
  1100. adminUser := this.GetAdminUserInfo()
  1101. orgid := adminUser.CurrentOrgId
  1102. fmt.Println("org", orgid)
  1103. lapstor, _ := this.GetInt64("lapstor")
  1104. fmt.Println("lapstor", lapstor)
  1105. startime := this.GetString("startime")
  1106. fmt.Println("开始时间", startime)
  1107. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1108. startimeStrUnix := startimeStr.Unix()
  1109. fmt.Println("时间搓", startimeStrUnix)
  1110. endtime := this.GetString("endtime")
  1111. fmt.Println("结束时间", endtime)
  1112. endtimeStr := endtime + " 23:59:59"
  1113. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1114. endtimeStrsUnix := endtimeStrs.Unix()
  1115. fmt.Println("结束时间搓", endtimeStrsUnix)
  1116. page, _ := this.GetInt64("page")
  1117. fmt.Println("page", page)
  1118. limit, _ := this.GetInt64("limit")
  1119. fmt.Println("limit", limit)
  1120. patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1121. control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1122. //获取最后一次数据
  1123. if err != nil {
  1124. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1125. return
  1126. }
  1127. this.ServeSuccessJSON(map[string]interface{}{
  1128. "patients": patients,
  1129. "total": total,
  1130. "control": control,
  1131. })
  1132. }
  1133. func (this *CommonApiController) GetCartogramList() {
  1134. adminUser := this.GetAdminUserInfo()
  1135. orgid := adminUser.CurrentOrgId
  1136. fmt.Println("orgid", orgid)
  1137. lapstor, _ := this.GetInt64("lapstor")
  1138. fmt.Println("lapstor", lapstor)
  1139. startime := this.GetString("startime")
  1140. fmt.Println("开始时间", startime)
  1141. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1142. startimeStrUnix := startimeStr.Unix()
  1143. fmt.Println("时间搓", startimeStrUnix)
  1144. endtime := this.GetString("endtime")
  1145. fmt.Println("结束时间", endtime)
  1146. endtimeStr := endtime + " 23:59:59"
  1147. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1148. endtimeStrsUnix := endtimeStrs.Unix()
  1149. fmt.Println("结束时间搓", endtimeStrsUnix)
  1150. limit, _ := this.GetInt64("limit")
  1151. page, _ := this.GetInt64("page")
  1152. cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1153. _, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1154. if err != nil {
  1155. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1156. return
  1157. }
  1158. this.ServeSuccessJSON(map[string]interface{}{
  1159. "cartogramlist": cartogramlist,
  1160. "total": total,
  1161. })
  1162. }
  1163. func (this *CommonApiController) GetPatientContor() {
  1164. adminUser := this.GetAdminUserInfo()
  1165. orgid := adminUser.CurrentOrgId
  1166. fmt.Println(orgid)
  1167. lapstor, _ := this.GetInt64("lapstor")
  1168. fmt.Println("lapstor", lapstor)
  1169. patientid, _ := this.GetInt64("patientid")
  1170. startime := this.GetString("startime")
  1171. fmt.Println("开始时间", startime)
  1172. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1173. startimeStrUnix := startimeStr.Unix()
  1174. fmt.Println("时间搓", startimeStrUnix)
  1175. endtime := this.GetString("endtime")
  1176. fmt.Println("结束时间", endtime)
  1177. endtimeStr := endtime + " 23:59:59"
  1178. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1179. endtimeStrsUnix := endtimeStrs.Unix()
  1180. fmt.Println("结束时间搓", endtimeStrsUnix)
  1181. patients, err := service.GetPatientNames(orgid, patientid)
  1182. patientcontorDetail, err := service.GetLastPatientsControlTwo(orgid, patientid, startimeStrUnix, endtimeStrsUnix)
  1183. if err != nil {
  1184. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1185. return
  1186. }
  1187. this.ServeSuccessJSON(map[string]interface{}{
  1188. "patientcontorDetail": patientcontorDetail,
  1189. "name": patients.Name,
  1190. })
  1191. }
  1192. func (this *CommonApiController) GetQualityControl() {
  1193. adminUser := this.GetAdminUserInfo()
  1194. orgid := adminUser.CurrentOrgId
  1195. fmt.Println(orgid)
  1196. patientid, _ := this.GetInt64("patientid")
  1197. startime, _ := this.GetInt64("startime")
  1198. fmt.Println("startime", startime)
  1199. endtime, _ := this.GetInt64("endtime")
  1200. fmt.Println("endtime", endtime)
  1201. itemid, _ := this.GetInt64("itemid")
  1202. fmt.Println("itemid", itemid)
  1203. list, err := service.GetQualityControlById(orgid, patientid, startime, endtime, itemid)
  1204. if err != nil {
  1205. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1206. return
  1207. }
  1208. this.ServeSuccessJSON(map[string]interface{}{
  1209. "list": list,
  1210. })
  1211. }
  1212. func (this *CommonApiController) GetTreatlist() {
  1213. adminuser := this.GetAdminUserInfo()
  1214. orgId := adminuser.CurrentOrgId
  1215. startime := this.GetString("start_time")
  1216. fmt.Println(startime)
  1217. endtime := this.GetString("end_time")
  1218. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1219. fmt.Println("parseDateErr", parseDateErr)
  1220. statime := startDate.Unix()
  1221. fmt.Println("开始时间", statime)
  1222. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  1223. entime := endDate.Unix()
  1224. fmt.Println("结束日期", entime)
  1225. value, _ := this.GetInt64("value")
  1226. fmt.Println("value", value)
  1227. list, err := service.GetTreatList(orgId, statime, entime, value)
  1228. if err != nil {
  1229. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1230. return
  1231. }
  1232. this.ServeSuccessJSON(map[string]interface{}{
  1233. "list": list,
  1234. })
  1235. }