common_api_controller.go 51KB

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