common_api_controller.go 74KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145
  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. fmt.Println("转归", lapseto)
  1007. startime := this.GetString("startime")
  1008. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1009. fmt.Println("parseDateErr", parseDateErr)
  1010. statime := startDate.Unix()
  1011. endtime := this.GetString("endtime")
  1012. endTimeYMDHmsStr := endtime + " 23:59:59"
  1013. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  1014. entime := endDate.Unix()
  1015. fmt.Println("结束日期", entime)
  1016. //统计数值类型的数据
  1017. count, err := service.GetQuarterTotalCount(orgid, statime, entime, lapseto)
  1018. //统计rang_type== 2
  1019. countwo, _ := service.GetQuarterTotalCountTwo(orgid, statime, entime, lapseto)
  1020. //获取收缩压数据
  1021. systolic, systolicTotal, parseDateErr := service.GetSystolicBloodPressure(orgid, statime, entime)
  1022. //统计收缩压合格的数据
  1023. //systolic, sysstandTotal, parseDateErr := service.GetStandSystolicBloodPressure(orgid, statime, entime)
  1024. //获取舒张压数据
  1025. diastolic, diastotal, parseDateErr := service.GetDiastolicBloodPressure(orgid, statime, entime)
  1026. //获取合格舒张压数据
  1027. //diastolic, diasstandtotal, parseDateErr := service.GetDiastolicStandPressure(orgid, statime, entime)
  1028. normData, _ := service.GetNormData(orgid)
  1029. if err != nil {
  1030. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1031. return
  1032. }
  1033. this.ServeSuccessJSON(map[string]interface{}{
  1034. "count": count,
  1035. "countwo": countwo,
  1036. "systolic": systolic,
  1037. "systolicTotal": systolicTotal,
  1038. "diastolic": diastolic,
  1039. "diastotal": diastotal,
  1040. "normData": normData,
  1041. })
  1042. }
  1043. func (this *CommonApiController) GetProjectList() {
  1044. startime := this.GetString("startime")
  1045. fmt.Println("startime", startime)
  1046. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1047. fmt.Println("parseDateErr", parseDateErr)
  1048. statime := startDate.Unix()
  1049. fmt.Println("开始时间", statime)
  1050. endtime := this.GetString("endtime")
  1051. fmt.Println("endtime", endtime)
  1052. endTimeYMDHmsStr := endtime + " 23:59:59"
  1053. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endTimeYMDHmsStr)
  1054. entime := endDate.Unix()
  1055. adminInfo := this.GetAdminUserInfo()
  1056. orgid := adminInfo.CurrentOrgId
  1057. lapseto, _ := this.GetInt64("lapseto")
  1058. fmt.Println("lapseto", lapseto)
  1059. itemtype, _ := this.GetInt64("itemtype")
  1060. fmt.Println("type", itemtype)
  1061. modetype, _ := this.GetInt64("modetype")
  1062. fmt.Println("modetype", modetype)
  1063. firstQuarterStart := this.GetString("first_quarter_start")
  1064. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  1065. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  1066. fisrtQuarterEnd := this.GetString("first_qurter_end")
  1067. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  1068. fisrtQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  1069. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  1070. secondeQuarterStart := this.GetString("second_qurter_start")
  1071. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  1072. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  1073. secondQuarterEnd := this.GetString("second_qurter_end")
  1074. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  1075. secondQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  1076. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  1077. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  1078. threeQuarterStart := this.GetString("three_qurter_start")
  1079. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  1080. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  1081. threeQuarterEnd := this.GetString("three_qurter_end")
  1082. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  1083. threeQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  1084. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  1085. fourQuarterStart := this.GetString("four_qurter_start")
  1086. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  1087. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  1088. fourQuarterEnd := this.GetString("four_qurter_end")
  1089. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  1090. fourQuarterEnds, parseDateErr := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  1091. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  1092. //fmt.Println("第四季度结束时间", fourQuarterEndStrUnix)
  1093. rangetype, parseDateErr := this.GetInt64("range_type")
  1094. //按季度统计
  1095. if rangetype == 1 {
  1096. //统计总共
  1097. list, err := service.GetProjectList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1098. //统计达标个数
  1099. standList, err := service.GetProjectStandList(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1100. if err != nil {
  1101. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1102. return
  1103. }
  1104. this.ServeSuccessJSON(map[string]interface{}{
  1105. "list": list,
  1106. "standList": standList,
  1107. })
  1108. }
  1109. if rangetype == 2 {
  1110. list, err := service.GetProjectListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1111. //统计达标个数
  1112. standList, err := service.GetProjectStandListOne(orgid, lapseto, modetype, statime, entime, firstQuarterStartUnix, fisrtQuarterEndStrUnix, secondeQuarterStartUnix, secondQuarterEndStrUnix, threeQuarterStartUnix, threeQuarterEndStrUnix, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1113. if err != nil {
  1114. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1115. return
  1116. }
  1117. this.ServeSuccessJSON(map[string]interface{}{
  1118. "list": list,
  1119. "standList": standList,
  1120. })
  1121. }
  1122. }
  1123. func (this *CommonApiController) GetMonthProjectList() {
  1124. adminUser := this.GetAdminUserInfo()
  1125. orgid := adminUser.CurrentOrgId
  1126. lapseto, _ := this.GetInt64("lapseto")
  1127. fmt.Println("lapseto", lapseto)
  1128. itemtype, _ := this.GetInt64("itemtype")
  1129. fmt.Println("itemtype", itemtype)
  1130. modetype, _ := this.GetInt64("modetype")
  1131. januaryStart := this.GetString("januaryStart")
  1132. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  1133. januaryStartStrUnix := januaryStartStr.Unix()
  1134. januaryEnd := this.GetString("januaryEnd")
  1135. januaryEndStr := januaryEnd + " 23:59:59"
  1136. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  1137. januaryEndStrUnix := januaryEndStrs.Unix()
  1138. febStart := this.GetString("febStart")
  1139. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  1140. febStartStrStrUnix := febStartStr.Unix()
  1141. febEnd := this.GetString("febEnd")
  1142. febEndStr := febEnd + " 23:59:59"
  1143. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  1144. febEndStrUnix := febEndStrs.Unix()
  1145. marchStart := this.GetString("marchStart")
  1146. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  1147. marchStartStrUnix := marchStartStr.Unix()
  1148. marchEnd := this.GetString("marchEnd")
  1149. marchEndStr := marchEnd + " 23:59:59"
  1150. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  1151. marchEndStrUnix := marchEndStrs.Unix()
  1152. aprStart := this.GetString("aprStart")
  1153. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  1154. aprStartStrUnix := aprStartStr.Unix()
  1155. aprEnd := this.GetString("aprEnd")
  1156. aprEndStr := aprEnd + " 23:59:59"
  1157. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  1158. aprEndStrsUnix := aprEndStrs.Unix()
  1159. mayStart := this.GetString("mayStart")
  1160. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1161. mayStartStrUnix := mayStartStr.Unix()
  1162. mayEnd := this.GetString("mayEnd")
  1163. mayEndStr := mayEnd + " 23:59:59"
  1164. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1165. mayEndStrsUnix := mayEndStrs.Unix()
  1166. junStart := this.GetString("junStart")
  1167. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1168. junStartStrUnix := junStartStr.Unix()
  1169. junEnd := this.GetString("junEnd")
  1170. junEndStr := junEnd + " 23:59:59"
  1171. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1172. junEndStrsUnix := junEndStrs.Unix()
  1173. julStart := this.GetString("julStart")
  1174. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1175. julStartStrUnix := julStartStr.Unix()
  1176. julEnd := this.GetString("julEnd")
  1177. julEndStr := julEnd + " 23:59:59"
  1178. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1179. julEndStrsUnix := julEndStrs.Unix()
  1180. augStart := this.GetString("augStart")
  1181. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1182. augStartStrUnix := augStartStr.Unix()
  1183. augEnd := this.GetString("augEnd")
  1184. augEndStr := augEnd + " 23:59:59"
  1185. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1186. augEndStrsUnix := augEndStrs.Unix()
  1187. sepStart := this.GetString("sepStart")
  1188. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1189. sepStartStrUnix := sepStartStr.Unix()
  1190. sepEnd := this.GetString("sepEnd")
  1191. sepEndStr := sepEnd + " 23:59:59"
  1192. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1193. sepEndStrsUnix := sepEndStrs.Unix()
  1194. octStart := this.GetString("octStart")
  1195. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1196. octStartStrUnix := octStartStr.Unix()
  1197. octEnd := this.GetString("octEnd")
  1198. octEndStr := octEnd + " 23:59:59"
  1199. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1200. octEndStrsUnix := octEndStrs.Unix()
  1201. novStart := this.GetString("novStart")
  1202. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1203. novStartStrUnix := novStartStr.Unix()
  1204. novEnd := this.GetString("novEnd")
  1205. novEndStr := novEnd + " 23:59:59"
  1206. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1207. novEndStrsUnix := novEndStrs.Unix()
  1208. decStart := this.GetString("decStart")
  1209. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1210. decStartStrUnix := decStartStr.Unix()
  1211. fmt.Println("12月使", decStartStrUnix)
  1212. decEnd := this.GetString("decEnd")
  1213. decEndStr := decEnd + " 23:59:59"
  1214. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1215. decEndStrsUnix := decEndStrs.Unix()
  1216. rangetype, _ := this.GetInt64("range_type")
  1217. if rangetype == 1 {
  1218. //统计总共
  1219. 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)
  1220. //统计不合格
  1221. 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)
  1222. fmt.Println("monthnolist", monthNolist)
  1223. if err != nil {
  1224. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1225. return
  1226. }
  1227. this.ServeSuccessJSON(map[string]interface{}{
  1228. "monthlist": monthlist,
  1229. "monthNolist": monthNolist,
  1230. })
  1231. }
  1232. if rangetype == 2 {
  1233. 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)
  1234. 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)
  1235. if err != nil {
  1236. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1237. return
  1238. }
  1239. this.ServeSuccessJSON(map[string]interface{}{
  1240. "monthlist": monthlist,
  1241. "monthNolist": monthNolist,
  1242. })
  1243. }
  1244. }
  1245. func (this *CommonApiController) GetPatientscontrol() {
  1246. adminUser := this.GetAdminUserInfo()
  1247. orgid := adminUser.CurrentOrgId
  1248. lapstor, _ := this.GetInt64("lapstor")
  1249. startime := this.GetString("startime")
  1250. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1251. startimeStrUnix := startimeStr.Unix()
  1252. endtime := this.GetString("endtime")
  1253. fmt.Println("结束时间", endtime)
  1254. endtimeStr := endtime + " 23:59:59"
  1255. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1256. endtimeStrsUnix := endtimeStrs.Unix()
  1257. page, _ := this.GetInt64("page")
  1258. limit, _ := this.GetInt64("limit")
  1259. patients, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1260. control, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1261. infectiousControl, err := service.GetInfectiousControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1262. if err != nil {
  1263. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1264. return
  1265. }
  1266. this.ServeSuccessJSON(map[string]interface{}{
  1267. "patients": patients,
  1268. "total": total,
  1269. "control": control,
  1270. "infectiousControl": infectiousControl,
  1271. })
  1272. }
  1273. func (this *CommonApiController) GetCartogramList() {
  1274. adminUser := this.GetAdminUserInfo()
  1275. orgid := adminUser.CurrentOrgId
  1276. //fmt.Println("orgid", orgid)
  1277. lapstor, _ := this.GetInt64("lapstor")
  1278. fmt.Println("lapstor", lapstor)
  1279. startime := this.GetString("startime")
  1280. //fmt.Println("开始时间", startime)
  1281. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1282. startimeStrUnix := startimeStr.Unix()
  1283. //fmt.Println("时间搓", startimeStrUnix)
  1284. endtime := this.GetString("endtime")
  1285. //fmt.Println("结束时间", endtime)
  1286. endtimeStr := endtime + " 23:59:59"
  1287. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1288. endtimeStrsUnix := endtimeStrs.Unix()
  1289. //fmt.Println("结束时间搓", endtimeStrsUnix)
  1290. //limit, _ := this.GetInt64("limit")
  1291. //page, _ := this.GetInt64("page")
  1292. //统计总共
  1293. _, total, err := service.GetTotalPatientsControl(orgid, startimeStrUnix, endtimeStrsUnix)
  1294. //fmt.Println("total=================", total)
  1295. //统计rangetype= 1
  1296. _, standtotal, err := service.GetStandControl(orgid, startimeStrUnix, endtimeStrsUnix)
  1297. //fmt.Println(standtotal)
  1298. _, standtotalOne, err := service.GetStandControlOne(orgid, startimeStrUnix, endtimeStrsUnix)
  1299. //fmt.Println(standtotalOne)
  1300. //cartogramlist, err := service.GetLastPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1301. //infectiouscontrol, err := service.GetInfectiousPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix)
  1302. //_, total, err := service.GetPatientsControl(orgid, lapstor, startimeStrUnix, endtimeStrsUnix, page, limit)
  1303. if err != nil {
  1304. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1305. return
  1306. }
  1307. this.ServeSuccessJSON(map[string]interface{}{
  1308. "total": total,
  1309. "standtotal": standtotal,
  1310. "standtotalOne": standtotalOne,
  1311. })
  1312. }
  1313. func (this *CommonApiController) GetPatientContor() {
  1314. adminUser := this.GetAdminUserInfo()
  1315. orgid := adminUser.CurrentOrgId
  1316. fmt.Println(orgid)
  1317. lapstor, _ := this.GetInt64("lapstor")
  1318. fmt.Println("lapstor", lapstor)
  1319. patientid, _ := this.GetInt64("patientid")
  1320. startime := this.GetString("startime")
  1321. startimeStr, _ := utils.ParseTimeStringToTime("2006-01-02", startime)
  1322. startimeStrUnix := startimeStr.Unix()
  1323. endtime := this.GetString("endtime")
  1324. //fmt.Println("结束时间", endtime)
  1325. endtimeStr := endtime + " 23:59:59"
  1326. endtimeStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", endtimeStr)
  1327. endtimeStrsUnix := endtimeStrs.Unix()
  1328. patients, err := service.GetPatientNames(orgid, patientid)
  1329. patientcontorDetail, err := service.GetLastPatientsControlTwo(orgid, patientid, startimeStrUnix, endtimeStrsUnix)
  1330. if err != nil {
  1331. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1332. return
  1333. }
  1334. this.ServeSuccessJSON(map[string]interface{}{
  1335. "patientcontorDetail": patientcontorDetail,
  1336. "name": patients.Name,
  1337. })
  1338. }
  1339. func (this *CommonApiController) GetQualityControl() {
  1340. adminUser := this.GetAdminUserInfo()
  1341. orgid := adminUser.CurrentOrgId
  1342. fmt.Println(orgid)
  1343. patientid, _ := this.GetInt64("patientid")
  1344. startime, _ := this.GetInt64("startime")
  1345. //fmt.Println("startime", startime)
  1346. endtime, _ := this.GetInt64("endtime")
  1347. //fmt.Println("endtime", endtime)
  1348. itemid, _ := this.GetInt64("itemid")
  1349. //fmt.Println("itemid", itemid)
  1350. inspectdate, _ := this.GetInt64("inspectdate")
  1351. list, err := service.GetQualityControlById(orgid, patientid, startime, endtime, itemid, inspectdate)
  1352. if err != nil {
  1353. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1354. return
  1355. }
  1356. this.ServeSuccessJSON(map[string]interface{}{
  1357. "list": list,
  1358. })
  1359. }
  1360. func (this *CommonApiController) GetTreatlist() {
  1361. adminuser := this.GetAdminUserInfo()
  1362. orgId := adminuser.CurrentOrgId
  1363. startime := this.GetString("start_time")
  1364. endtime := this.GetString("end_time")
  1365. startDate, parseDateErr := utils.ParseTimeStringToTime("2006-01-02", startime)
  1366. fmt.Println("parseDateErr", parseDateErr)
  1367. statime := startDate.Unix()
  1368. endDate, _ := utils.ParseTimeStringToTime("2006-01-02", endtime)
  1369. entime := endDate.Unix()
  1370. value, _ := this.GetInt64("value")
  1371. fmt.Println("value", value)
  1372. list, err := service.GetTreatList(orgId, statime, entime, value)
  1373. if err != nil {
  1374. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1375. return
  1376. }
  1377. this.ServeSuccessJSON(map[string]interface{}{
  1378. "list": list,
  1379. })
  1380. }
  1381. func (this *CommonApiController) GetPatientComplianceDetail() {
  1382. adminUser := this.GetAdminUserInfo()
  1383. orgid := adminUser.CurrentOrgId
  1384. fmt.Println(orgid)
  1385. patientid, _ := this.GetInt64("patientid")
  1386. startime, _ := this.GetInt64("startime")
  1387. fmt.Println("startime", startime)
  1388. endtime, _ := this.GetInt64("endtime")
  1389. fmt.Println("endtime", endtime)
  1390. itemid, _ := this.GetInt64("itemid")
  1391. fmt.Println("itemid", itemid)
  1392. list, err := service.GetPatientComplianceDetail(orgid, patientid, startime, endtime, itemid)
  1393. if err != nil {
  1394. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1395. return
  1396. }
  1397. this.ServeSuccessJSON(map[string]interface{}{
  1398. "list": list,
  1399. })
  1400. }
  1401. func (this *CommonApiController) GetBloodPressureDetail() {
  1402. id, _ := this.GetInt64("id")
  1403. blooddetail, err := service.GetBloodPressureDetail(id)
  1404. if err != nil {
  1405. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1406. return
  1407. }
  1408. this.ServeSuccessJSON(map[string]interface{}{
  1409. "blooddetail": blooddetail,
  1410. })
  1411. }
  1412. func (this *CommonApiController) UpdateBloodPrussre() {
  1413. id, _ := this.GetInt64("id")
  1414. fmt.Println("id", id)
  1415. dataBody := make(map[string]interface{}, 0)
  1416. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1417. fmt.Println("err", err)
  1418. inspectionmajor := int64(dataBody["inspectionMajor"].(float64))
  1419. fmt.Println("inspectionmajor", inspectionmajor)
  1420. inspectionminor := int64(dataBody["inspectionMinor"].(float64))
  1421. fmt.Println("inspectionminor", inspectionminor)
  1422. largerange := dataBody["large_range"].(string)
  1423. fmt.Println(largerange)
  1424. minrange := dataBody["min_range"].(string)
  1425. fmt.Print(minrange)
  1426. sort := int64(dataBody["sort"].(float64))
  1427. fmt.Print("sort", sort)
  1428. standard := models.XtQualityControlStandard{
  1429. InspectionMajor: inspectionmajor,
  1430. InspectionMinor: inspectionminor,
  1431. MinRange: minrange,
  1432. Sort: sort,
  1433. LargeRange: largerange,
  1434. }
  1435. err = service.UpdateBloodPressure(&standard, id)
  1436. if err != nil {
  1437. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1438. return
  1439. }
  1440. this.ServeSuccessJSON(map[string]interface{}{
  1441. "standard": standard,
  1442. })
  1443. }
  1444. func (this *CommonApiController) GetBloodPressureList() {
  1445. adminUser := this.GetAdminUserInfo()
  1446. orgId := adminUser.CurrentOrgId
  1447. bloodType, _ := this.GetInt64("bloodType")
  1448. fmt.Println(bloodType)
  1449. firstQuarterStart := this.GetString("first_quarter_start")
  1450. firstQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", firstQuarterStart)
  1451. firstQuarterStartUnix := firstQuarterStartStr.Unix()
  1452. fmt.Println("第一季度", firstQuarterStartUnix)
  1453. fisrtQuarterEnd := this.GetString("first_qurter_end")
  1454. fisrtQuarterEndStr := fisrtQuarterEnd + " 23:59:59"
  1455. fisrtQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fisrtQuarterEndStr)
  1456. fisrtQuarterEndStrUnix := fisrtQuarterEnds.Unix()
  1457. fmt.Println("fisrtQuarterEndStrUnix", fisrtQuarterEndStrUnix)
  1458. secondeQuarterStart := this.GetString("second_qurter_start")
  1459. secondeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", secondeQuarterStart)
  1460. secondeQuarterStartUnix := secondeQuarterStartStr.Unix()
  1461. fmt.Println("secondeQuarterStartUnix", secondeQuarterStartUnix)
  1462. secondQuarterEnd := this.GetString("second_qurter_end")
  1463. secondQuarterEndStr := secondQuarterEnd + " 23:59:59"
  1464. secondQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", secondQuarterEndStr)
  1465. secondQuarterEndStrUnix := secondQuarterEnds.Unix()
  1466. fmt.Println("第二季度结束时间", secondQuarterEndStrUnix)
  1467. threeQuarterStart := this.GetString("three_qurter_start")
  1468. threeQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", threeQuarterStart)
  1469. threeQuarterStartUnix := threeQuarterStartStr.Unix()
  1470. fmt.Println("第三季度", threeQuarterStartUnix)
  1471. threeQuarterEnd := this.GetString("three_qurter_end")
  1472. threeQuarterEndStr := threeQuarterEnd + " 23:59:59"
  1473. threeQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", threeQuarterEndStr)
  1474. threeQuarterEndStrUnix := threeQuarterEnds.Unix()
  1475. fmt.Println("第三季度", threeQuarterEndStrUnix)
  1476. fourQuarterStart := this.GetString("four_qurter_start")
  1477. fourQuarterStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", fourQuarterStart)
  1478. fourQuarterStartUnix := fourQuarterStartStr.Unix()
  1479. fmt.Println("第四季度", fourQuarterStartUnix)
  1480. fourQuarterEnd := this.GetString("four_qurter_end")
  1481. fourQuarterEndStr := fourQuarterEnd + " 23:59:59"
  1482. fourQuarterEnds, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", fourQuarterEndStr)
  1483. fourQuarterEndStrUnix := fourQuarterEnds.Unix()
  1484. fmt.Println("第四季度", fourQuarterEndStrUnix)
  1485. if bloodType == -1 {
  1486. //统计收缩压第一季度的总数
  1487. firstList, firstTotal, err := service.GetSystolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1488. //统计收缩压第一季合格的总数
  1489. //_, firstStandTotal, err := service.GetStandSystolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1490. //统计第二季收缩压总数
  1491. secondelist, secondeTotal, err := service.GetSystolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1492. //第二季度合格总数
  1493. //_, secondeStandTotal, err := service.GetStandSystolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1494. //统计第三季收缩压总数
  1495. threelist, threeTotal, err := service.GetSystolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1496. //第三季度合格数
  1497. //_, threeStandTotal, err := service.GetStandSystolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1498. //第四季度总数
  1499. fourlist, fourTotal, err := service.GetSystolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1500. //第四季度合格总数
  1501. //_, fourStandTotal, err := service.GetStandSystolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1502. if err != nil {
  1503. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1504. return
  1505. }
  1506. this.ServeSuccessJSON(map[string]interface{}{
  1507. "firstTotal": firstTotal,
  1508. "firstList": firstList,
  1509. "secondelist": secondelist,
  1510. "secondeTotal": secondeTotal,
  1511. "threelist": threelist,
  1512. "threeTotal": threeTotal,
  1513. "fourTotal": fourTotal,
  1514. "fourlist": fourlist,
  1515. })
  1516. }
  1517. if bloodType == -2 {
  1518. //统计舒张压第一季度的总数
  1519. firstList, firstTotal, err := service.GetDiastolicBloodPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1520. //_, firstStandTotal, err := service.GetDiastolicStandPressure(orgId, firstQuarterStartUnix, fisrtQuarterEndStrUnix)
  1521. secondelist, secondeTotal, err := service.GetDiastolicBloodPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1522. //_, secondeStandTotal, err := service.GetDiastolicStandPressure(orgId, secondeQuarterStartUnix, secondQuarterEndStrUnix)
  1523. threelist, threeTotal, err := service.GetDiastolicBloodPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1524. //_, threeStandTotal, err := service.GetDiastolicStandPressure(orgId, threeQuarterStartUnix, threeQuarterEndStrUnix)
  1525. fourlist, fourTotal, err := service.GetDiastolicBloodPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1526. //_, fourStandTotal, err := service.GetDiastolicStandPressure(orgId, fourQuarterStartUnix, fourQuarterEndStrUnix)
  1527. if err != nil {
  1528. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1529. return
  1530. }
  1531. this.ServeSuccessJSON(map[string]interface{}{
  1532. "firstTotal": firstTotal,
  1533. "firstList": firstList,
  1534. "secondelist": secondelist,
  1535. "secondeTotal": secondeTotal,
  1536. "threelist": threelist,
  1537. "threeTotal": threeTotal,
  1538. "fourTotal": fourTotal,
  1539. "fourlist": fourlist,
  1540. })
  1541. }
  1542. }
  1543. func (this *CommonApiController) GetMonthBloodList() {
  1544. bloodtype, _ := this.GetInt64("bloodType")
  1545. fmt.Println(bloodtype)
  1546. januaryStart := this.GetString("januaryStart")
  1547. januaryStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", januaryStart)
  1548. januaryStartStrUnix := januaryStartStr.Unix()
  1549. fmt.Println(januaryStartStrUnix)
  1550. januaryEnd := this.GetString("januaryEnd")
  1551. januaryEndStr := januaryEnd + " 23:59:59"
  1552. januaryEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", januaryEndStr)
  1553. januaryEndStrUnix := januaryEndStrs.Unix()
  1554. fmt.Println(januaryEndStrUnix)
  1555. febStart := this.GetString("febStart")
  1556. febStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", febStart)
  1557. febStartStrStrUnix := febStartStr.Unix()
  1558. fmt.Println(febStartStrStrUnix)
  1559. febEnd := this.GetString("febEnd")
  1560. febEndStr := febEnd + " 23:59:59"
  1561. febEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", febEndStr)
  1562. febEndStrUnix := febEndStrs.Unix()
  1563. fmt.Println(febEndStrUnix)
  1564. marchStart := this.GetString("marchStart")
  1565. marchStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", marchStart)
  1566. marchStartStrUnix := marchStartStr.Unix()
  1567. fmt.Println(marchStartStrUnix)
  1568. marchEnd := this.GetString("marchEnd")
  1569. marchEndStr := marchEnd + " 23:59:59"
  1570. marchEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", marchEndStr)
  1571. marchEndStrUnix := marchEndStrs.Unix()
  1572. fmt.Println(marchEndStrUnix)
  1573. aprStart := this.GetString("aprStart")
  1574. aprStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", aprStart)
  1575. aprStartStrUnix := aprStartStr.Unix()
  1576. fmt.Println(aprStartStrUnix)
  1577. aprEnd := this.GetString("aprEnd")
  1578. aprEndStr := aprEnd + " 23:59:59"
  1579. aprEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", aprEndStr)
  1580. aprEndStrsUnix := aprEndStrs.Unix()
  1581. fmt.Println(aprEndStrsUnix)
  1582. mayStart := this.GetString("mayStart")
  1583. mayStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", mayStart)
  1584. mayStartStrUnix := mayStartStr.Unix()
  1585. fmt.Println(mayStartStrUnix)
  1586. mayEnd := this.GetString("mayEnd")
  1587. mayEndStr := mayEnd + " 23:59:59"
  1588. mayEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", mayEndStr)
  1589. mayEndStrsUnix := mayEndStrs.Unix()
  1590. fmt.Println(mayEndStrsUnix)
  1591. junStart := this.GetString("junStart")
  1592. junStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", junStart)
  1593. junStartStrUnix := junStartStr.Unix()
  1594. fmt.Println(junStartStrUnix)
  1595. junEnd := this.GetString("junEnd")
  1596. junEndStr := junEnd + " 23:59:59"
  1597. junEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", junEndStr)
  1598. junEndStrsUnix := junEndStrs.Unix()
  1599. fmt.Println(junEndStrsUnix)
  1600. julStart := this.GetString("julStart")
  1601. julStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", julStart)
  1602. julStartStrUnix := julStartStr.Unix()
  1603. fmt.Println(julStartStrUnix)
  1604. julEnd := this.GetString("julEnd")
  1605. julEndStr := julEnd + " 23:59:59"
  1606. julEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", julEndStr)
  1607. julEndStrsUnix := julEndStrs.Unix()
  1608. fmt.Println(julEndStrsUnix)
  1609. augStart := this.GetString("augStart")
  1610. augStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", augStart)
  1611. augStartStrUnix := augStartStr.Unix()
  1612. fmt.Print(augStartStrUnix)
  1613. augEnd := this.GetString("augEnd")
  1614. augEndStr := augEnd + " 23:59:59"
  1615. augEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", augEndStr)
  1616. augEndStrsUnix := augEndStrs.Unix()
  1617. fmt.Println(augEndStrsUnix)
  1618. sepStart := this.GetString("sepStart")
  1619. sepStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", sepStart)
  1620. sepStartStrUnix := sepStartStr.Unix()
  1621. fmt.Println(sepStartStrUnix)
  1622. sepEnd := this.GetString("sepEnd")
  1623. sepEndStr := sepEnd + " 23:59:59"
  1624. sepEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", sepEndStr)
  1625. sepEndStrsUnix := sepEndStrs.Unix()
  1626. fmt.Println(sepEndStrsUnix)
  1627. octStart := this.GetString("octStart")
  1628. octStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", octStart)
  1629. octStartStrUnix := octStartStr.Unix()
  1630. fmt.Println(octStartStrUnix)
  1631. octEnd := this.GetString("octEnd")
  1632. octEndStr := octEnd + " 23:59:59"
  1633. octEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", octEndStr)
  1634. octEndStrsUnix := octEndStrs.Unix()
  1635. fmt.Println(octEndStrsUnix)
  1636. novStart := this.GetString("novStart")
  1637. novStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", novStart)
  1638. novStartStrUnix := novStartStr.Unix()
  1639. fmt.Println(novStartStrUnix)
  1640. novEnd := this.GetString("novEnd")
  1641. novEndStr := novEnd + " 23:59:59"
  1642. novEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", novEndStr)
  1643. novEndStrsUnix := novEndStrs.Unix()
  1644. fmt.Println(novEndStrsUnix)
  1645. decStart := this.GetString("decStart")
  1646. decStartStr, _ := utils.ParseTimeStringToTime("2006-01-02", decStart)
  1647. decStartStrUnix := decStartStr.Unix()
  1648. fmt.Println("12月使", decStartStrUnix)
  1649. decEnd := this.GetString("decEnd")
  1650. decEndStr := decEnd + " 23:59:59"
  1651. decEndStrs, _ := utils.ParseTimeStringToTime("2006-01-02 15:04:05", decEndStr)
  1652. decEndStrsUnix := decEndStrs.Unix()
  1653. fmt.Println(decEndStrsUnix)
  1654. adminUser := this.GetAdminUserInfo()
  1655. orgId := adminUser.CurrentOrgId
  1656. //统计收缩压
  1657. if bloodtype == -1 {
  1658. //统计收缩压一月总数
  1659. januarylist, januaryTotal, err := service.GetSystolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1660. //_, januaryStandTotal, err := service.GetStandSystolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1661. //二月
  1662. feblist, febTotal, err := service.GetSystolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1663. //_, febStandTotal, err := service.GetStandSystolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1664. //三月
  1665. marchlist, marchTotal, err := service.GetSystolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1666. //_, marchStandTotal, err := service.GetStandSystolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1667. //四月
  1668. aprlist, aprTotal, err := service.GetSystolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1669. //_, aprStandTotal, err := service.GetStandSystolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1670. //五月
  1671. maylist, mayTotal, err := service.GetSystolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1672. //_, mayStandTotal, err := service.GetStandSystolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1673. //六月
  1674. junlist, junTotal, err := service.GetSystolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1675. //_, junStandTotal, err := service.GetStandSystolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1676. //7月
  1677. jullist, julTotal, err := service.GetSystolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1678. //_, julStandTotal, err := service.GetStandSystolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1679. //8月
  1680. auglist, augTotal, err := service.GetSystolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1681. //_, augStandTotal, err := service.GetStandSystolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1682. //9月
  1683. seplist, sepTotal, err := service.GetSystolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1684. //_, sepStandTotal, err := service.GetStandSystolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1685. //10月
  1686. octlist, octTotal, err := service.GetSystolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1687. //_, octStandTotal, err := service.GetStandSystolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1688. //11月
  1689. novlist, novTotal, err := service.GetSystolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1690. //_, novStandTotal, err := service.GetStandSystolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1691. //12月
  1692. declist, decTotal, err := service.GetSystolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1693. //_, decStandTotal, err := service.GetStandSystolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1694. if err != nil {
  1695. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1696. return
  1697. }
  1698. this.ServeSuccessJSON(map[string]interface{}{
  1699. "januaryTotal": januaryTotal,
  1700. "januarylist": januarylist,
  1701. "febTotal": febTotal,
  1702. "feblist": feblist,
  1703. "marchTotal": marchTotal,
  1704. "marchlist": marchlist,
  1705. "aprTotal": aprTotal,
  1706. "aprlist": aprlist,
  1707. "mayTotal": mayTotal,
  1708. "maylist": maylist,
  1709. "junTotal": junTotal,
  1710. "junlist": junlist,
  1711. "julTotal": julTotal,
  1712. "jullist": jullist,
  1713. "augTotal": augTotal,
  1714. "auglist": auglist,
  1715. "sepTotal": sepTotal,
  1716. "seplist": seplist,
  1717. "octTotal": octTotal,
  1718. "octlist": octlist,
  1719. "novTotal": novTotal,
  1720. "novlist": novlist,
  1721. "decTotal": decTotal,
  1722. "declist": declist,
  1723. })
  1724. }
  1725. //统计舒张压
  1726. if bloodtype == -2 {
  1727. //统计收缩压一月总数
  1728. januarylist, januaryTotal, err := service.GetDiastolicBloodPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1729. //_, januaryStandTotal, err := service.GetDiastolicStandPressure(orgId, januaryStartStrUnix, januaryEndStrUnix)
  1730. //二月
  1731. feblist, febTotal, err := service.GetDiastolicBloodPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1732. //_, febStandTotal, err := service.GetDiastolicStandPressure(orgId, febStartStrStrUnix, febEndStrUnix)
  1733. //三月
  1734. marchlist, marchTotal, err := service.GetDiastolicBloodPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1735. //_, marchStandTotal, err := service.GetDiastolicStandPressure(orgId, marchStartStrUnix, marchEndStrUnix)
  1736. //四月
  1737. aprlist, aprTotal, err := service.GetDiastolicBloodPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1738. //_, aprStandTotal, err := service.GetDiastolicStandPressure(orgId, aprStartStrUnix, aprEndStrsUnix)
  1739. //五月
  1740. maylist, mayTotal, err := service.GetDiastolicBloodPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1741. //_, mayStandTotal, err := service.GetDiastolicStandPressure(orgId, mayStartStrUnix, mayEndStrsUnix)
  1742. //六月
  1743. junlist, junTotal, err := service.GetDiastolicBloodPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1744. //_, junStandTotal, err := service.GetDiastolicStandPressure(orgId, junStartStrUnix, junEndStrsUnix)
  1745. //7月
  1746. jullist, julTotal, err := service.GetDiastolicBloodPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1747. //_, julStandTotal, err := service.GetDiastolicStandPressure(orgId, julStartStrUnix, julEndStrsUnix)
  1748. //8月
  1749. auglist, augTotal, err := service.GetDiastolicBloodPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1750. //_, augStandTotal, err := service.GetDiastolicStandPressure(orgId, augStartStrUnix, augEndStrsUnix)
  1751. //9月
  1752. seplist, sepTotal, err := service.GetDiastolicBloodPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1753. //_, sepStandTotal, err := service.GetDiastolicStandPressure(orgId, sepStartStrUnix, sepEndStrsUnix)
  1754. //10月
  1755. octlist, octTotal, err := service.GetDiastolicBloodPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1756. //_, octStandTotal, err := service.GetDiastolicStandPressure(orgId, octStartStrUnix, octEndStrsUnix)
  1757. //11月
  1758. novlist, novTotal, err := service.GetDiastolicBloodPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1759. //_, novStandTotal, err := service.GetDiastolicStandPressure(orgId, novStartStrUnix, novEndStrsUnix)
  1760. //12月
  1761. declist, decTotal, err := service.GetDiastolicBloodPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1762. //_, decStandTotal, err := service.GetDiastolicStandPressure(orgId, decStartStrUnix, decEndStrsUnix)
  1763. if err != nil {
  1764. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1765. return
  1766. }
  1767. this.ServeSuccessJSON(map[string]interface{}{
  1768. "januaryTotal": januaryTotal,
  1769. "januarylist": januarylist,
  1770. "febTotal": febTotal,
  1771. "feblist": feblist,
  1772. "marchTotal": marchTotal,
  1773. "marchlist": marchlist,
  1774. "aprTotal": aprTotal,
  1775. "aprlist": aprlist,
  1776. "mayTotal": mayTotal,
  1777. "maylist": maylist,
  1778. "junTotal": junTotal,
  1779. "junlist": junlist,
  1780. "julTotal": julTotal,
  1781. "jullist": jullist,
  1782. "augTotal": augTotal,
  1783. "auglist": auglist,
  1784. "sepTotal": sepTotal,
  1785. "seplist": seplist,
  1786. "octTotal": octTotal,
  1787. "octlist": octlist,
  1788. "novTotal": novTotal,
  1789. "novlist": novlist,
  1790. "decTotal": decTotal,
  1791. "declist": declist,
  1792. })
  1793. }
  1794. }
  1795. func (this *CommonApiController) GetIdsListTwo() {
  1796. dataBody := make(map[string]interface{}, 0)
  1797. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1798. fmt.Println(err)
  1799. adminInfo := this.GetAdminUserInfo()
  1800. orgId := adminInfo.CurrentOrgId
  1801. patientid, _ := this.GetInt64("patientid")
  1802. idlist := dataBody["ids"].([]interface{})
  1803. var vlist []interface{}
  1804. for _, contagion := range idlist {
  1805. id := int64(contagion.(float64))
  1806. list, _ := service.GetInspectionMoninList(id, orgId, patientid)
  1807. vlist = append(vlist, list)
  1808. }
  1809. if err != nil {
  1810. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1811. return
  1812. }
  1813. this.ServeSuccessJSON(map[string]interface{}{
  1814. "vlist": vlist,
  1815. })
  1816. }
  1817. func (this *CommonApiController) GetTreatModeList() {
  1818. start_time, _ := this.GetInt64("start_time")
  1819. end_time, _ := this.GetInt64("end_time")
  1820. adminUserInfo := this.GetAdminUserInfo()
  1821. orgId := adminUserInfo.CurrentOrgId
  1822. list, err := service.GetTreatModeList(start_time, end_time, orgId)
  1823. if err != nil {
  1824. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1825. return
  1826. }
  1827. this.ServeSuccessJSON(map[string]interface{}{
  1828. "list": list,
  1829. })
  1830. }
  1831. func (this *CommonApiController) GetCountModeId() {
  1832. start_time, _ := this.GetInt64("start_time")
  1833. end_time, _ := this.GetInt64("end_time")
  1834. mode_id, _ := this.GetInt64("mode_id")
  1835. adminUserInfo := this.GetAdminUserInfo()
  1836. orgId := adminUserInfo.CurrentOrgId
  1837. fmt.Println("start_time", start_time)
  1838. fmt.Println("end_time", end_time)
  1839. fmt.Println("mode_id", mode_id)
  1840. modeCount, err := service.GetCountModeId(start_time, end_time, mode_id, orgId)
  1841. if err != nil {
  1842. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1843. return
  1844. }
  1845. this.ServeSuccessJSON(map[string]interface{}{
  1846. "modeCount": modeCount,
  1847. })
  1848. }
  1849. func (this *CommonApiController) GetRolloutCount() {
  1850. start_time, _ := this.GetInt64("start_time")
  1851. end_time, _ := this.GetInt64("end_time")
  1852. lapsetotype, _ := this.GetInt64("lapsetotype")
  1853. sourcetype, _ := this.GetInt64("sourcetype")
  1854. adminUserInfo := this.GetAdminUserInfo()
  1855. orgId := adminUserInfo.CurrentOrgId
  1856. //统计当前机构转出的人数
  1857. rollout, err := service.GetCountRollout(orgId, start_time, end_time, lapsetotype, sourcetype)
  1858. if err != nil {
  1859. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1860. return
  1861. }
  1862. this.ServeSuccessJSON(map[string]interface{}{
  1863. "rollout": rollout,
  1864. })
  1865. }