common_api_controller.go 54KB

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