common_api_controller.go 77KB

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