common_api_controller.go 76KB

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