common_api_controller.go 73KB

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