common_api_controller.go 48KB

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