common_api_controller.go 71KB

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