common_api_controller.go 74KB

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