common_api_controller.go 54KB

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