common_api_controller.go 77KB

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