common_api_controller.go 75KB

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