common_api_controller.go 75KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/jinzhu/gorm"
  10. "strconv"
  11. "time"
  12. )
  13. type CommonApiController struct {
  14. BaseAuthAPIController
  15. }
  16. func (this *CommonApiController) GetInspectionMajor() {
  17. adminInfo := this.GetAdminUserInfo()
  18. orgid := adminInfo.CurrentOrgId
  19. major, err := service.GetInspectionMajor(orgid)
  20. if len(major) == 0 {
  21. major, _ := service.GetInspectionMajor(0)
  22. if err != nil {
  23. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  24. return
  25. }
  26. this.ServeSuccessJSON(map[string]interface{}{
  27. "inspection": major,
  28. })
  29. }
  30. if err != nil {
  31. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  32. return
  33. }
  34. this.ServeSuccessJSON(map[string]interface{}{
  35. "inspection": major,
  36. })
  37. }
  38. func (this *CommonApiController) GetInspectionMinor() {
  39. id, _ := this.GetInt64("id")
  40. adminInfo := this.GetAdminUserInfo()
  41. orgId := adminInfo.CurrentOrgId
  42. //查询该机构是否存在小项
  43. major, _ := service.GetInspectionMajor(orgId)
  44. if len(major) == 0 {
  45. minor, err := service.GetInspectionMinor(id, 0)
  46. if err != nil {
  47. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  48. return
  49. }
  50. this.ServeSuccessJSON(map[string]interface{}{
  51. "inspection": minor,
  52. })
  53. } else {
  54. minor, err := service.GetInspectionMinor(id, orgId)
  55. if err != nil {
  56. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  57. return
  58. }
  59. this.ServeSuccessJSON(map[string]interface{}{
  60. "inspection": minor,
  61. })
  62. }
  63. }
  64. func (this *CommonApiController) GetInspectionRange() {
  65. id, _ := this.GetInt64("id")
  66. fmt.Println("id", id)
  67. inspectionRange, err := service.GetInspectionRange(id)
  68. if err != nil {
  69. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  70. return
  71. }
  72. this.ServeSuccessJSON(map[string]interface{}{
  73. "inspectionRange": inspectionRange,
  74. })
  75. }
  76. func (this *CommonApiController) SaveConfiguration() {
  77. adminInfo := this.GetAdminUserInfo()
  78. orgid := adminInfo.CurrentOrgId
  79. dataBody := make(map[string]interface{}, 0)
  80. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  81. fmt.Println("err", err)
  82. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  83. inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
  84. minrange := dataBody["min_range"].(string)
  85. largerange := dataBody["large_range"].(string)
  86. fmt.Println("largerange", largerange)
  87. sort := dataBody["sort"].(string)
  88. sorts, err := strconv.ParseInt(sort, 10, 64)
  89. checktype := int64(dataBody["check_type"].(float64))
  90. rangvalue := dataBody["range_value"].(string)
  91. if rangvalue == "0" {
  92. rangvalue = ""
  93. }
  94. // 参与集成的机构根据小项id获取item_id
  95. itemid, err := service.GetItemid(inspectionMinor)
  96. //查询小项是否有值
  97. fmt.Println("小项id", itemid.ItemId)
  98. major, err := service.GetInspectionMajor(orgid)
  99. if len(major) == 0 {
  100. _, errcode := service.GetConfigurationById(inspectionmajor, inspectionMinor, orgid)
  101. if errcode == gorm.ErrRecordNotFound {
  102. standard := models.XtQualityControlStandard{
  103. InspectionMajor: inspectionmajor,
  104. InspectionMinor: inspectionMinor,
  105. MinRange: minrange,
  106. LargeRange: largerange,
  107. Sort: sorts,
  108. UserOrgId: orgid,
  109. Status: 1,
  110. RangeType: checktype,
  111. RangeValue: rangvalue,
  112. CreatedTime: time.Now().Unix(),
  113. IsStatus: 1,
  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. } else {
  129. _, errcode := service.GetConfigurationById(inspectionmajor, inspectionMinor, orgid)
  130. if errcode == gorm.ErrRecordNotFound {
  131. standard := models.XtQualityControlStandard{
  132. InspectionMajor: inspectionmajor,
  133. InspectionMinor: itemid.ItemId,
  134. MinRange: minrange,
  135. LargeRange: largerange,
  136. Sort: sorts,
  137. UserOrgId: orgid,
  138. Status: 1,
  139. RangeType: checktype,
  140. RangeValue: rangvalue,
  141. CreatedTime: time.Now().Unix(),
  142. IsStatus: 1,
  143. }
  144. fmt.Println(standard)
  145. err = service.SaveInspection(&standard)
  146. if err != nil {
  147. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  148. return
  149. }
  150. this.ServeSuccessJSON(map[string]interface{}{
  151. "standard": standard,
  152. })
  153. } else if errcode == nil {
  154. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  155. return
  156. }
  157. }
  158. }
  159. func (this *CommonApiController) GetConfigurationlist() {
  160. limit, _ := this.GetInt64("limit")
  161. page, _ := this.GetInt64("page")
  162. adminUser := this.GetAdminUserInfo()
  163. orgid := adminUser.CurrentOrgId
  164. major, _ := service.GetInspectionMajor(orgid)
  165. fmt.Println("major22222222222222222222222222222222222222", major)
  166. if len(major) == 0 {
  167. configurationlist, total, err := service.GetConfigurationlist(orgid, limit, page)
  168. pressure, err := service.GetDefaultBloodPressure(orgid)
  169. if err != nil {
  170. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  171. return
  172. }
  173. this.ServeSuccessJSON(map[string]interface{}{
  174. "configurationlist": configurationlist,
  175. "total": total,
  176. "pressure": pressure,
  177. })
  178. } else {
  179. configurationlist, total, err := service.GetConfigurationListTwo(orgid, limit, page)
  180. pressure, err := service.GetDefaultBloodPressure(orgid)
  181. if err != nil {
  182. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  183. return
  184. }
  185. this.ServeSuccessJSON(map[string]interface{}{
  186. "configurationlist": configurationlist,
  187. "total": total,
  188. "pressure": pressure,
  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. dataBody := make(map[string]interface{}, 0)
  247. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  248. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  249. inspectionMinor := int64(dataBody["inspectionMinor"].(float64))
  250. minrange := dataBody["min_range"].(string)
  251. largerange := dataBody["large_range"].(string)
  252. sort := int64(dataBody["sort"].(float64))
  253. rangvalue := dataBody["range_value"].(string)
  254. if rangvalue == "0" {
  255. rangvalue = ""
  256. }
  257. rangtype := int64(dataBody["check_type"].(float64))
  258. adminInfo := this.GetAdminUserInfo()
  259. orgId := adminInfo.CurrentOrgId
  260. configuration, err := service.GetConfigurationByIdTwo(inspectionmajor, inspectionMinor, orgId)
  261. fmt.Println("err", err)
  262. if configuration.ID > 0 && configuration.ID != id {
  263. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  264. return
  265. }
  266. major, err := service.GetInspectionMajor(orgId)
  267. if len(major) == 0 {
  268. standard := models.XtQualityControlStandard{
  269. InspectionMajor: inspectionmajor,
  270. InspectionMinor: inspectionMinor,
  271. MinRange: minrange,
  272. LargeRange: largerange,
  273. Sort: sort,
  274. RangeValue: rangvalue,
  275. RangeType: rangtype,
  276. Status: 1,
  277. UserOrgId: orgId,
  278. CreatedTime: time.Now().Unix(),
  279. UpdatedTime: time.Now().Unix(),
  280. }
  281. err = service.UpdarteConfiguration(&standard, id)
  282. if err != nil {
  283. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  284. return
  285. }
  286. this.ServeSuccessJSON(map[string]interface{}{
  287. "standard": standard,
  288. })
  289. } else {
  290. itemid, _ := service.GetItemid(inspectionMinor)
  291. standard := models.XtQualityControlStandard{
  292. InspectionMajor: inspectionmajor,
  293. InspectionMinor: itemid.ItemId,
  294. MinRange: minrange,
  295. LargeRange: largerange,
  296. Sort: sort,
  297. RangeValue: rangvalue,
  298. RangeType: rangtype,
  299. Status: 1,
  300. UserOrgId: orgId,
  301. CreatedTime: time.Now().Unix(),
  302. UpdatedTime: time.Now().Unix(),
  303. }
  304. err = service.UpdarteConfiguration(&standard, id)
  305. if err != nil {
  306. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  307. return
  308. }
  309. this.ServeSuccessJSON(map[string]interface{}{
  310. "standard": standard,
  311. })
  312. }
  313. }
  314. func (this *CommonApiController) DeleteConfiguration() {
  315. id, _ := this.GetInt64("id")
  316. err := service.DeleteConfiguration(id)
  317. if err != nil {
  318. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  319. return
  320. }
  321. returnData := make(map[string]interface{}, 0)
  322. returnData["msg"] = "ok"
  323. this.ServeSuccessJSON(returnData)
  324. return
  325. }
  326. func (this *CommonApiController) GetAllInspectiondata() {
  327. adminUser := this.GetAdminUserInfo()
  328. orgid := adminUser.CurrentOrgId
  329. //查询该机构是否有数据
  330. _, errcode := service.GetAllInspectionData(orgid)
  331. if errcode == gorm.ErrRecordNotFound {
  332. inspection, err := service.GetAllInspectiondatatwo(0)
  333. if err != nil {
  334. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  335. return
  336. }
  337. this.ServeSuccessJSON(map[string]interface{}{
  338. "inspection": inspection,
  339. })
  340. } else if errcode == nil {
  341. inspection, err := service.GetAllInspectiondatatwo(orgid)
  342. if err != nil {
  343. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  344. return
  345. }
  346. this.ServeSuccessJSON(map[string]interface{}{
  347. "inspection": inspection,
  348. })
  349. }
  350. }
  351. func (this *CommonApiController) SaveCheckConfiguration() {
  352. dataBody := make(map[string]interface{}, 0)
  353. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  354. fmt.Println("err", err)
  355. adminUser := this.GetAdminUserInfo()
  356. orgid := adminUser.CurrentOrgId
  357. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  358. //fmt.Println("大项", inspectionmajor)
  359. frequency := dataBody["frequency"].(string)
  360. //fmt.Println("凭次", frequency)
  361. sort := dataBody["sort"].(string)
  362. sorts, err := strconv.ParseInt(sort, 10, 64)
  363. //fmt.Println("sort", sort)
  364. _, errcode := service.GetInspectionMajorById(inspectionmajor, orgid)
  365. if errcode == gorm.ErrRecordNotFound {
  366. configuration := models.XtCheckConfiguration{
  367. InspectionMajor: inspectionmajor,
  368. InspectionFrequency: frequency,
  369. Sort: sorts,
  370. UserOrgId: orgid,
  371. Status: 1,
  372. CreatedTime: time.Now().Unix(),
  373. }
  374. err := service.CreateCheckConfiguration(&configuration)
  375. if err != nil {
  376. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  377. return
  378. }
  379. this.ServeSuccessJSON(map[string]interface{}{
  380. "configuration": configuration,
  381. })
  382. } else if errcode == nil {
  383. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  384. return
  385. }
  386. }
  387. func (this *CommonApiController) GetAllCheckList() {
  388. adminUser := this.GetAdminUserInfo()
  389. orgid := adminUser.CurrentOrgId
  390. //fmt.Println("org", orgid)
  391. page, _ := this.GetInt64("page")
  392. limit, _ := this.GetInt64("limit")
  393. major, _ := service.GetInspectionMajor(orgid)
  394. if len(major) == 0 {
  395. checklist, total, err := service.GetAllChekcListTwo(orgid, page, limit)
  396. if err != nil {
  397. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  398. return
  399. }
  400. this.ServeSuccessJSON(map[string]interface{}{
  401. "checklist": checklist,
  402. "total": total,
  403. })
  404. } else {
  405. checkList, total, err := service.GetAllCheckList(orgid, page, limit)
  406. if err != nil {
  407. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  408. return
  409. }
  410. this.ServeSuccessJSON(map[string]interface{}{
  411. "checklist": checkList,
  412. "total": total,
  413. })
  414. }
  415. }
  416. func (this *CommonApiController) GetCheckdetail() {
  417. id, _ := this.GetInt64("id")
  418. detail, err := service.GetCheckDetail(id)
  419. if err != nil {
  420. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  421. return
  422. }
  423. this.ServeSuccessJSON(map[string]interface{}{
  424. "checkdetail": detail,
  425. })
  426. }
  427. func (this *CommonApiController) UpdateCheck() {
  428. id, _ := this.GetInt64("id")
  429. fmt.Println(id)
  430. dataBody := make(map[string]interface{}, 0)
  431. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  432. fmt.Println(err)
  433. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  434. //fmt.Println("大项", inspectionmajor)
  435. frequency := dataBody["frequency"].(string)
  436. //fmt.Println("凭次", frequency)
  437. sort := int64(dataBody["sort"].(float64))
  438. //fmt.Println("sort", sort)
  439. adminInfo := this.GetAdminUserInfo()
  440. orgId := adminInfo.CurrentOrgId
  441. Inspection, err := service.GetInspectionMajorByIdTwo(inspectionmajor, orgId)
  442. if Inspection.ID > 0 && Inspection.ID != id {
  443. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  444. return
  445. }
  446. configuration := models.XtCheckConfiguration{
  447. InspectionMajor: inspectionmajor,
  448. InspectionFrequency: frequency,
  449. Sort: sort,
  450. }
  451. err = service.UpdateCheck(&configuration, id)
  452. if err != nil {
  453. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  454. return
  455. }
  456. this.ServeSuccessJSON(map[string]interface{}{
  457. "configuration": configuration,
  458. })
  459. }
  460. func (this *CommonApiController) DeleteCheck() {
  461. id, _ := this.GetInt64("id")
  462. err := service.DeleteCheck(id)
  463. if err != nil {
  464. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  465. return
  466. }
  467. returnData := make(map[string]interface{}, 0)
  468. returnData["msg"] = "ok"
  469. this.ServeSuccessJSON(returnData)
  470. return
  471. }
  472. func (this *CommonApiController) GetDialysisModeType() {
  473. timeLayout := "2006-01-02"
  474. loc, _ := time.LoadLocation("Local")
  475. startime := this.GetString("startime")
  476. endtime := this.GetString("endtime")
  477. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  478. startimes := startTimes.Unix()
  479. endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  480. endtimeData := endtimes.Unix()
  481. lapsetotype, _ := this.GetInt64("lapsetotype")
  482. sourcetype, _ := this.GetInt64("sourcetype")
  483. adminUser := this.GetAdminUserInfo()
  484. orgid := adminUser.CurrentOrgId
  485. //统计透析总量
  486. total, _ := service.GetDialysiTotal(startimes, endtimeData, orgid, lapsetotype, sourcetype)
  487. //var mode models.PatientPrescriptionCountStruct
  488. //mode.Count = total
  489. modeType, err := service.GetDialysisCountMode(startimes, endtimeData, orgid, lapsetotype, sourcetype)
  490. //var total models.PatientPrescriptionCountStruct
  491. //for _, item := range modeType {
  492. // total.Count = total.Count + item.Count
  493. //}
  494. if err != nil {
  495. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  496. return
  497. }
  498. this.ServeSuccessJSON(map[string]interface{}{
  499. "total": total,
  500. "modetype": modeType,
  501. })
  502. }
  503. func (this *CommonApiController) GetTotalLapseCount() {
  504. timeLayout := "2006-01-02"
  505. loc, _ := time.LoadLocation("Local")
  506. adminUser := this.GetAdminUserInfo()
  507. orgid := adminUser.CurrentOrgId
  508. startime := this.GetString("startime")
  509. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  510. startnunix := startTimes.Unix()
  511. endtime := this.GetString("endtime")
  512. endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
  513. endunix := endtimes.Unix()
  514. lapsetotype, _ := this.GetInt64("lapsetotype")
  515. sourcetype, _ := this.GetInt64("sourcetype")
  516. //统计该机构的转出人数
  517. patients, err := service.GetTotalRollOutPatients(orgid, startnunix, endunix, lapsetotype, sourcetype)
  518. //统计该机构转出病人
  519. patienttwo, err := service.GetTotalRollOutPatientsTwo(orgid, startnunix, endunix, lapsetotype, sourcetype)
  520. count := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
  521. if err != nil {
  522. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  523. return
  524. }
  525. //统计当前机构转出的人数
  526. rollout, err := service.GetCountRollout(orgid, startnunix, endunix, lapsetotype, sourcetype)
  527. this.ServeSuccessJSON(map[string]interface{}{
  528. "patients": patients,
  529. "count": count,
  530. "patienttwo": patienttwo,
  531. "rollout": rollout,
  532. })
  533. }
  534. func (this *CommonApiController) GetTotalSexCount() {
  535. adminUser := this.GetAdminUserInfo()
  536. orgid := adminUser.CurrentOrgId
  537. fmt.Println("orgid", orgid)
  538. startime, _ := this.GetInt64("startime")
  539. fmt.Println("开始时间", startime)
  540. endtime, _ := this.GetInt64("endtime")
  541. fmt.Println("结束时间", endtime)
  542. lapsetotype, _ := this.GetInt64("lapsetotype")
  543. sourcetype, _ := this.GetInt64("sourcetype")
  544. total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
  545. _, totalSex, err := service.GetManPatientTotal(orgid, lapsetotype, sourcetype)
  546. _, totalWoman, err := service.GetWoManPatientTotal(orgid, lapsetotype, sourcetype)
  547. if err != nil {
  548. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  549. return
  550. }
  551. this.ServeSuccessJSON(map[string]interface{}{
  552. "total": total,
  553. "totalSex": totalSex,
  554. "totalWoman": totalWoman,
  555. })
  556. }
  557. func (this *CommonApiController) GetTotalInfectiouscount() {
  558. adminUser := this.GetAdminUserInfo()
  559. orgid := adminUser.CurrentOrgId
  560. fmt.Println("orgid", orgid)
  561. timeLayout := "2006-01-02"
  562. loc, _ := time.LoadLocation("Local")
  563. startime := this.GetString("startime")
  564. startTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  565. startnunix := startTimes.Unix()
  566. endtime := this.GetString("endtime")
  567. endtimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 23:59:59", loc)
  568. endunix := endtimes.Unix()
  569. lapsetotype, _ := this.GetInt64("lapsetotype")
  570. sourcetype, _ := this.GetInt64("sourcetype")
  571. //统计透析总人数
  572. total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
  573. //统计透析人数传染病所占比例
  574. count, err := service.GetPatientInfectiousCount(orgid, startnunix, endunix, lapsetotype, sourcetype)
  575. //统计其他
  576. _, otherTotal, err := service.GetPatientOtherInfectious(orgid)
  577. if err != nil {
  578. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  579. return
  580. }
  581. this.ServeSuccessJSON(map[string]interface{}{
  582. "total": total,
  583. "count": count,
  584. "otherTotal": otherTotal,
  585. })
  586. }
  587. func (this *CommonApiController) GetTotalAgeCount() {
  588. adminUser := this.GetAdminUserInfo()
  589. orgid := adminUser.CurrentOrgId
  590. fmt.Println("orgid", orgid)
  591. startime, _ := this.GetInt64("startime")
  592. fmt.Println("开始时间", startime)
  593. endtime, _ := this.GetInt64("endtime")
  594. fmt.Println("结束时间", endtime)
  595. lapsetotype, _ := this.GetInt64("lapsetotype")
  596. sourcetype, _ := this.GetInt64("sourcetype")
  597. //统计透析总人数
  598. total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
  599. agecount, err := service.GetTotalAgeCount(orgid, lapsetotype, sourcetype)
  600. //two, err := service.GetTotalAgeCountTwo(orgid, startime, endtime)
  601. if err != nil {
  602. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  603. return
  604. }
  605. this.ServeSuccessJSON(map[string]interface{}{
  606. "total": total,
  607. "ageCount": agecount,
  608. })
  609. }
  610. func (this *CommonApiController) GetTotalDialysisCount() {
  611. adminUser := this.GetAdminUserInfo()
  612. orgid := adminUser.CurrentOrgId
  613. fmt.Println("org", orgid)
  614. startime, _ := this.GetInt64("startime")
  615. fmt.Println(startime)
  616. endtime, _ := this.GetInt64("endtime")
  617. fmt.Println(endtime)
  618. recordDateStr := time.Now().Format("2006-01-02")
  619. recordDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", recordDateStr)
  620. fmt.Println("parseDateErr", parseDateErr)
  621. nowtime := recordDate.Unix()
  622. lapsetotype, _ := this.GetInt64("lapsetotype")
  623. sourcetype, _ := this.GetInt64("sourcetype")
  624. //统计透析总人数
  625. total := service.GetPatientTotalCount(orgid, lapsetotype, sourcetype)
  626. fmt.Println("total", total)
  627. //获取该机构下的所有病人数据
  628. patients, err := service.GetTotalDialysisAgeCount(orgid)
  629. fmt.Println("patients", patients)
  630. //统计透年龄
  631. dataage, _ := service.GetDialysisAgeData(orgid, lapsetotype, sourcetype)
  632. if err != nil {
  633. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  634. return
  635. }
  636. this.ServeSuccessJSON(map[string]interface{}{
  637. "total": total,
  638. "patients": patients,
  639. "nowtime": nowtime,
  640. "dataage": dataage,
  641. })
  642. }
  643. func (this *CommonApiController) GetCurentOrgPatients() {
  644. adminUser := this.GetAdminUserInfo()
  645. orgid := adminUser.CurrentOrgId
  646. patients, err := service.GetCurentOrgPatients(orgid)
  647. if err != nil {
  648. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  649. return
  650. }
  651. this.ServeSuccessJSON(map[string]interface{}{
  652. "patients": patients,
  653. })
  654. }
  655. func (this *CommonApiController) GetDialysislist() {
  656. startime := this.GetString("startime")
  657. endtime := this.GetString("endtime")
  658. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  659. fmt.Println("parseDateErr", parseDateErr)
  660. statime := startDate.Unix()
  661. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  662. entime := endDate.Unix()
  663. page, _ := this.GetInt64("page")
  664. limit, _ := this.GetInt64("limit")
  665. fmt.Println(limit)
  666. adminUser := this.GetAdminUserInfo()
  667. orgId := adminUser.CurrentOrgId
  668. count, _ := service.TotalDialysisCount(statime, entime, orgId)
  669. dialysislist, total, err := service.GetDialysisList(statime, entime, page, limit, orgId)
  670. prescriptionList, _ := service.GetAllDialysisList(statime, entime, orgId)
  671. list, totallist, _ := service.GetDialysisPatientList(statime, entime, page, limit, orgId)
  672. //获取每个病人每个透析模式的数据(按透析记录)
  673. modeIdCount, parseDateErr := service.GetModeIdCount(statime, entime, orgId, page, 1000)
  674. //按排班
  675. scheduleCount, _ := service.GetScheduleModeIdCount(statime, entime, orgId, page, 1000)
  676. scheduleList, _ := service.GetDialysisScheduleList(statime, entime, page, limit, orgId)
  677. if err != nil {
  678. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  679. return
  680. }
  681. this.ServeSuccessJSON(map[string]interface{}{
  682. "dialysislist": dialysislist,
  683. "total": total,
  684. "list": list,
  685. "totallist": totallist,
  686. "prescriptionList": prescriptionList,
  687. "count": count,
  688. "modeIdCount": modeIdCount,
  689. "scheduleCount": scheduleCount,
  690. "scheduleList": scheduleList,
  691. })
  692. }
  693. func (this *CommonApiController) GetLastSort() {
  694. adminUser := this.GetAdminUserInfo()
  695. orgid := adminUser.CurrentOrgId
  696. standard, err := service.GetLastSort(orgid)
  697. if err != nil {
  698. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  699. return
  700. }
  701. this.ServeSuccessJSON(map[string]interface{}{
  702. "standard": standard,
  703. })
  704. }
  705. func (this *CommonApiController) GetLastCheckList() {
  706. adminUser := this.GetAdminUserInfo()
  707. orgid := adminUser.CurrentOrgId
  708. checkList, err := service.GetLastCheckList(orgid)
  709. if err != nil {
  710. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  711. return
  712. }
  713. this.ServeSuccessJSON(map[string]interface{}{
  714. "checkList": checkList,
  715. })
  716. }
  717. func (this *CommonApiController) GetDialysisDetailById() {
  718. adminUser := this.GetAdminUserInfo()
  719. orgId := adminUser.CurrentOrgId
  720. id, _ := this.GetInt64("id")
  721. fmt.Println("id", id)
  722. startime := this.GetString("startime")
  723. fmt.Println(startime)
  724. endtime := this.GetString("endtime")
  725. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  726. fmt.Println("parseDateErr", parseDateErr)
  727. statime := startDate.Unix()
  728. fmt.Println("开始时间", statime)
  729. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  730. entime := endDate.Unix()
  731. fmt.Println("开始时间", statime)
  732. fmt.Println(endtime)
  733. limit, _ := this.GetInt64("limit")
  734. fmt.Println("limit", limit)
  735. page, _ := this.GetInt64("page")
  736. fmt.Println("page", page)
  737. patients, total, err := service.GetDialysisDetailById(id, orgId, statime, entime, limit, page)
  738. if err != nil {
  739. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  740. return
  741. }
  742. this.ServeSuccessJSON(map[string]interface{}{
  743. "patients": patients,
  744. "total": total,
  745. })
  746. }
  747. func (this *CommonApiController) GetPrescritionByName() {
  748. adminUser := this.GetAdminUserInfo()
  749. orgId := adminUser.CurrentOrgId
  750. patientid, _ := this.GetInt64("patientid")
  751. startime := this.GetString("startime")
  752. fmt.Println(startime)
  753. endtime := this.GetString("endtime")
  754. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  755. fmt.Println("parseDateErr", parseDateErr)
  756. statime := startDate.Unix()
  757. fmt.Println("开始时间", statime)
  758. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  759. entime := endDate.Unix()
  760. limit, _ := this.GetInt64("limit")
  761. page, _ := this.GetInt64("page")
  762. patient, total, err := service.GetPrescritionByName(orgId, patientid, statime, entime, limit, page)
  763. if err != nil {
  764. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  765. return
  766. }
  767. this.ServeSuccessJSON(map[string]interface{}{
  768. "patient": patient,
  769. "total": total,
  770. })
  771. }
  772. func (this *CommonApiController) GetStatistics() {
  773. adminUser := this.GetAdminUserInfo()
  774. orgId := adminUser.CurrentOrgId
  775. startime := this.GetString("start_time")
  776. endtime := this.GetString("end_time")
  777. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  778. fmt.Println("parseDateErr", parseDateErr)
  779. statime := startDate.Unix()
  780. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  781. entime := endDate.Unix()
  782. value, _ := this.GetInt64("value")
  783. limit, _ := this.GetInt64("limit")
  784. page, _ := this.GetInt64("page")
  785. modeId, _ := this.GetInt64("mode_id")
  786. treatinfo, total, err := service.GetTreateInfo(orgId, statime, entime, value, limit, page)
  787. statistics, ttd, _ := service.GetStatistics(orgId, statime, entime, modeId)
  788. if err != nil {
  789. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  790. return
  791. }
  792. this.ServeSuccessJSON(map[string]interface{}{
  793. "statistics": statistics,
  794. "ttd": ttd,
  795. "total": total,
  796. "treatinfo": treatinfo,
  797. })
  798. }
  799. func (this *CommonApiController) GetInspectionTatolCount() {
  800. adminUser := this.GetAdminUserInfo()
  801. orgid := adminUser.CurrentOrgId
  802. startime := this.GetString("startime")
  803. fmt.Println(startime)
  804. endtime := this.GetString("endtime")
  805. fmt.Print("endtime", endtime)
  806. patientid, _ := this.GetInt64("patientid")
  807. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  808. fmt.Println("parseDateErr", parseDateErr)
  809. statime := startDate.Unix()
  810. secondQuarterEndStr := endtime + " 23:59:59"
  811. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  812. entime := secondQuarterEnds.Unix()
  813. references, err := service.GetInspectionTotalCount(orgid)
  814. if err != nil {
  815. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  816. return
  817. }
  818. counts, err := service.GetInspectionProjectCount(orgid, statime, entime, patientid)
  819. this.ServeSuccessJSON(map[string]interface{}{
  820. "Inspection": references,
  821. "counts": counts,
  822. })
  823. }
  824. func (this *CommonApiController) GetInspectionDetailById() {
  825. adminUser := this.GetAdminUserInfo()
  826. orgId := adminUser.CurrentOrgId
  827. id, _ := this.GetInt64("id")
  828. fmt.Println("id", id)
  829. startime := this.GetString("startime")
  830. endtime := this.GetString("endtime")
  831. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  832. fmt.Println("parseDateErr", parseDateErr)
  833. statime := startDate.Unix()
  834. fmt.Println("开始时间", statime)
  835. secondQuarterEndStr := endtime + " 23:59:59"
  836. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  837. entime := secondQuarterEnds.Unix()
  838. patientdetail, err := service.GetInspectionDetailById(id, orgId, statime, entime)
  839. if err != nil {
  840. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  841. return
  842. }
  843. this.ServeSuccessJSON(map[string]interface{}{
  844. "patientdetail": patientdetail,
  845. })
  846. }
  847. func (this *CommonApiController) GetSearchPatientInfo() {
  848. adminUser := this.GetAdminUserInfo()
  849. orgId := adminUser.CurrentOrgId
  850. //keyword := this.GetString("keyword")
  851. //fmt.Println("keyword", keyword)
  852. patientid, _ := this.GetInt64("patientid")
  853. startime := this.GetString("startime")
  854. endtime := this.GetString("endtime")
  855. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  856. fmt.Println("parseDateErr", parseDateErr)
  857. statime := startDate.Unix()
  858. fmt.Println("开始时间", statime)
  859. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  860. //entime := endDate.Unix()
  861. //fmt.Println("结束日期", entime)
  862. secondQuarterEndStr := endtime + " 23:59:59"
  863. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  864. entime := secondQuarterEnds.Unix()
  865. PatientsInfo, err := service.GetSearchPatientInfo(orgId, patientid, statime, entime)
  866. if err != nil {
  867. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  868. return
  869. }
  870. this.ServeSuccessJSON(map[string]interface{}{
  871. "PatientsInfo": PatientsInfo,
  872. })
  873. }
  874. func (this *CommonApiController) GetAllMajorInspection() {
  875. adminUser := this.GetAdminUserInfo()
  876. orgid := adminUser.CurrentOrgId
  877. inspection, err := service.GetMajorInspectionByOrgid(orgid)
  878. if len(inspection) == 0 {
  879. inspect, err := service.GetDefaultByOrgId(0)
  880. if err != nil {
  881. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  882. return
  883. }
  884. this.ServeSuccessJSON(map[string]interface{}{
  885. "inspection": inspect,
  886. })
  887. } else {
  888. if err != nil {
  889. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  890. return
  891. }
  892. this.ServeSuccessJSON(map[string]interface{}{
  893. "inspection": inspection,
  894. })
  895. }
  896. }
  897. func (this *CommonApiController) GetPatientList() {
  898. adminUser := this.GetAdminUserInfo()
  899. orgid := adminUser.CurrentOrgId
  900. startime := this.GetString("startime")
  901. endtime := this.GetString("endtime")
  902. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  903. fmt.Println("parseDateErr", parseDateErr)
  904. statime := startDate.Unix()
  905. fmt.Println("开始时间", statime)
  906. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  907. // //entime := endDate.Unix()
  908. endTimeYMDHmsStr := endtime + " 23:59:59"
  909. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  910. entime := endDate.Unix()
  911. fmt.Println("结束日期", entime)
  912. limit, _ := this.GetInt64("limit")
  913. fmt.Println("limit", limit)
  914. page, _ := this.GetInt64("page")
  915. fmt.Println("page", page)
  916. patientInfo, total, err := service.GetPatientListData(orgid, statime, entime, limit, page)
  917. info, _ := service.GetPatientListInfo(orgid, statime, entime, limit, page)
  918. if err != nil {
  919. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  920. return
  921. }
  922. this.ServeSuccessJSON(map[string]interface{}{
  923. "patientInfo": patientInfo,
  924. "total": total,
  925. "list": info,
  926. })
  927. }
  928. func (this *CommonApiController) GetPatientDetailCheck() {
  929. adminUser := this.GetAdminUserInfo()
  930. orgid := adminUser.CurrentOrgId
  931. id, _ := this.GetInt64("id")
  932. startime := this.GetString("startime")
  933. endtime := this.GetString("endtime")
  934. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  935. fmt.Println("parseDateErr", parseDateErr)
  936. statime := startDate.Unix()
  937. fmt.Println("开始时间", statime)
  938. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  939. //entime := endDate.Unix()
  940. //fmt.Println("结束日期", entime)
  941. endTimeYMDHmsStr := endtime + " 23:59:59"
  942. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  943. entime := endDate.Unix()
  944. checkDetail, err := service.GetPatientDetailCheck(id, orgid, statime, entime)
  945. if err != nil {
  946. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  947. return
  948. }
  949. this.ServeSuccessJSON(map[string]interface{}{
  950. "checkDetail": checkDetail,
  951. })
  952. }
  953. func (this *CommonApiController) GetSearchDetailCheck() {
  954. adminUser := this.GetAdminUserInfo()
  955. orgid := adminUser.CurrentOrgId
  956. keyword := this.GetString("keyword")
  957. startime := this.GetString("startime")
  958. endtime := this.GetString("endtime")
  959. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  960. fmt.Println("parseDateErr", parseDateErr)
  961. statime := startDate.Unix()
  962. fmt.Println("开始时间", statime)
  963. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  964. entime := endDate.Unix()
  965. fmt.Println("结束日期", entime)
  966. checkDetail, err := service.GetSearchDetailCheck(orgid, keyword, statime, entime)
  967. if err != nil {
  968. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  969. return
  970. }
  971. this.ServeSuccessJSON(map[string]interface{}{
  972. "checkDetail": checkDetail,
  973. })
  974. }
  975. func (this *CommonApiController) GetNormData() {
  976. orgid := this.GetAdminUserInfo().CurrentOrgId
  977. //获取系统数据
  978. normdata, err := service.GetNormDataByOrgId(orgid)
  979. //获取血压数据
  980. bloodPressure, err := service.GetDefaultBloodPressure(orgid)
  981. if err != nil {
  982. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  983. return
  984. }
  985. this.ServeSuccessJSON(map[string]interface{}{
  986. "normdata": normdata,
  987. "bloodPressure": bloodPressure,
  988. })
  989. //if len(normdata) == 0 {
  990. // normdata, err := service.GetNormData(0)
  991. // if err != nil {
  992. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  993. // return
  994. // }
  995. // this.ServeSuccessJSON(map[string]interface{}{
  996. // "normdata": normdata,
  997. // })
  998. //} else {
  999. // normdata, err := service.GetNormDataByOrgId(orgid)
  1000. // if err != nil {
  1001. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1002. // return
  1003. // }
  1004. // this.ServeSuccessJSON(map[string]interface{}{
  1005. // "normdata": normdata,
  1006. // })
  1007. //}
  1008. }
  1009. func (this *CommonApiController) GetFirstQuarter() {
  1010. orgid := this.GetAdminUserInfo().CurrentOrgId
  1011. lapseto, _ := this.GetInt64("lapseto")
  1012. origin, _ := this.GetInt64("origin")
  1013. startime := this.GetString("startime")
  1014. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1015. fmt.Println("parseDateErr", parseDateErr)
  1016. statime := startDate.Unix()
  1017. endtime := this.GetString("endtime")
  1018. endTimeYMDHmsStr := endtime + " 23:59:59"
  1019. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  1020. entime := endDate.Unix()
  1021. //统计数值类型的数据
  1022. count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto, origin)
  1023. //统计rang_type== 2
  1024. countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto, origin)
  1025. //获取收缩压数据
  1026. systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressureTwo(orgid, statime, entime, lapseto, origin)
  1027. //统计收缩压合格的数据
  1028. //systolic, sysstandTotal, parseDateErr := service.GetStandSystolicBloodPressure(orgid, statime, entime)
  1029. //获取舒张压数据
  1030. diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressureTwo(orgid, statime, entime, lapseto, origin)
  1031. //获取合格舒张压数据
  1032. //diastolic, diasstandtotal, parseDateErr := service.GetDiastolicStandPressure(orgid, statime, entime)
  1033. normData, _ := service.GetNormData(orgid)
  1034. if err != nil {
  1035. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1036. return
  1037. }
  1038. this.ServeSuccessJSON(map[string]interface{}{
  1039. "count": count,
  1040. "countwo": countwo,
  1041. "systolic": systolic,
  1042. "systolicTotal": systolicTotal,
  1043. "diastolic": diastolic,
  1044. "diastotal": diastotal,
  1045. "normData": normData,
  1046. })
  1047. }
  1048. func (this *CommonApiController) GetProjectList() {
  1049. startime := this.GetString("startime")
  1050. fmt.Println("startime", startime)
  1051. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1052. fmt.Println("parseDateErr", parseDateErr)
  1053. statime := startDate.Unix()
  1054. fmt.Println("开始时间", statime)
  1055. endtime := this.GetString("endtime")
  1056. fmt.Println("endtime", endtime)
  1057. endTimeYMDHmsStr := endtime + " 23:59:59"
  1058. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  1059. entime := endDate.Unix()
  1060. adminInfo := this.GetAdminUserInfo()
  1061. orgid := adminInfo.CurrentOrgId
  1062. lapseto, _ := this.GetInt64("lapseto")
  1063. fmt.Println("lapseto", lapseto)
  1064. itemtype, _ := this.GetInt64("itemtype")
  1065. fmt.Println("type", itemtype)
  1066. modetype, _ := this.GetInt64("modetype")
  1067. fmt.Println("modetype", modetype)
  1068. firstQuarterStart := this.GetString("first_quarter_start")
  1069. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  1070. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  1071. fisrtQuarterEnd := this.GetString("first_qurter_end")
  1072. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  1073. fisrtQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  1074. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  1075. secondeQuarterStart := this.GetString("second_qurter_start")
  1076. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  1077. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  1078. secondQuarterEnd := this.GetString("second_qurter_end")
  1079. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  1080. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  1081. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  1082. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  1083. threeQuarterStart := this.GetString("three_qurter_start")
  1084. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  1085. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  1086. threeQuarterEnd := this.GetString("three_qurter_end")
  1087. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  1088. threeQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  1089. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  1090. fourQuarterStart := this.GetString("four_qurter_start")
  1091. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  1092. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  1093. fourQuarterEnd := this.GetString("four_qurter_end")
  1094. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  1095. fourQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  1096. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  1097. //fmt.Println("第四季度结束时间", fourQuarterEndStrUnix)
  1098. rangetype, parseDateErr := this.GetInt64("range_type")
  1099. //按季度统计
  1100. if rangetype == 1 {
  1101. //统计总共
  1102. list, err := service.GetProjectList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1103. //统计达标个数
  1104. standList, err := service.GetProjectStandList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1105. if err != nil {
  1106. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1107. return
  1108. }
  1109. this.ServeSuccessJSON(map[string]interface{}{
  1110. "list": list,
  1111. "standList": standList,
  1112. })
  1113. }
  1114. if rangetype == 2 {
  1115. list, err := service.GetProjectListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1116. //统计达标个数
  1117. standList, err := service.GetProjectStandListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1118. if err != nil {
  1119. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1120. return
  1121. }
  1122. this.ServeSuccessJSON(map[string]interface{}{
  1123. "list": list,
  1124. "standList": standList,
  1125. })
  1126. }
  1127. }
  1128. func (this *CommonApiController) GetMonthProjectList() {
  1129. adminUser := this.GetAdminUserInfo()
  1130. orgid := adminUser.CurrentOrgId
  1131. lapseto, _ := this.GetInt64("lapseto")
  1132. fmt.Println("lapseto", lapseto)
  1133. itemtype, _ := this.GetInt64("itemtype")
  1134. fmt.Println("itemtype", itemtype)
  1135. modetype, _ := this.GetInt64("modetype")
  1136. januaryStart := this.GetString("januaryStart")
  1137. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  1138. januaryStartStrUnix := januaryStartStr.Unix()
  1139. januaryEnd := this.GetString("januaryEnd")
  1140. januaryEndStr := januaryEnd + " 23:59:59"
  1141. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  1142. januaryEndStrUnix := januaryEndStrs.Unix()
  1143. febStart := this.GetString("febStart")
  1144. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  1145. febStartStrStrUnix := febStartStr.Unix()
  1146. febEnd := this.GetString("febEnd")
  1147. febEndStr := febEnd + " 23:59:59"
  1148. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  1149. febEndStrUnix := febEndStrs.Unix()
  1150. marchStart := this.GetString("marchStart")
  1151. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  1152. marchStartStrUnix := marchStartStr.Unix()
  1153. marchEnd := this.GetString("marchEnd")
  1154. marchEndStr := marchEnd + " 23:59:59"
  1155. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  1156. marchEndStrUnix := marchEndStrs.Unix()
  1157. aprStart := this.GetString("aprStart")
  1158. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  1159. aprStartStrUnix := aprStartStr.Unix()
  1160. aprEnd := this.GetString("aprEnd")
  1161. aprEndStr := aprEnd + " 23:59:59"
  1162. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  1163. aprEndStrsUnix := aprEndStrs.Unix()
  1164. mayStart := this.GetString("mayStart")
  1165. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1166. mayStartStrUnix := mayStartStr.Unix()
  1167. mayEnd := this.GetString("mayEnd")
  1168. mayEndStr := mayEnd + " 23:59:59"
  1169. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1170. mayEndStrsUnix := mayEndStrs.Unix()
  1171. junStart := this.GetString("junStart")
  1172. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1173. junStartStrUnix := junStartStr.Unix()
  1174. junEnd := this.GetString("junEnd")
  1175. junEndStr := junEnd + " 23:59:59"
  1176. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1177. junEndStrsUnix := junEndStrs.Unix()
  1178. julStart := this.GetString("julStart")
  1179. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1180. julStartStrUnix := julStartStr.Unix()
  1181. julEnd := this.GetString("julEnd")
  1182. julEndStr := julEnd + " 23:59:59"
  1183. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1184. julEndStrsUnix := julEndStrs.Unix()
  1185. augStart := this.GetString("augStart")
  1186. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1187. augStartStrUnix := augStartStr.Unix()
  1188. augEnd := this.GetString("augEnd")
  1189. augEndStr := augEnd + " 23:59:59"
  1190. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1191. augEndStrsUnix := augEndStrs.Unix()
  1192. sepStart := this.GetString("sepStart")
  1193. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1194. sepStartStrUnix := sepStartStr.Unix()
  1195. sepEnd := this.GetString("sepEnd")
  1196. sepEndStr := sepEnd + " 23:59:59"
  1197. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1198. sepEndStrsUnix := sepEndStrs.Unix()
  1199. octStart := this.GetString("octStart")
  1200. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1201. octStartStrUnix := octStartStr.Unix()
  1202. octEnd := this.GetString("octEnd")
  1203. octEndStr := octEnd + " 23:59:59"
  1204. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1205. octEndStrsUnix := octEndStrs.Unix()
  1206. novStart := this.GetString("novStart")
  1207. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1208. novStartStrUnix := novStartStr.Unix()
  1209. novEnd := this.GetString("novEnd")
  1210. novEndStr := novEnd + " 23:59:59"
  1211. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1212. novEndStrsUnix := novEndStrs.Unix()
  1213. decStart := this.GetString("decStart")
  1214. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1215. decStartStrUnix := decStartStr.Unix()
  1216. fmt.Println("12月使", decStartStrUnix)
  1217. decEnd := this.GetString("decEnd")
  1218. decEndStr := decEnd + " 23:59:59"
  1219. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1220. decEndStrsUnix := decEndStrs.Unix()
  1221. rangetype, _ := this.GetInt64("range_type")
  1222. if rangetype == 1 {
  1223. //统计总共
  1224. 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)
  1225. //统计不合格
  1226. 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)
  1227. fmt.Println("monthnolist", monthNolist)
  1228. if err != nil {
  1229. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1230. return
  1231. }
  1232. this.ServeSuccessJSON(map[string]interface{}{
  1233. "monthlist": monthlist,
  1234. "monthNolist": monthNolist,
  1235. })
  1236. }
  1237. if rangetype == 2 {
  1238. 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)
  1239. 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)
  1240. if err != nil {
  1241. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1242. return
  1243. }
  1244. this.ServeSuccessJSON(map[string]interface{}{
  1245. "monthlist": monthlist,
  1246. "monthNolist": monthNolist,
  1247. })
  1248. }
  1249. }
  1250. func (this *CommonApiController) GetPatientscontrol() {
  1251. adminUser := this.GetAdminUserInfo()
  1252. orgid := adminUser.CurrentOrgId
  1253. lapstor, _ := this.GetInt64("lapstor")
  1254. startime := this.GetString("startime")
  1255. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1256. startimeStrUnix := startimeStr.Unix()
  1257. endtime := this.GetString("endtime")
  1258. fmt.Println("结束时间", endtime)
  1259. endtimeStr := endtime + " 23:59:59"
  1260. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1261. endtimeStrsUnix := endtimeStrs.Unix()
  1262. page, _ := this.GetInt64("page")
  1263. limit, _ := this.GetInt64("limit")
  1264. patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1265. control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1266. infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1267. if err != nil {
  1268. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1269. return
  1270. }
  1271. this.ServeSuccessJSON(map[string]interface{}{
  1272. "patients": patients,
  1273. "total": total,
  1274. "control": control,
  1275. "infectiousControl": infectiousControl,
  1276. })
  1277. }
  1278. func (this *CommonApiController) GetCartogramList() {
  1279. adminUser := this.GetAdminUserInfo()
  1280. orgid := adminUser.CurrentOrgId
  1281. //fmt.Println("orgid", orgid)
  1282. lapstor, _ := this.GetInt64("lapstor")
  1283. fmt.Println("lapstor", lapstor)
  1284. startime := this.GetString("startime")
  1285. //fmt.Println("开始时间", startime)
  1286. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1287. startimeStrUnix := startimeStr.Unix()
  1288. //fmt.Println("时间搓", startimeStrUnix)
  1289. endtime := this.GetString("endtime")
  1290. //fmt.Println("结束时间", endtime)
  1291. endtimeStr := endtime + " 23:59:59"
  1292. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1293. endtimeStrsUnix := endtimeStrs.Unix()
  1294. //fmt.Println("结束时间搓", endtimeStrsUnix)
  1295. //limit, _ := this.GetInt64("limit")
  1296. //page, _ := this.GetInt64("page")
  1297. //统计总共
  1298. _, total, err := service.GetTotalPatientsControl(orgid, startimeStrUnix, endtimeStrsUnix)
  1299. //fmt.Println("total=================", total)
  1300. //统计rangetype= 1
  1301. _, standtotal, err := service.GetStandControl(orgid, startimeStrUnix, endtimeStrsUnix)
  1302. //fmt.Println(standtotal)
  1303. _, standtotalOne, err := service.GetStandControlOne(orgid, startimeStrUnix, endtimeStrsUnix)
  1304. //fmt.Println(standtotalOne)
  1305. //cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1306. //infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1307. //_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1308. if err != nil {
  1309. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1310. return
  1311. }
  1312. this.ServeSuccessJSON(map[string]interface{}{
  1313. "total": total,
  1314. "standtotal": standtotal,
  1315. "standtotalOne": standtotalOne,
  1316. })
  1317. }
  1318. func (this *CommonApiController) GetPatientContor() {
  1319. adminUser := this.GetAdminUserInfo()
  1320. orgid := adminUser.CurrentOrgId
  1321. fmt.Println(orgid)
  1322. lapstor, _ := this.GetInt64("lapstor")
  1323. fmt.Println("lapstor", lapstor)
  1324. patientid, _ := this.GetInt64("patientid")
  1325. startime := this.GetString("startime")
  1326. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1327. startimeStrUnix := startimeStr.Unix()
  1328. endtime := this.GetString("endtime")
  1329. //fmt.Println("结束时间", endtime)
  1330. endtimeStr := endtime + " 23:59:59"
  1331. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1332. endtimeStrsUnix := endtimeStrs.Unix()
  1333. patients, err := service.GetPatientNames(orgid, patientid)
  1334. patientcontorDetail, err := service.GetLastPatientsControlTwo(orgid, patientid, startimeStrUnix, endtimeStrsUnix)
  1335. if err != nil {
  1336. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1337. return
  1338. }
  1339. this.ServeSuccessJSON(map[string]interface{}{
  1340. "patientcontorDetail": patientcontorDetail,
  1341. "name": patients.Name,
  1342. })
  1343. }
  1344. func (this *CommonApiController) GetQualityControl() {
  1345. adminUser := this.GetAdminUserInfo()
  1346. orgid := adminUser.CurrentOrgId
  1347. fmt.Println(orgid)
  1348. patientid, _ := this.GetInt64("patientid")
  1349. startime, _ := this.GetInt64("startime")
  1350. //fmt.Println("startime", startime)
  1351. endtime, _ := this.GetInt64("endtime")
  1352. //fmt.Println("endtime", endtime)
  1353. itemid, _ := this.GetInt64("itemid")
  1354. //fmt.Println("itemid", itemid)
  1355. inspectdate, _ := this.GetInt64("inspectdate")
  1356. list, err := service.GetQualityControlById(orgid, patientid, startime, endtime, itemid, inspectdate)
  1357. if err != nil {
  1358. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1359. return
  1360. }
  1361. this.ServeSuccessJSON(map[string]interface{}{
  1362. "list": list,
  1363. })
  1364. }
  1365. func (this *CommonApiController) GetTreatlist() {
  1366. adminuser := this.GetAdminUserInfo()
  1367. orgId := adminuser.CurrentOrgId
  1368. startime := this.GetString("start_time")
  1369. endtime := this.GetString("end_time")
  1370. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1371. fmt.Println("parseDateErr", parseDateErr)
  1372. statime := startDate.Unix()
  1373. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  1374. entime := endDate.Unix()
  1375. value, _ := this.GetInt64("value")
  1376. fmt.Println("value", value)
  1377. list, err := service.GetTreatList(orgId, statime, entime, value)
  1378. if err != nil {
  1379. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1380. return
  1381. }
  1382. this.ServeSuccessJSON(map[string]interface{}{
  1383. "list": list,
  1384. })
  1385. }
  1386. func (this *CommonApiController) GetPatientComplianceDetail() {
  1387. adminUser := this.GetAdminUserInfo()
  1388. orgid := adminUser.CurrentOrgId
  1389. fmt.Println(orgid)
  1390. patientid, _ := this.GetInt64("patientid")
  1391. startime, _ := this.GetInt64("startime")
  1392. fmt.Println("startime", startime)
  1393. endtime, _ := this.GetInt64("endtime")
  1394. fmt.Println("endtime", endtime)
  1395. itemid, _ := this.GetInt64("itemid")
  1396. fmt.Println("itemid", itemid)
  1397. list, err := service.GetPatientComplianceDetail(orgid, patientid, startime, endtime, itemid)
  1398. if err != nil {
  1399. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1400. return
  1401. }
  1402. this.ServeSuccessJSON(map[string]interface{}{
  1403. "list": list,
  1404. })
  1405. }
  1406. func (this *CommonApiController) GetBloodPressureDetail() {
  1407. id, _ := this.GetInt64("id")
  1408. blooddetail, err := service.GetBloodPressureDetail(id)
  1409. if err != nil {
  1410. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1411. return
  1412. }
  1413. this.ServeSuccessJSON(map[string]interface{}{
  1414. "blooddetail": blooddetail,
  1415. })
  1416. }
  1417. func (this *CommonApiController) UpdateBloodPrussre() {
  1418. id, _ := this.GetInt64("id")
  1419. fmt.Println("id", id)
  1420. dataBody := make(map[string]interface{}, 0)
  1421. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1422. fmt.Println("err", err)
  1423. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  1424. fmt.Println("inspectionmajor", inspectionmajor)
  1425. inspectionminor := int64(dataBody["inspectionMinor"].(float64))
  1426. fmt.Println("inspectionminor", inspectionminor)
  1427. largerange := dataBody["large_range"].(string)
  1428. fmt.Println(largerange)
  1429. minrange := dataBody["min_range"].(string)
  1430. fmt.Print(minrange)
  1431. sort := int64(dataBody["sort"].(float64))
  1432. fmt.Print("sort", sort)
  1433. standard := models.XtQualityControlStandard{
  1434. InspectionMajor: inspectionmajor,
  1435. InspectionMinor: inspectionminor,
  1436. MinRange: minrange,
  1437. Sort: sort,
  1438. LargeRange: largerange,
  1439. }
  1440. err = service.UpdateBloodPressure(&standard, id)
  1441. if err != nil {
  1442. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1443. return
  1444. }
  1445. this.ServeSuccessJSON(map[string]interface{}{
  1446. "standard": standard,
  1447. })
  1448. }
  1449. func (this *CommonApiController) GetBloodPressureList() {
  1450. adminUser := this.GetAdminUserInfo()
  1451. orgId := adminUser.CurrentOrgId
  1452. bloodType, _ := this.GetInt64("bloodType")
  1453. fmt.Println(bloodType)
  1454. firstQuarterStart := this.GetString("first_quarter_start")
  1455. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  1456. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  1457. fmt.Println("第一季度", firstQuarterStartUnix)
  1458. fisrtQuarterEnd := this.GetString("first_qurter_end")
  1459. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  1460. fisrtQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  1461. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  1462. fmt.Println("fisrtQuarterEndStrUnix", fisrtQuarterEndStrUnix)
  1463. secondeQuarterStart := this.GetString("second_qurter_start")
  1464. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  1465. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  1466. fmt.Println("secondeQuarterStartUnix", secondeQuarterStartUnix)
  1467. secondQuarterEnd := this.GetString("second_qurter_end")
  1468. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  1469. secondQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  1470. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  1471. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  1472. threeQuarterStart := this.GetString("three_qurter_start")
  1473. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  1474. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  1475. fmt.Println("第三季度", threeQuarterStartUnix)
  1476. threeQuarterEnd := this.GetString("three_qurter_end")
  1477. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  1478. threeQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  1479. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  1480. fmt.Println("第三季度", threeQuarterEndStrUnix)
  1481. fourQuarterStart := this.GetString("four_qurter_start")
  1482. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  1483. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  1484. fmt.Println("第四季度", fourQuarterStartUnix)
  1485. fourQuarterEnd := this.GetString("four_qurter_end")
  1486. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  1487. fourQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  1488. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  1489. fmt.Println("第四季度", fourQuarterEndStrUnix)
  1490. if bloodType == -1 {
  1491. //统计收缩压第一季度的总数
  1492. firstList, firstTotal, err := service.GetSystolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1493. //统计收缩压第一季合格的总数
  1494. //_, firstStandTotal, err := service.GetStandSystolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1495. //统计第二季收缩压总数
  1496. secondelist, secondeTotal, err := service.GetSystolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1497. //第二季度合格总数
  1498. //_, secondeStandTotal, err := service.GetStandSystolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1499. //统计第三季收缩压总数
  1500. threelist, threeTotal, err := service.GetSystolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1501. //第三季度合格数
  1502. //_, threeStandTotal, err := service.GetStandSystolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1503. //第四季度总数
  1504. fourlist, fourTotal, err := service.GetSystolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1505. //第四季度合格总数
  1506. //_, fourStandTotal, err := service.GetStandSystolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1507. if err != nil {
  1508. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1509. return
  1510. }
  1511. this.ServeSuccessJSON(map[string]interface{}{
  1512. "firstTotal": firstTotal,
  1513. "firstList": firstList,
  1514. "secondelist": secondelist,
  1515. "secondeTotal": secondeTotal,
  1516. "threelist": threelist,
  1517. "threeTotal": threeTotal,
  1518. "fourTotal": fourTotal,
  1519. "fourlist": fourlist,
  1520. })
  1521. }
  1522. if bloodType == -2 {
  1523. //统计舒张压第一季度的总数
  1524. firstList, firstTotal, err := service.GetDiastolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1525. //_, firstStandTotal, err := service.GetDiastolicStandPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1526. secondelist, secondeTotal, err := service.GetDiastolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1527. //_, secondeStandTotal, err := service.GetDiastolicStandPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1528. threelist, threeTotal, err := service.GetDiastolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1529. //_, threeStandTotal, err := service.GetDiastolicStandPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1530. fourlist, fourTotal, err := service.GetDiastolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1531. //_, fourStandTotal, err := service.GetDiastolicStandPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1532. if err != nil {
  1533. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1534. return
  1535. }
  1536. this.ServeSuccessJSON(map[string]interface{}{
  1537. "firstTotal": firstTotal,
  1538. "firstList": firstList,
  1539. "secondelist": secondelist,
  1540. "secondeTotal": secondeTotal,
  1541. "threelist": threelist,
  1542. "threeTotal": threeTotal,
  1543. "fourTotal": fourTotal,
  1544. "fourlist": fourlist,
  1545. })
  1546. }
  1547. }
  1548. func (this *CommonApiController) GetMonthBloodList() {
  1549. bloodtype, _ := this.GetInt64("bloodType")
  1550. fmt.Println(bloodtype)
  1551. januaryStart := this.GetString("januaryStart")
  1552. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  1553. januaryStartStrUnix := januaryStartStr.Unix()
  1554. fmt.Println(januaryStartStrUnix)
  1555. januaryEnd := this.GetString("januaryEnd")
  1556. januaryEndStr := januaryEnd + " 23:59:59"
  1557. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  1558. januaryEndStrUnix := januaryEndStrs.Unix()
  1559. fmt.Println(januaryEndStrUnix)
  1560. febStart := this.GetString("febStart")
  1561. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  1562. febStartStrStrUnix := febStartStr.Unix()
  1563. fmt.Println(febStartStrStrUnix)
  1564. febEnd := this.GetString("febEnd")
  1565. febEndStr := febEnd + " 23:59:59"
  1566. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  1567. febEndStrUnix := febEndStrs.Unix()
  1568. fmt.Println(febEndStrUnix)
  1569. marchStart := this.GetString("marchStart")
  1570. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  1571. marchStartStrUnix := marchStartStr.Unix()
  1572. fmt.Println(marchStartStrUnix)
  1573. marchEnd := this.GetString("marchEnd")
  1574. marchEndStr := marchEnd + " 23:59:59"
  1575. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  1576. marchEndStrUnix := marchEndStrs.Unix()
  1577. fmt.Println(marchEndStrUnix)
  1578. aprStart := this.GetString("aprStart")
  1579. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  1580. aprStartStrUnix := aprStartStr.Unix()
  1581. fmt.Println(aprStartStrUnix)
  1582. aprEnd := this.GetString("aprEnd")
  1583. aprEndStr := aprEnd + " 23:59:59"
  1584. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  1585. aprEndStrsUnix := aprEndStrs.Unix()
  1586. fmt.Println(aprEndStrsUnix)
  1587. mayStart := this.GetString("mayStart")
  1588. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1589. mayStartStrUnix := mayStartStr.Unix()
  1590. fmt.Println(mayStartStrUnix)
  1591. mayEnd := this.GetString("mayEnd")
  1592. mayEndStr := mayEnd + " 23:59:59"
  1593. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1594. mayEndStrsUnix := mayEndStrs.Unix()
  1595. fmt.Println(mayEndStrsUnix)
  1596. junStart := this.GetString("junStart")
  1597. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1598. junStartStrUnix := junStartStr.Unix()
  1599. fmt.Println(junStartStrUnix)
  1600. junEnd := this.GetString("junEnd")
  1601. junEndStr := junEnd + " 23:59:59"
  1602. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1603. junEndStrsUnix := junEndStrs.Unix()
  1604. fmt.Println(junEndStrsUnix)
  1605. julStart := this.GetString("julStart")
  1606. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1607. julStartStrUnix := julStartStr.Unix()
  1608. fmt.Println(julStartStrUnix)
  1609. julEnd := this.GetString("julEnd")
  1610. julEndStr := julEnd + " 23:59:59"
  1611. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1612. julEndStrsUnix := julEndStrs.Unix()
  1613. fmt.Println(julEndStrsUnix)
  1614. augStart := this.GetString("augStart")
  1615. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1616. augStartStrUnix := augStartStr.Unix()
  1617. fmt.Print(augStartStrUnix)
  1618. augEnd := this.GetString("augEnd")
  1619. augEndStr := augEnd + " 23:59:59"
  1620. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1621. augEndStrsUnix := augEndStrs.Unix()
  1622. fmt.Println(augEndStrsUnix)
  1623. sepStart := this.GetString("sepStart")
  1624. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1625. sepStartStrUnix := sepStartStr.Unix()
  1626. fmt.Println(sepStartStrUnix)
  1627. sepEnd := this.GetString("sepEnd")
  1628. sepEndStr := sepEnd + " 23:59:59"
  1629. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1630. sepEndStrsUnix := sepEndStrs.Unix()
  1631. fmt.Println(sepEndStrsUnix)
  1632. octStart := this.GetString("octStart")
  1633. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1634. octStartStrUnix := octStartStr.Unix()
  1635. fmt.Println(octStartStrUnix)
  1636. octEnd := this.GetString("octEnd")
  1637. octEndStr := octEnd + " 23:59:59"
  1638. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1639. octEndStrsUnix := octEndStrs.Unix()
  1640. fmt.Println(octEndStrsUnix)
  1641. novStart := this.GetString("novStart")
  1642. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1643. novStartStrUnix := novStartStr.Unix()
  1644. fmt.Println(novStartStrUnix)
  1645. novEnd := this.GetString("novEnd")
  1646. novEndStr := novEnd + " 23:59:59"
  1647. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1648. novEndStrsUnix := novEndStrs.Unix()
  1649. fmt.Println(novEndStrsUnix)
  1650. decStart := this.GetString("decStart")
  1651. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1652. decStartStrUnix := decStartStr.Unix()
  1653. fmt.Println("12月使", decStartStrUnix)
  1654. decEnd := this.GetString("decEnd")
  1655. decEndStr := decEnd + " 23:59:59"
  1656. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1657. decEndStrsUnix := decEndStrs.Unix()
  1658. fmt.Println(decEndStrsUnix)
  1659. adminUser := this.GetAdminUserInfo()
  1660. orgId := adminUser.CurrentOrgId
  1661. //统计收缩压
  1662. if bloodtype == -1 {
  1663. //统计收缩压一月总数
  1664. januarylist, januaryTotal, err := service.GetSystolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1665. //_, januaryStandTotal, err := service.GetStandSystolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1666. //二月
  1667. feblist, febTotal, err := service.GetSystolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1668. //_, febStandTotal, err := service.GetStandSystolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1669. //三月
  1670. marchlist, marchTotal, err := service.GetSystolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1671. //_, marchStandTotal, err := service.GetStandSystolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1672. //四月
  1673. aprlist, aprTotal, err := service.GetSystolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1674. //_, aprStandTotal, err := service.GetStandSystolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1675. //五月
  1676. maylist, mayTotal, err := service.GetSystolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1677. //_, mayStandTotal, err := service.GetStandSystolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1678. //六月
  1679. junlist, junTotal, err := service.GetSystolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1680. //_, junStandTotal, err := service.GetStandSystolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1681. //7月
  1682. jullist, julTotal, err := service.GetSystolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1683. //_, julStandTotal, err := service.GetStandSystolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1684. //8月
  1685. auglist, augTotal, err := service.GetSystolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1686. //_, augStandTotal, err := service.GetStandSystolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1687. //9月
  1688. seplist, sepTotal, err := service.GetSystolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1689. //_, sepStandTotal, err := service.GetStandSystolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1690. //10月
  1691. octlist, octTotal, err := service.GetSystolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1692. //_, octStandTotal, err := service.GetStandSystolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1693. //11月
  1694. novlist, novTotal, err := service.GetSystolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1695. //_, novStandTotal, err := service.GetStandSystolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1696. //12月
  1697. declist, decTotal, err := service.GetSystolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1698. //_, decStandTotal, err := service.GetStandSystolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1699. if err != nil {
  1700. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1701. return
  1702. }
  1703. this.ServeSuccessJSON(map[string]interface{}{
  1704. "januaryTotal": januaryTotal,
  1705. "januarylist": januarylist,
  1706. "febTotal": febTotal,
  1707. "feblist": feblist,
  1708. "marchTotal": marchTotal,
  1709. "marchlist": marchlist,
  1710. "aprTotal": aprTotal,
  1711. "aprlist": aprlist,
  1712. "mayTotal": mayTotal,
  1713. "maylist": maylist,
  1714. "junTotal": junTotal,
  1715. "junlist": junlist,
  1716. "julTotal": julTotal,
  1717. "jullist": jullist,
  1718. "augTotal": augTotal,
  1719. "auglist": auglist,
  1720. "sepTotal": sepTotal,
  1721. "seplist": seplist,
  1722. "octTotal": octTotal,
  1723. "octlist": octlist,
  1724. "novTotal": novTotal,
  1725. "novlist": novlist,
  1726. "decTotal": decTotal,
  1727. "declist": declist,
  1728. })
  1729. }
  1730. //统计舒张压
  1731. if bloodtype == -2 {
  1732. //统计收缩压一月总数
  1733. januarylist, januaryTotal, err := service.GetDiastolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1734. //_, januaryStandTotal, err := service.GetDiastolicStandPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1735. //二月
  1736. feblist, febTotal, err := service.GetDiastolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1737. //_, febStandTotal, err := service.GetDiastolicStandPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1738. //三月
  1739. marchlist, marchTotal, err := service.GetDiastolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1740. //_, marchStandTotal, err := service.GetDiastolicStandPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1741. //四月
  1742. aprlist, aprTotal, err := service.GetDiastolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1743. //_, aprStandTotal, err := service.GetDiastolicStandPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1744. //五月
  1745. maylist, mayTotal, err := service.GetDiastolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1746. //_, mayStandTotal, err := service.GetDiastolicStandPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1747. //六月
  1748. junlist, junTotal, err := service.GetDiastolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1749. //_, junStandTotal, err := service.GetDiastolicStandPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1750. //7月
  1751. jullist, julTotal, err := service.GetDiastolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1752. //_, julStandTotal, err := service.GetDiastolicStandPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1753. //8月
  1754. auglist, augTotal, err := service.GetDiastolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1755. //_, augStandTotal, err := service.GetDiastolicStandPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1756. //9月
  1757. seplist, sepTotal, err := service.GetDiastolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1758. //_, sepStandTotal, err := service.GetDiastolicStandPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1759. //10月
  1760. octlist, octTotal, err := service.GetDiastolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1761. //_, octStandTotal, err := service.GetDiastolicStandPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1762. //11月
  1763. novlist, novTotal, err := service.GetDiastolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1764. //_, novStandTotal, err := service.GetDiastolicStandPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1765. //12月
  1766. declist, decTotal, err := service.GetDiastolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1767. //_, decStandTotal, err := service.GetDiastolicStandPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1768. if err != nil {
  1769. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1770. return
  1771. }
  1772. this.ServeSuccessJSON(map[string]interface{}{
  1773. "januaryTotal": januaryTotal,
  1774. "januarylist": januarylist,
  1775. "febTotal": febTotal,
  1776. "feblist": feblist,
  1777. "marchTotal": marchTotal,
  1778. "marchlist": marchlist,
  1779. "aprTotal": aprTotal,
  1780. "aprlist": aprlist,
  1781. "mayTotal": mayTotal,
  1782. "maylist": maylist,
  1783. "junTotal": junTotal,
  1784. "junlist": junlist,
  1785. "julTotal": julTotal,
  1786. "jullist": jullist,
  1787. "augTotal": augTotal,
  1788. "auglist": auglist,
  1789. "sepTotal": sepTotal,
  1790. "seplist": seplist,
  1791. "octTotal": octTotal,
  1792. "octlist": octlist,
  1793. "novTotal": novTotal,
  1794. "novlist": novlist,
  1795. "decTotal": decTotal,
  1796. "declist": declist,
  1797. })
  1798. }
  1799. }
  1800. func (this *CommonApiController) GetIdsListTwo() {
  1801. dataBody := make(map[string]interface{}, 0)
  1802. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1803. fmt.Println(err)
  1804. adminInfo := this.GetAdminUserInfo()
  1805. orgId := adminInfo.CurrentOrgId
  1806. patientid, _ := this.GetInt64("patientid")
  1807. idlist := dataBody["ids"].([]interface{})
  1808. var vlist []interface{}
  1809. for _, contagion := range idlist {
  1810. id := int64(contagion.(float64))
  1811. list, _ := service.GetInspectionMoninList(id, orgId, patientid)
  1812. vlist = append(vlist, list)
  1813. }
  1814. if err != nil {
  1815. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1816. return
  1817. }
  1818. this.ServeSuccessJSON(map[string]interface{}{
  1819. "vlist": vlist,
  1820. })
  1821. }
  1822. func (this *CommonApiController) GetTreatModeList() {
  1823. start_time, _ := this.GetInt64("start_time")
  1824. end_time, _ := this.GetInt64("end_time")
  1825. adminUserInfo := this.GetAdminUserInfo()
  1826. orgId := adminUserInfo.CurrentOrgId
  1827. list, err := service.GetTreatModeList(start_time, end_time, orgId)
  1828. if err != nil {
  1829. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1830. return
  1831. }
  1832. this.ServeSuccessJSON(map[string]interface{}{
  1833. "list": list,
  1834. })
  1835. }
  1836. func (this *CommonApiController) GetCountModeId() {
  1837. start_time, _ := this.GetInt64("start_time")
  1838. end_time, _ := this.GetInt64("end_time")
  1839. mode_id, _ := this.GetInt64("mode_id")
  1840. adminUserInfo := this.GetAdminUserInfo()
  1841. orgId := adminUserInfo.CurrentOrgId
  1842. fmt.Println("start_time", start_time)
  1843. fmt.Println("end_time", end_time)
  1844. fmt.Println("mode_id", mode_id)
  1845. modeCount, err := service.GetCountModeId(start_time, end_time, mode_id, orgId)
  1846. if err != nil {
  1847. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1848. return
  1849. }
  1850. this.ServeSuccessJSON(map[string]interface{}{
  1851. "modeCount": modeCount,
  1852. })
  1853. }
  1854. func (this *CommonApiController) GetRolloutCount() {
  1855. start_time, _ := this.GetInt64("start_time")
  1856. end_time, _ := this.GetInt64("end_time")
  1857. lapsetotype, _ := this.GetInt64("lapsetotype")
  1858. sourcetype, _ := this.GetInt64("sourcetype")
  1859. adminUserInfo := this.GetAdminUserInfo()
  1860. orgId := adminUserInfo.CurrentOrgId
  1861. //统计当前机构转出的人数
  1862. rollout, err := service.GetCountRollout(orgId, start_time, end_time, lapsetotype, sourcetype)
  1863. if err != nil {
  1864. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1865. return
  1866. }
  1867. this.ServeSuccessJSON(map[string]interface{}{
  1868. "rollout": rollout,
  1869. })
  1870. }
  1871. func (this *CommonApiController) GetCheckExamine() {
  1872. //check_type, _ := this.GetInt64("check_type")
  1873. //start_time, _ := this.GetInt64("start_time")
  1874. //end_time, _ := this.GetInt64("end_time")
  1875. //total, _ := service.GetAllPatientCount(this.GetAdminUserInfo().CurrentOrgId)
  1876. //xcg_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 1) //血常规
  1877. //xysh_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 2) //血液生化
  1878. //ipth_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 3) //全段甲状旁腺激素
  1879. //xqtdb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 4) //血清铁蛋白和转铁蛋白饱和度
  1880. //xqqbdb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 5) //血清前白蛋白
  1881. //cfydb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 6) //c反应蛋白
  1882. //
  1883. }