common_api_controller.go 75KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164
  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. if err != nil {
  675. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  676. return
  677. }
  678. this.ServeSuccessJSON(map[string]interface{}{
  679. "dialysislist": dialysislist,
  680. "total": total,
  681. "list": list,
  682. "totallist": totallist,
  683. "prescriptionList": prescriptionList,
  684. "count": count,
  685. "modeIdCount": modeIdCount,
  686. })
  687. }
  688. func (this *CommonApiController) GetLastSort() {
  689. adminUser := this.GetAdminUserInfo()
  690. orgid := adminUser.CurrentOrgId
  691. standard, err := service.GetLastSort(orgid)
  692. if err != nil {
  693. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  694. return
  695. }
  696. this.ServeSuccessJSON(map[string]interface{}{
  697. "standard": standard,
  698. })
  699. }
  700. func (this *CommonApiController) GetLastCheckList() {
  701. adminUser := this.GetAdminUserInfo()
  702. orgid := adminUser.CurrentOrgId
  703. checkList, err := service.GetLastCheckList(orgid)
  704. if err != nil {
  705. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  706. return
  707. }
  708. this.ServeSuccessJSON(map[string]interface{}{
  709. "checkList": checkList,
  710. })
  711. }
  712. func (this *CommonApiController) GetDialysisDetailById() {
  713. adminUser := this.GetAdminUserInfo()
  714. orgId := adminUser.CurrentOrgId
  715. id, _ := this.GetInt64("id")
  716. fmt.Println("id", id)
  717. startime := this.GetString("startime")
  718. fmt.Println(startime)
  719. endtime := this.GetString("endtime")
  720. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  721. fmt.Println("parseDateErr", parseDateErr)
  722. statime := startDate.Unix()
  723. fmt.Println("开始时间", statime)
  724. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  725. entime := endDate.Unix()
  726. fmt.Println("开始时间", statime)
  727. fmt.Println(endtime)
  728. limit, _ := this.GetInt64("limit")
  729. fmt.Println("limit", limit)
  730. page, _ := this.GetInt64("page")
  731. fmt.Println("page", page)
  732. patients, total, err := service.GetDialysisDetailById(id, orgId, statime, entime, limit, page)
  733. if err != nil {
  734. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  735. return
  736. }
  737. this.ServeSuccessJSON(map[string]interface{}{
  738. "patients": patients,
  739. "total": total,
  740. })
  741. }
  742. func (this *CommonApiController) GetPrescritionByName() {
  743. adminUser := this.GetAdminUserInfo()
  744. orgId := adminUser.CurrentOrgId
  745. patientid, _ := this.GetInt64("patientid")
  746. startime := this.GetString("startime")
  747. fmt.Println(startime)
  748. endtime := this.GetString("endtime")
  749. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  750. fmt.Println("parseDateErr", parseDateErr)
  751. statime := startDate.Unix()
  752. fmt.Println("开始时间", statime)
  753. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  754. entime := endDate.Unix()
  755. limit, _ := this.GetInt64("limit")
  756. page, _ := this.GetInt64("page")
  757. patient, total, err := service.GetPrescritionByName(orgId, patientid, statime, entime, limit, page)
  758. if err != nil {
  759. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  760. return
  761. }
  762. this.ServeSuccessJSON(map[string]interface{}{
  763. "patient": patient,
  764. "total": total,
  765. })
  766. }
  767. func (this *CommonApiController) GetStatistics() {
  768. adminUser := this.GetAdminUserInfo()
  769. orgId := adminUser.CurrentOrgId
  770. startime := this.GetString("start_time")
  771. endtime := this.GetString("end_time")
  772. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  773. fmt.Println("parseDateErr", parseDateErr)
  774. statime := startDate.Unix()
  775. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  776. entime := endDate.Unix()
  777. value, _ := this.GetInt64("value")
  778. limit, _ := this.GetInt64("limit")
  779. page, _ := this.GetInt64("page")
  780. modeId, _ := this.GetInt64("mode_id")
  781. treatinfo, total, err := service.GetTreateInfo(orgId, statime, entime, value, limit, page)
  782. statistics, ttd, _ := service.GetStatistics(orgId, statime, entime, modeId)
  783. if err != nil {
  784. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  785. return
  786. }
  787. this.ServeSuccessJSON(map[string]interface{}{
  788. "statistics": statistics,
  789. "ttd": ttd,
  790. "total": total,
  791. "treatinfo": treatinfo,
  792. })
  793. }
  794. func (this *CommonApiController) GetInspectionTatolCount() {
  795. adminUser := this.GetAdminUserInfo()
  796. orgid := adminUser.CurrentOrgId
  797. startime := this.GetString("startime")
  798. fmt.Println(startime)
  799. endtime := this.GetString("endtime")
  800. fmt.Print("endtime", endtime)
  801. patientid, _ := this.GetInt64("patientid")
  802. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  803. fmt.Println("parseDateErr", parseDateErr)
  804. statime := startDate.Unix()
  805. secondQuarterEndStr := endtime + " 23:59:59"
  806. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  807. entime := secondQuarterEnds.Unix()
  808. references, err := service.GetInspectionTotalCount(orgid)
  809. if err != nil {
  810. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  811. return
  812. }
  813. counts, err := service.GetInspectionProjectCount(orgid, statime, entime, patientid)
  814. this.ServeSuccessJSON(map[string]interface{}{
  815. "Inspection": references,
  816. "counts": counts,
  817. })
  818. }
  819. func (this *CommonApiController) GetInspectionDetailById() {
  820. adminUser := this.GetAdminUserInfo()
  821. orgId := adminUser.CurrentOrgId
  822. id, _ := this.GetInt64("id")
  823. fmt.Println("id", id)
  824. startime := this.GetString("startime")
  825. endtime := this.GetString("endtime")
  826. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  827. fmt.Println("parseDateErr", parseDateErr)
  828. statime := startDate.Unix()
  829. fmt.Println("开始时间", statime)
  830. secondQuarterEndStr := endtime + " 23:59:59"
  831. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  832. entime := secondQuarterEnds.Unix()
  833. patientdetail, err := service.GetInspectionDetailById(id, orgId, statime, entime)
  834. if err != nil {
  835. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  836. return
  837. }
  838. this.ServeSuccessJSON(map[string]interface{}{
  839. "patientdetail": patientdetail,
  840. })
  841. }
  842. func (this *CommonApiController) GetSearchPatientInfo() {
  843. adminUser := this.GetAdminUserInfo()
  844. orgId := adminUser.CurrentOrgId
  845. //keyword := this.GetString("keyword")
  846. //fmt.Println("keyword", keyword)
  847. patientid, _ := this.GetInt64("patientid")
  848. startime := this.GetString("startime")
  849. endtime := this.GetString("endtime")
  850. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  851. fmt.Println("parseDateErr", parseDateErr)
  852. statime := startDate.Unix()
  853. fmt.Println("开始时间", statime)
  854. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  855. //entime := endDate.Unix()
  856. //fmt.Println("结束日期", entime)
  857. secondQuarterEndStr := endtime + " 23:59:59"
  858. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  859. entime := secondQuarterEnds.Unix()
  860. PatientsInfo, err := service.GetSearchPatientInfo(orgId, patientid, statime, entime)
  861. if err != nil {
  862. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  863. return
  864. }
  865. this.ServeSuccessJSON(map[string]interface{}{
  866. "PatientsInfo": PatientsInfo,
  867. })
  868. }
  869. func (this *CommonApiController) GetAllMajorInspection() {
  870. adminUser := this.GetAdminUserInfo()
  871. orgid := adminUser.CurrentOrgId
  872. inspection, err := service.GetMajorInspectionByOrgid(orgid)
  873. if len(inspection) == 0 {
  874. inspect, err := service.GetDefaultByOrgId(0)
  875. if err != nil {
  876. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  877. return
  878. }
  879. this.ServeSuccessJSON(map[string]interface{}{
  880. "inspection": inspect,
  881. })
  882. } else {
  883. if err != nil {
  884. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  885. return
  886. }
  887. this.ServeSuccessJSON(map[string]interface{}{
  888. "inspection": inspection,
  889. })
  890. }
  891. }
  892. func (this *CommonApiController) GetPatientList() {
  893. adminUser := this.GetAdminUserInfo()
  894. orgid := adminUser.CurrentOrgId
  895. startime := this.GetString("startime")
  896. endtime := this.GetString("endtime")
  897. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  898. fmt.Println("parseDateErr", parseDateErr)
  899. statime := startDate.Unix()
  900. fmt.Println("开始时间", statime)
  901. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  902. // //entime := endDate.Unix()
  903. endTimeYMDHmsStr := endtime + " 23:59:59"
  904. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  905. entime := endDate.Unix()
  906. fmt.Println("结束日期", entime)
  907. limit, _ := this.GetInt64("limit")
  908. fmt.Println("limit", limit)
  909. page, _ := this.GetInt64("page")
  910. fmt.Println("page", page)
  911. patientInfo, total, err := service.GetPatientListData(orgid, statime, entime, limit, page)
  912. info, _ := service.GetPatientListInfo(orgid, statime, entime, limit, page)
  913. if err != nil {
  914. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  915. return
  916. }
  917. this.ServeSuccessJSON(map[string]interface{}{
  918. "patientInfo": patientInfo,
  919. "total": total,
  920. "list": info,
  921. })
  922. }
  923. func (this *CommonApiController) GetPatientDetailCheck() {
  924. adminUser := this.GetAdminUserInfo()
  925. orgid := adminUser.CurrentOrgId
  926. id, _ := this.GetInt64("id")
  927. startime := this.GetString("startime")
  928. endtime := this.GetString("endtime")
  929. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  930. fmt.Println("parseDateErr", parseDateErr)
  931. statime := startDate.Unix()
  932. fmt.Println("开始时间", statime)
  933. //endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  934. //entime := endDate.Unix()
  935. //fmt.Println("结束日期", entime)
  936. endTimeYMDHmsStr := endtime + " 23:59:59"
  937. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  938. entime := endDate.Unix()
  939. checkDetail, err := service.GetPatientDetailCheck(id, orgid, statime, entime)
  940. if err != nil {
  941. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  942. return
  943. }
  944. this.ServeSuccessJSON(map[string]interface{}{
  945. "checkDetail": checkDetail,
  946. })
  947. }
  948. func (this *CommonApiController) GetSearchDetailCheck() {
  949. adminUser := this.GetAdminUserInfo()
  950. orgid := adminUser.CurrentOrgId
  951. keyword := this.GetString("keyword")
  952. startime := this.GetString("startime")
  953. endtime := this.GetString("endtime")
  954. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  955. fmt.Println("parseDateErr", parseDateErr)
  956. statime := startDate.Unix()
  957. fmt.Println("开始时间", statime)
  958. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  959. entime := endDate.Unix()
  960. fmt.Println("结束日期", entime)
  961. checkDetail, err := service.GetSearchDetailCheck(orgid, keyword, statime, entime)
  962. if err != nil {
  963. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  964. return
  965. }
  966. this.ServeSuccessJSON(map[string]interface{}{
  967. "checkDetail": checkDetail,
  968. })
  969. }
  970. func (this *CommonApiController) GetNormData() {
  971. orgid := this.GetAdminUserInfo().CurrentOrgId
  972. //获取系统数据
  973. normdata, err := service.GetNormDataByOrgId(orgid)
  974. //获取血压数据
  975. bloodPressure, err := service.GetDefaultBloodPressure(orgid)
  976. if err != nil {
  977. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  978. return
  979. }
  980. this.ServeSuccessJSON(map[string]interface{}{
  981. "normdata": normdata,
  982. "bloodPressure": bloodPressure,
  983. })
  984. //if len(normdata) == 0 {
  985. // normdata, err := service.GetNormData(0)
  986. // if err != nil {
  987. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  988. // return
  989. // }
  990. // this.ServeSuccessJSON(map[string]interface{}{
  991. // "normdata": normdata,
  992. // })
  993. //} else {
  994. // normdata, err := service.GetNormDataByOrgId(orgid)
  995. // if err != nil {
  996. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  997. // return
  998. // }
  999. // this.ServeSuccessJSON(map[string]interface{}{
  1000. // "normdata": normdata,
  1001. // })
  1002. //}
  1003. }
  1004. func (this *CommonApiController) GetFirstQuarter() {
  1005. orgid := this.GetAdminUserInfo().CurrentOrgId
  1006. lapseto, _ := this.GetInt64("lapseto")
  1007. origin, _ := this.GetInt64("origin")
  1008. fmt.Println("转归", lapseto)
  1009. startime := this.GetString("startime")
  1010. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1011. fmt.Println("parseDateErr", parseDateErr)
  1012. statime := startDate.Unix()
  1013. endtime := this.GetString("endtime")
  1014. endTimeYMDHmsStr := endtime + " 23:59:59"
  1015. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  1016. entime := endDate.Unix()
  1017. fmt.Println("结束日期", entime)
  1018. //统计数值类型的数据
  1019. count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto, origin)
  1020. fmt.Println("countwowowowoowowowowoww", count)
  1021. //统计rang_type== 2
  1022. countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto, origin)
  1023. //获取收缩压数据
  1024. systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressureTwo(orgid, statime, entime, lapseto, origin)
  1025. //统计收缩压合格的数据
  1026. //systolic, sysstandTotal, parseDateErr := service.GetStandSystolicBloodPressure(orgid, statime, entime)
  1027. //获取舒张压数据
  1028. diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressureTwo(orgid, statime, entime, lapseto, origin)
  1029. //获取合格舒张压数据
  1030. //diastolic, diasstandtotal, parseDateErr := service.GetDiastolicStandPressure(orgid, statime, entime)
  1031. normData, _ := service.GetNormData(orgid)
  1032. if err != nil {
  1033. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1034. return
  1035. }
  1036. this.ServeSuccessJSON(map[string]interface{}{
  1037. "count": count,
  1038. "countwo": countwo,
  1039. "systolic": systolic,
  1040. "systolicTotal": systolicTotal,
  1041. "diastolic": diastolic,
  1042. "diastotal": diastotal,
  1043. "normData": normData,
  1044. })
  1045. }
  1046. func (this *CommonApiController) GetProjectList() {
  1047. startime := this.GetString("startime")
  1048. fmt.Println("startime", startime)
  1049. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1050. fmt.Println("parseDateErr", parseDateErr)
  1051. statime := startDate.Unix()
  1052. fmt.Println("开始时间", statime)
  1053. endtime := this.GetString("endtime")
  1054. fmt.Println("endtime", endtime)
  1055. endTimeYMDHmsStr := endtime + " 23:59:59"
  1056. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  1057. entime := endDate.Unix()
  1058. adminInfo := this.GetAdminUserInfo()
  1059. orgid := adminInfo.CurrentOrgId
  1060. lapseto, _ := this.GetInt64("lapseto")
  1061. fmt.Println("lapseto", lapseto)
  1062. itemtype, _ := this.GetInt64("itemtype")
  1063. fmt.Println("type", itemtype)
  1064. modetype, _ := this.GetInt64("modetype")
  1065. fmt.Println("modetype", modetype)
  1066. firstQuarterStart := this.GetString("first_quarter_start")
  1067. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  1068. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  1069. fisrtQuarterEnd := this.GetString("first_qurter_end")
  1070. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  1071. fisrtQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  1072. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  1073. secondeQuarterStart := this.GetString("second_qurter_start")
  1074. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  1075. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  1076. secondQuarterEnd := this.GetString("second_qurter_end")
  1077. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  1078. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  1079. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  1080. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  1081. threeQuarterStart := this.GetString("three_qurter_start")
  1082. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  1083. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  1084. threeQuarterEnd := this.GetString("three_qurter_end")
  1085. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  1086. threeQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  1087. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  1088. fourQuarterStart := this.GetString("four_qurter_start")
  1089. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  1090. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  1091. fourQuarterEnd := this.GetString("four_qurter_end")
  1092. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  1093. fourQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  1094. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  1095. //fmt.Println("第四季度结束时间", fourQuarterEndStrUnix)
  1096. rangetype, parseDateErr := this.GetInt64("range_type")
  1097. //按季度统计
  1098. if rangetype == 1 {
  1099. //统计总共
  1100. list, err := service.GetProjectList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1101. //统计达标个数
  1102. standList, err := service.GetProjectStandList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1103. if err != nil {
  1104. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1105. return
  1106. }
  1107. this.ServeSuccessJSON(map[string]interface{}{
  1108. "list": list,
  1109. "standList": standList,
  1110. })
  1111. }
  1112. if rangetype == 2 {
  1113. list, err := service.GetProjectListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1114. //统计达标个数
  1115. standList, err := service.GetProjectStandListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1116. if err != nil {
  1117. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1118. return
  1119. }
  1120. this.ServeSuccessJSON(map[string]interface{}{
  1121. "list": list,
  1122. "standList": standList,
  1123. })
  1124. }
  1125. }
  1126. func (this *CommonApiController) GetMonthProjectList() {
  1127. adminUser := this.GetAdminUserInfo()
  1128. orgid := adminUser.CurrentOrgId
  1129. lapseto, _ := this.GetInt64("lapseto")
  1130. fmt.Println("lapseto", lapseto)
  1131. itemtype, _ := this.GetInt64("itemtype")
  1132. fmt.Println("itemtype", itemtype)
  1133. modetype, _ := this.GetInt64("modetype")
  1134. januaryStart := this.GetString("januaryStart")
  1135. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  1136. januaryStartStrUnix := januaryStartStr.Unix()
  1137. januaryEnd := this.GetString("januaryEnd")
  1138. januaryEndStr := januaryEnd + " 23:59:59"
  1139. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  1140. januaryEndStrUnix := januaryEndStrs.Unix()
  1141. febStart := this.GetString("febStart")
  1142. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  1143. febStartStrStrUnix := febStartStr.Unix()
  1144. febEnd := this.GetString("febEnd")
  1145. febEndStr := febEnd + " 23:59:59"
  1146. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  1147. febEndStrUnix := febEndStrs.Unix()
  1148. marchStart := this.GetString("marchStart")
  1149. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  1150. marchStartStrUnix := marchStartStr.Unix()
  1151. marchEnd := this.GetString("marchEnd")
  1152. marchEndStr := marchEnd + " 23:59:59"
  1153. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  1154. marchEndStrUnix := marchEndStrs.Unix()
  1155. aprStart := this.GetString("aprStart")
  1156. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  1157. aprStartStrUnix := aprStartStr.Unix()
  1158. aprEnd := this.GetString("aprEnd")
  1159. aprEndStr := aprEnd + " 23:59:59"
  1160. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  1161. aprEndStrsUnix := aprEndStrs.Unix()
  1162. mayStart := this.GetString("mayStart")
  1163. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1164. mayStartStrUnix := mayStartStr.Unix()
  1165. mayEnd := this.GetString("mayEnd")
  1166. mayEndStr := mayEnd + " 23:59:59"
  1167. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1168. mayEndStrsUnix := mayEndStrs.Unix()
  1169. junStart := this.GetString("junStart")
  1170. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1171. junStartStrUnix := junStartStr.Unix()
  1172. junEnd := this.GetString("junEnd")
  1173. junEndStr := junEnd + " 23:59:59"
  1174. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1175. junEndStrsUnix := junEndStrs.Unix()
  1176. julStart := this.GetString("julStart")
  1177. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1178. julStartStrUnix := julStartStr.Unix()
  1179. julEnd := this.GetString("julEnd")
  1180. julEndStr := julEnd + " 23:59:59"
  1181. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1182. julEndStrsUnix := julEndStrs.Unix()
  1183. augStart := this.GetString("augStart")
  1184. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1185. augStartStrUnix := augStartStr.Unix()
  1186. augEnd := this.GetString("augEnd")
  1187. augEndStr := augEnd + " 23:59:59"
  1188. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1189. augEndStrsUnix := augEndStrs.Unix()
  1190. sepStart := this.GetString("sepStart")
  1191. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1192. sepStartStrUnix := sepStartStr.Unix()
  1193. sepEnd := this.GetString("sepEnd")
  1194. sepEndStr := sepEnd + " 23:59:59"
  1195. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1196. sepEndStrsUnix := sepEndStrs.Unix()
  1197. octStart := this.GetString("octStart")
  1198. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1199. octStartStrUnix := octStartStr.Unix()
  1200. octEnd := this.GetString("octEnd")
  1201. octEndStr := octEnd + " 23:59:59"
  1202. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1203. octEndStrsUnix := octEndStrs.Unix()
  1204. novStart := this.GetString("novStart")
  1205. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1206. novStartStrUnix := novStartStr.Unix()
  1207. novEnd := this.GetString("novEnd")
  1208. novEndStr := novEnd + " 23:59:59"
  1209. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1210. novEndStrsUnix := novEndStrs.Unix()
  1211. decStart := this.GetString("decStart")
  1212. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1213. decStartStrUnix := decStartStr.Unix()
  1214. fmt.Println("12月使", decStartStrUnix)
  1215. decEnd := this.GetString("decEnd")
  1216. decEndStr := decEnd + " 23:59:59"
  1217. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1218. decEndStrsUnix := decEndStrs.Unix()
  1219. rangetype, _ := this.GetInt64("range_type")
  1220. if rangetype == 1 {
  1221. //统计总共
  1222. 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)
  1223. //统计不合格
  1224. 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)
  1225. fmt.Println("monthnolist", monthNolist)
  1226. if err != nil {
  1227. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1228. return
  1229. }
  1230. this.ServeSuccessJSON(map[string]interface{}{
  1231. "monthlist": monthlist,
  1232. "monthNolist": monthNolist,
  1233. })
  1234. }
  1235. if rangetype == 2 {
  1236. 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)
  1237. 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)
  1238. if err != nil {
  1239. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1240. return
  1241. }
  1242. this.ServeSuccessJSON(map[string]interface{}{
  1243. "monthlist": monthlist,
  1244. "monthNolist": monthNolist,
  1245. })
  1246. }
  1247. }
  1248. func (this *CommonApiController) GetPatientscontrol() {
  1249. adminUser := this.GetAdminUserInfo()
  1250. orgid := adminUser.CurrentOrgId
  1251. lapstor, _ := this.GetInt64("lapstor")
  1252. startime := this.GetString("startime")
  1253. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1254. startimeStrUnix := startimeStr.Unix()
  1255. endtime := this.GetString("endtime")
  1256. fmt.Println("结束时间", endtime)
  1257. endtimeStr := endtime + " 23:59:59"
  1258. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1259. endtimeStrsUnix := endtimeStrs.Unix()
  1260. page, _ := this.GetInt64("page")
  1261. limit, _ := this.GetInt64("limit")
  1262. patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1263. control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1264. infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1265. if err != nil {
  1266. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1267. return
  1268. }
  1269. this.ServeSuccessJSON(map[string]interface{}{
  1270. "patients": patients,
  1271. "total": total,
  1272. "control": control,
  1273. "infectiousControl": infectiousControl,
  1274. })
  1275. }
  1276. func (this *CommonApiController) GetCartogramList() {
  1277. adminUser := this.GetAdminUserInfo()
  1278. orgid := adminUser.CurrentOrgId
  1279. //fmt.Println("orgid", orgid)
  1280. lapstor, _ := this.GetInt64("lapstor")
  1281. fmt.Println("lapstor", lapstor)
  1282. startime := this.GetString("startime")
  1283. //fmt.Println("开始时间", startime)
  1284. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1285. startimeStrUnix := startimeStr.Unix()
  1286. //fmt.Println("时间搓", startimeStrUnix)
  1287. endtime := this.GetString("endtime")
  1288. //fmt.Println("结束时间", endtime)
  1289. endtimeStr := endtime + " 23:59:59"
  1290. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1291. endtimeStrsUnix := endtimeStrs.Unix()
  1292. //fmt.Println("结束时间搓", endtimeStrsUnix)
  1293. //limit, _ := this.GetInt64("limit")
  1294. //page, _ := this.GetInt64("page")
  1295. //统计总共
  1296. _, total, err := service.GetTotalPatientsControl(orgid, startimeStrUnix, endtimeStrsUnix)
  1297. //fmt.Println("total=================", total)
  1298. //统计rangetype= 1
  1299. _, standtotal, err := service.GetStandControl(orgid, startimeStrUnix, endtimeStrsUnix)
  1300. //fmt.Println(standtotal)
  1301. _, standtotalOne, err := service.GetStandControlOne(orgid, startimeStrUnix, endtimeStrsUnix)
  1302. //fmt.Println(standtotalOne)
  1303. //cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1304. //infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1305. //_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1306. if err != nil {
  1307. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1308. return
  1309. }
  1310. this.ServeSuccessJSON(map[string]interface{}{
  1311. "total": total,
  1312. "standtotal": standtotal,
  1313. "standtotalOne": standtotalOne,
  1314. })
  1315. }
  1316. func (this *CommonApiController) GetPatientContor() {
  1317. adminUser := this.GetAdminUserInfo()
  1318. orgid := adminUser.CurrentOrgId
  1319. fmt.Println(orgid)
  1320. lapstor, _ := this.GetInt64("lapstor")
  1321. fmt.Println("lapstor", lapstor)
  1322. patientid, _ := this.GetInt64("patientid")
  1323. startime := this.GetString("startime")
  1324. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1325. startimeStrUnix := startimeStr.Unix()
  1326. endtime := this.GetString("endtime")
  1327. //fmt.Println("结束时间", endtime)
  1328. endtimeStr := endtime + " 23:59:59"
  1329. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1330. endtimeStrsUnix := endtimeStrs.Unix()
  1331. patients, err := service.GetPatientNames(orgid, patientid)
  1332. patientcontorDetail, err := service.GetLastPatientsControlTwo(orgid, patientid, startimeStrUnix, endtimeStrsUnix)
  1333. if err != nil {
  1334. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1335. return
  1336. }
  1337. this.ServeSuccessJSON(map[string]interface{}{
  1338. "patientcontorDetail": patientcontorDetail,
  1339. "name": patients.Name,
  1340. })
  1341. }
  1342. func (this *CommonApiController) GetQualityControl() {
  1343. adminUser := this.GetAdminUserInfo()
  1344. orgid := adminUser.CurrentOrgId
  1345. fmt.Println(orgid)
  1346. patientid, _ := this.GetInt64("patientid")
  1347. startime, _ := this.GetInt64("startime")
  1348. //fmt.Println("startime", startime)
  1349. endtime, _ := this.GetInt64("endtime")
  1350. //fmt.Println("endtime", endtime)
  1351. itemid, _ := this.GetInt64("itemid")
  1352. //fmt.Println("itemid", itemid)
  1353. inspectdate, _ := this.GetInt64("inspectdate")
  1354. list, err := service.GetQualityControlById(orgid, patientid, startime, endtime, itemid, inspectdate)
  1355. if err != nil {
  1356. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1357. return
  1358. }
  1359. this.ServeSuccessJSON(map[string]interface{}{
  1360. "list": list,
  1361. })
  1362. }
  1363. func (this *CommonApiController) GetTreatlist() {
  1364. adminuser := this.GetAdminUserInfo()
  1365. orgId := adminuser.CurrentOrgId
  1366. startime := this.GetString("start_time")
  1367. endtime := this.GetString("end_time")
  1368. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1369. fmt.Println("parseDateErr", parseDateErr)
  1370. statime := startDate.Unix()
  1371. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  1372. entime := endDate.Unix()
  1373. value, _ := this.GetInt64("value")
  1374. fmt.Println("value", value)
  1375. list, err := service.GetTreatList(orgId, statime, entime, value)
  1376. if err != nil {
  1377. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1378. return
  1379. }
  1380. this.ServeSuccessJSON(map[string]interface{}{
  1381. "list": list,
  1382. })
  1383. }
  1384. func (this *CommonApiController) GetPatientComplianceDetail() {
  1385. adminUser := this.GetAdminUserInfo()
  1386. orgid := adminUser.CurrentOrgId
  1387. fmt.Println(orgid)
  1388. patientid, _ := this.GetInt64("patientid")
  1389. startime, _ := this.GetInt64("startime")
  1390. fmt.Println("startime", startime)
  1391. endtime, _ := this.GetInt64("endtime")
  1392. fmt.Println("endtime", endtime)
  1393. itemid, _ := this.GetInt64("itemid")
  1394. fmt.Println("itemid", itemid)
  1395. list, err := service.GetPatientComplianceDetail(orgid, patientid, startime, endtime, itemid)
  1396. if err != nil {
  1397. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1398. return
  1399. }
  1400. this.ServeSuccessJSON(map[string]interface{}{
  1401. "list": list,
  1402. })
  1403. }
  1404. func (this *CommonApiController) GetBloodPressureDetail() {
  1405. id, _ := this.GetInt64("id")
  1406. blooddetail, err := service.GetBloodPressureDetail(id)
  1407. if err != nil {
  1408. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1409. return
  1410. }
  1411. this.ServeSuccessJSON(map[string]interface{}{
  1412. "blooddetail": blooddetail,
  1413. })
  1414. }
  1415. func (this *CommonApiController) UpdateBloodPrussre() {
  1416. id, _ := this.GetInt64("id")
  1417. fmt.Println("id", id)
  1418. dataBody := make(map[string]interface{}, 0)
  1419. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1420. fmt.Println("err", err)
  1421. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  1422. fmt.Println("inspectionmajor", inspectionmajor)
  1423. inspectionminor := int64(dataBody["inspectionMinor"].(float64))
  1424. fmt.Println("inspectionminor", inspectionminor)
  1425. largerange := dataBody["large_range"].(string)
  1426. fmt.Println(largerange)
  1427. minrange := dataBody["min_range"].(string)
  1428. fmt.Print(minrange)
  1429. sort := int64(dataBody["sort"].(float64))
  1430. fmt.Print("sort", sort)
  1431. standard := models.XtQualityControlStandard{
  1432. InspectionMajor: inspectionmajor,
  1433. InspectionMinor: inspectionminor,
  1434. MinRange: minrange,
  1435. Sort: sort,
  1436. LargeRange: largerange,
  1437. }
  1438. err = service.UpdateBloodPressure(&standard, id)
  1439. if err != nil {
  1440. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1441. return
  1442. }
  1443. this.ServeSuccessJSON(map[string]interface{}{
  1444. "standard": standard,
  1445. })
  1446. }
  1447. func (this *CommonApiController) GetBloodPressureList() {
  1448. adminUser := this.GetAdminUserInfo()
  1449. orgId := adminUser.CurrentOrgId
  1450. bloodType, _ := this.GetInt64("bloodType")
  1451. fmt.Println(bloodType)
  1452. firstQuarterStart := this.GetString("first_quarter_start")
  1453. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  1454. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  1455. fmt.Println("第一季度", firstQuarterStartUnix)
  1456. fisrtQuarterEnd := this.GetString("first_qurter_end")
  1457. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  1458. fisrtQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  1459. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  1460. fmt.Println("fisrtQuarterEndStrUnix", fisrtQuarterEndStrUnix)
  1461. secondeQuarterStart := this.GetString("second_qurter_start")
  1462. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  1463. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  1464. fmt.Println("secondeQuarterStartUnix", secondeQuarterStartUnix)
  1465. secondQuarterEnd := this.GetString("second_qurter_end")
  1466. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  1467. secondQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  1468. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  1469. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  1470. threeQuarterStart := this.GetString("three_qurter_start")
  1471. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  1472. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  1473. fmt.Println("第三季度", threeQuarterStartUnix)
  1474. threeQuarterEnd := this.GetString("three_qurter_end")
  1475. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  1476. threeQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  1477. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  1478. fmt.Println("第三季度", threeQuarterEndStrUnix)
  1479. fourQuarterStart := this.GetString("four_qurter_start")
  1480. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  1481. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  1482. fmt.Println("第四季度", fourQuarterStartUnix)
  1483. fourQuarterEnd := this.GetString("four_qurter_end")
  1484. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  1485. fourQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  1486. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  1487. fmt.Println("第四季度", fourQuarterEndStrUnix)
  1488. if bloodType == -1 {
  1489. //统计收缩压第一季度的总数
  1490. firstList, firstTotal, err := service.GetSystolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1491. //统计收缩压第一季合格的总数
  1492. //_, firstStandTotal, err := service.GetStandSystolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1493. //统计第二季收缩压总数
  1494. secondelist, secondeTotal, err := service.GetSystolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1495. //第二季度合格总数
  1496. //_, secondeStandTotal, err := service.GetStandSystolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1497. //统计第三季收缩压总数
  1498. threelist, threeTotal, err := service.GetSystolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1499. //第三季度合格数
  1500. //_, threeStandTotal, err := service.GetStandSystolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1501. //第四季度总数
  1502. fourlist, fourTotal, err := service.GetSystolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1503. //第四季度合格总数
  1504. //_, fourStandTotal, err := service.GetStandSystolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1505. if err != nil {
  1506. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1507. return
  1508. }
  1509. this.ServeSuccessJSON(map[string]interface{}{
  1510. "firstTotal": firstTotal,
  1511. "firstList": firstList,
  1512. "secondelist": secondelist,
  1513. "secondeTotal": secondeTotal,
  1514. "threelist": threelist,
  1515. "threeTotal": threeTotal,
  1516. "fourTotal": fourTotal,
  1517. "fourlist": fourlist,
  1518. })
  1519. }
  1520. if bloodType == -2 {
  1521. //统计舒张压第一季度的总数
  1522. firstList, firstTotal, err := service.GetDiastolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1523. //_, firstStandTotal, err := service.GetDiastolicStandPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1524. secondelist, secondeTotal, err := service.GetDiastolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1525. //_, secondeStandTotal, err := service.GetDiastolicStandPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1526. threelist, threeTotal, err := service.GetDiastolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1527. //_, threeStandTotal, err := service.GetDiastolicStandPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1528. fourlist, fourTotal, err := service.GetDiastolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1529. //_, fourStandTotal, err := service.GetDiastolicStandPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1530. if err != nil {
  1531. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1532. return
  1533. }
  1534. this.ServeSuccessJSON(map[string]interface{}{
  1535. "firstTotal": firstTotal,
  1536. "firstList": firstList,
  1537. "secondelist": secondelist,
  1538. "secondeTotal": secondeTotal,
  1539. "threelist": threelist,
  1540. "threeTotal": threeTotal,
  1541. "fourTotal": fourTotal,
  1542. "fourlist": fourlist,
  1543. })
  1544. }
  1545. }
  1546. func (this *CommonApiController) GetMonthBloodList() {
  1547. bloodtype, _ := this.GetInt64("bloodType")
  1548. fmt.Println(bloodtype)
  1549. januaryStart := this.GetString("januaryStart")
  1550. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  1551. januaryStartStrUnix := januaryStartStr.Unix()
  1552. fmt.Println(januaryStartStrUnix)
  1553. januaryEnd := this.GetString("januaryEnd")
  1554. januaryEndStr := januaryEnd + " 23:59:59"
  1555. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  1556. januaryEndStrUnix := januaryEndStrs.Unix()
  1557. fmt.Println(januaryEndStrUnix)
  1558. febStart := this.GetString("febStart")
  1559. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  1560. febStartStrStrUnix := febStartStr.Unix()
  1561. fmt.Println(febStartStrStrUnix)
  1562. febEnd := this.GetString("febEnd")
  1563. febEndStr := febEnd + " 23:59:59"
  1564. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  1565. febEndStrUnix := febEndStrs.Unix()
  1566. fmt.Println(febEndStrUnix)
  1567. marchStart := this.GetString("marchStart")
  1568. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  1569. marchStartStrUnix := marchStartStr.Unix()
  1570. fmt.Println(marchStartStrUnix)
  1571. marchEnd := this.GetString("marchEnd")
  1572. marchEndStr := marchEnd + " 23:59:59"
  1573. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  1574. marchEndStrUnix := marchEndStrs.Unix()
  1575. fmt.Println(marchEndStrUnix)
  1576. aprStart := this.GetString("aprStart")
  1577. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  1578. aprStartStrUnix := aprStartStr.Unix()
  1579. fmt.Println(aprStartStrUnix)
  1580. aprEnd := this.GetString("aprEnd")
  1581. aprEndStr := aprEnd + " 23:59:59"
  1582. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  1583. aprEndStrsUnix := aprEndStrs.Unix()
  1584. fmt.Println(aprEndStrsUnix)
  1585. mayStart := this.GetString("mayStart")
  1586. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1587. mayStartStrUnix := mayStartStr.Unix()
  1588. fmt.Println(mayStartStrUnix)
  1589. mayEnd := this.GetString("mayEnd")
  1590. mayEndStr := mayEnd + " 23:59:59"
  1591. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1592. mayEndStrsUnix := mayEndStrs.Unix()
  1593. fmt.Println(mayEndStrsUnix)
  1594. junStart := this.GetString("junStart")
  1595. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1596. junStartStrUnix := junStartStr.Unix()
  1597. fmt.Println(junStartStrUnix)
  1598. junEnd := this.GetString("junEnd")
  1599. junEndStr := junEnd + " 23:59:59"
  1600. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1601. junEndStrsUnix := junEndStrs.Unix()
  1602. fmt.Println(junEndStrsUnix)
  1603. julStart := this.GetString("julStart")
  1604. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1605. julStartStrUnix := julStartStr.Unix()
  1606. fmt.Println(julStartStrUnix)
  1607. julEnd := this.GetString("julEnd")
  1608. julEndStr := julEnd + " 23:59:59"
  1609. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1610. julEndStrsUnix := julEndStrs.Unix()
  1611. fmt.Println(julEndStrsUnix)
  1612. augStart := this.GetString("augStart")
  1613. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1614. augStartStrUnix := augStartStr.Unix()
  1615. fmt.Print(augStartStrUnix)
  1616. augEnd := this.GetString("augEnd")
  1617. augEndStr := augEnd + " 23:59:59"
  1618. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1619. augEndStrsUnix := augEndStrs.Unix()
  1620. fmt.Println(augEndStrsUnix)
  1621. sepStart := this.GetString("sepStart")
  1622. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1623. sepStartStrUnix := sepStartStr.Unix()
  1624. fmt.Println(sepStartStrUnix)
  1625. sepEnd := this.GetString("sepEnd")
  1626. sepEndStr := sepEnd + " 23:59:59"
  1627. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1628. sepEndStrsUnix := sepEndStrs.Unix()
  1629. fmt.Println(sepEndStrsUnix)
  1630. octStart := this.GetString("octStart")
  1631. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1632. octStartStrUnix := octStartStr.Unix()
  1633. fmt.Println(octStartStrUnix)
  1634. octEnd := this.GetString("octEnd")
  1635. octEndStr := octEnd + " 23:59:59"
  1636. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1637. octEndStrsUnix := octEndStrs.Unix()
  1638. fmt.Println(octEndStrsUnix)
  1639. novStart := this.GetString("novStart")
  1640. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1641. novStartStrUnix := novStartStr.Unix()
  1642. fmt.Println(novStartStrUnix)
  1643. novEnd := this.GetString("novEnd")
  1644. novEndStr := novEnd + " 23:59:59"
  1645. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1646. novEndStrsUnix := novEndStrs.Unix()
  1647. fmt.Println(novEndStrsUnix)
  1648. decStart := this.GetString("decStart")
  1649. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1650. decStartStrUnix := decStartStr.Unix()
  1651. fmt.Println("12月使", decStartStrUnix)
  1652. decEnd := this.GetString("decEnd")
  1653. decEndStr := decEnd + " 23:59:59"
  1654. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1655. decEndStrsUnix := decEndStrs.Unix()
  1656. fmt.Println(decEndStrsUnix)
  1657. adminUser := this.GetAdminUserInfo()
  1658. orgId := adminUser.CurrentOrgId
  1659. //统计收缩压
  1660. if bloodtype == -1 {
  1661. //统计收缩压一月总数
  1662. januarylist, januaryTotal, err := service.GetSystolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1663. //_, januaryStandTotal, err := service.GetStandSystolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1664. //二月
  1665. feblist, febTotal, err := service.GetSystolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1666. //_, febStandTotal, err := service.GetStandSystolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1667. //三月
  1668. marchlist, marchTotal, err := service.GetSystolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1669. //_, marchStandTotal, err := service.GetStandSystolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1670. //四月
  1671. aprlist, aprTotal, err := service.GetSystolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1672. //_, aprStandTotal, err := service.GetStandSystolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1673. //五月
  1674. maylist, mayTotal, err := service.GetSystolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1675. //_, mayStandTotal, err := service.GetStandSystolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1676. //六月
  1677. junlist, junTotal, err := service.GetSystolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1678. //_, junStandTotal, err := service.GetStandSystolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1679. //7月
  1680. jullist, julTotal, err := service.GetSystolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1681. //_, julStandTotal, err := service.GetStandSystolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1682. //8月
  1683. auglist, augTotal, err := service.GetSystolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1684. //_, augStandTotal, err := service.GetStandSystolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1685. //9月
  1686. seplist, sepTotal, err := service.GetSystolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1687. //_, sepStandTotal, err := service.GetStandSystolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1688. //10月
  1689. octlist, octTotal, err := service.GetSystolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1690. //_, octStandTotal, err := service.GetStandSystolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1691. //11月
  1692. novlist, novTotal, err := service.GetSystolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1693. //_, novStandTotal, err := service.GetStandSystolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1694. //12月
  1695. declist, decTotal, err := service.GetSystolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1696. //_, decStandTotal, err := service.GetStandSystolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1697. if err != nil {
  1698. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1699. return
  1700. }
  1701. this.ServeSuccessJSON(map[string]interface{}{
  1702. "januaryTotal": januaryTotal,
  1703. "januarylist": januarylist,
  1704. "febTotal": febTotal,
  1705. "feblist": feblist,
  1706. "marchTotal": marchTotal,
  1707. "marchlist": marchlist,
  1708. "aprTotal": aprTotal,
  1709. "aprlist": aprlist,
  1710. "mayTotal": mayTotal,
  1711. "maylist": maylist,
  1712. "junTotal": junTotal,
  1713. "junlist": junlist,
  1714. "julTotal": julTotal,
  1715. "jullist": jullist,
  1716. "augTotal": augTotal,
  1717. "auglist": auglist,
  1718. "sepTotal": sepTotal,
  1719. "seplist": seplist,
  1720. "octTotal": octTotal,
  1721. "octlist": octlist,
  1722. "novTotal": novTotal,
  1723. "novlist": novlist,
  1724. "decTotal": decTotal,
  1725. "declist": declist,
  1726. })
  1727. }
  1728. //统计舒张压
  1729. if bloodtype == -2 {
  1730. //统计收缩压一月总数
  1731. januarylist, januaryTotal, err := service.GetDiastolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1732. //_, januaryStandTotal, err := service.GetDiastolicStandPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1733. //二月
  1734. feblist, febTotal, err := service.GetDiastolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1735. //_, febStandTotal, err := service.GetDiastolicStandPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1736. //三月
  1737. marchlist, marchTotal, err := service.GetDiastolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1738. //_, marchStandTotal, err := service.GetDiastolicStandPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1739. //四月
  1740. aprlist, aprTotal, err := service.GetDiastolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1741. //_, aprStandTotal, err := service.GetDiastolicStandPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1742. //五月
  1743. maylist, mayTotal, err := service.GetDiastolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1744. //_, mayStandTotal, err := service.GetDiastolicStandPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1745. //六月
  1746. junlist, junTotal, err := service.GetDiastolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1747. //_, junStandTotal, err := service.GetDiastolicStandPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1748. //7月
  1749. jullist, julTotal, err := service.GetDiastolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1750. //_, julStandTotal, err := service.GetDiastolicStandPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1751. //8月
  1752. auglist, augTotal, err := service.GetDiastolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1753. //_, augStandTotal, err := service.GetDiastolicStandPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1754. //9月
  1755. seplist, sepTotal, err := service.GetDiastolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1756. //_, sepStandTotal, err := service.GetDiastolicStandPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1757. //10月
  1758. octlist, octTotal, err := service.GetDiastolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1759. //_, octStandTotal, err := service.GetDiastolicStandPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1760. //11月
  1761. novlist, novTotal, err := service.GetDiastolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1762. //_, novStandTotal, err := service.GetDiastolicStandPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1763. //12月
  1764. declist, decTotal, err := service.GetDiastolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1765. //_, decStandTotal, err := service.GetDiastolicStandPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1766. if err != nil {
  1767. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1768. return
  1769. }
  1770. this.ServeSuccessJSON(map[string]interface{}{
  1771. "januaryTotal": januaryTotal,
  1772. "januarylist": januarylist,
  1773. "febTotal": febTotal,
  1774. "feblist": feblist,
  1775. "marchTotal": marchTotal,
  1776. "marchlist": marchlist,
  1777. "aprTotal": aprTotal,
  1778. "aprlist": aprlist,
  1779. "mayTotal": mayTotal,
  1780. "maylist": maylist,
  1781. "junTotal": junTotal,
  1782. "junlist": junlist,
  1783. "julTotal": julTotal,
  1784. "jullist": jullist,
  1785. "augTotal": augTotal,
  1786. "auglist": auglist,
  1787. "sepTotal": sepTotal,
  1788. "seplist": seplist,
  1789. "octTotal": octTotal,
  1790. "octlist": octlist,
  1791. "novTotal": novTotal,
  1792. "novlist": novlist,
  1793. "decTotal": decTotal,
  1794. "declist": declist,
  1795. })
  1796. }
  1797. }
  1798. func (this *CommonApiController) GetIdsListTwo() {
  1799. dataBody := make(map[string]interface{}, 0)
  1800. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1801. fmt.Println(err)
  1802. adminInfo := this.GetAdminUserInfo()
  1803. orgId := adminInfo.CurrentOrgId
  1804. patientid, _ := this.GetInt64("patientid")
  1805. idlist := dataBody["ids"].([]interface{})
  1806. var vlist []interface{}
  1807. for _, contagion := range idlist {
  1808. id := int64(contagion.(float64))
  1809. list, _ := service.GetInspectionMoninList(id, orgId, patientid)
  1810. vlist = append(vlist, list)
  1811. }
  1812. if err != nil {
  1813. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1814. return
  1815. }
  1816. this.ServeSuccessJSON(map[string]interface{}{
  1817. "vlist": vlist,
  1818. })
  1819. }
  1820. func (this *CommonApiController) GetTreatModeList() {
  1821. start_time, _ := this.GetInt64("start_time")
  1822. end_time, _ := this.GetInt64("end_time")
  1823. adminUserInfo := this.GetAdminUserInfo()
  1824. orgId := adminUserInfo.CurrentOrgId
  1825. list, err := service.GetTreatModeList(start_time, end_time, orgId)
  1826. if err != nil {
  1827. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1828. return
  1829. }
  1830. this.ServeSuccessJSON(map[string]interface{}{
  1831. "list": list,
  1832. })
  1833. }
  1834. func (this *CommonApiController) GetCountModeId() {
  1835. start_time, _ := this.GetInt64("start_time")
  1836. end_time, _ := this.GetInt64("end_time")
  1837. mode_id, _ := this.GetInt64("mode_id")
  1838. adminUserInfo := this.GetAdminUserInfo()
  1839. orgId := adminUserInfo.CurrentOrgId
  1840. fmt.Println("start_time", start_time)
  1841. fmt.Println("end_time", end_time)
  1842. fmt.Println("mode_id", mode_id)
  1843. modeCount, err := service.GetCountModeId(start_time, end_time, mode_id, orgId)
  1844. if err != nil {
  1845. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1846. return
  1847. }
  1848. this.ServeSuccessJSON(map[string]interface{}{
  1849. "modeCount": modeCount,
  1850. })
  1851. }
  1852. func (this *CommonApiController) GetRolloutCount() {
  1853. start_time, _ := this.GetInt64("start_time")
  1854. end_time, _ := this.GetInt64("end_time")
  1855. lapsetotype, _ := this.GetInt64("lapsetotype")
  1856. sourcetype, _ := this.GetInt64("sourcetype")
  1857. adminUserInfo := this.GetAdminUserInfo()
  1858. orgId := adminUserInfo.CurrentOrgId
  1859. //统计当前机构转出的人数
  1860. rollout, err := service.GetCountRollout(orgId, start_time, end_time, lapsetotype, sourcetype)
  1861. if err != nil {
  1862. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1863. return
  1864. }
  1865. this.ServeSuccessJSON(map[string]interface{}{
  1866. "rollout": rollout,
  1867. })
  1868. }
  1869. func (this *CommonApiController) GetCheckExamine() {
  1870. //check_type, _ := this.GetInt64("check_type")
  1871. //start_time, _ := this.GetInt64("start_time")
  1872. //end_time, _ := this.GetInt64("end_time")
  1873. //total, _ := service.GetAllPatientCount(this.GetAdminUserInfo().CurrentOrgId)
  1874. //xcg_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 1) //血常规
  1875. //xysh_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 2) //血液生化
  1876. //ipth_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 3) //全段甲状旁腺激素
  1877. //xqtdb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 4) //血清铁蛋白和转铁蛋白饱和度
  1878. //xqqbdb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 5) //血清前白蛋白
  1879. //cfydb_total := service.GetCheckExaminePercent(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId, 6) //c反应蛋白
  1880. //
  1881. }