common_api_controller.go 75KB

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