common_api_controller.go 71KB

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