common_api_controller.go 44KB

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