common_api_controller.go 45KB

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