common_api_controller.go 75KB

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