inspection_api_controller.go 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. type InspectionApiController struct {
  15. BaseAuthAPIController
  16. }
  17. func InspectionApiRegistRouters() {
  18. beego.Router("/api/patient/inspection/list", &InspectionApiController{}, "Get:GetPatientInspections")
  19. beego.Router("/api/patient/inspection/reference", &InspectionApiController{}, "Get:PatientInspectionReference")
  20. beego.Router("/api/patient/inspection/create", &InspectionApiController{}, "Post:CreatePatientInspection")
  21. beego.Router("/api/patient/inspection/edit", &InspectionApiController{}, "Put:EditPatientInspection")
  22. beego.Router("/api/patient/inspection/delete", &InspectionApiController{}, "Delete:DeletePatientInspection")
  23. beego.Router("/api/patient/inspection/get", &InspectionApiController{}, "Get:GetAllPatientInspection")
  24. beego.Router("/api/patient/inspectioninit/get", &InspectionApiController{}, "Get:GetInitInsepction")
  25. }
  26. //PatientInspectionReference 请求检验检查大小项目
  27. //[get]: /api/patient/inspection/reference
  28. func (c *InspectionApiController) PatientInspectionReference() {
  29. patient, _ := c.GetInt64("patient")
  30. if patient <= 0 {
  31. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  32. return
  33. }
  34. adminUserInfo := c.GetAdminUserInfo()
  35. references, err := service.GetInspectionReference(adminUserInfo.CurrentOrgId)
  36. if err != nil {
  37. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  38. return
  39. }
  40. patient_info, _ := service.GetPatientByID(adminUserInfo.CurrentOrgId, patient)
  41. counts, err := service.GetPatientInspectionProjectCount(adminUserInfo.CurrentOrgId, patient)
  42. if err != nil {
  43. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  44. return
  45. }
  46. countsMap := make(map[int64]int64, 0)
  47. for _, count := range counts {
  48. countsMap[count.ProjectId] = count.Count
  49. }
  50. referenceMap := make(map[string]*models.InspectionReferenceMap, 0)
  51. for _, reference := range references {
  52. if _, exist := referenceMap[reference.Project]; !exist {
  53. referenceMap[reference.Project] = new(models.InspectionReferenceMap)
  54. referenceMap[reference.Project].Project = reference.Project
  55. referenceMap[reference.Project].ProjectId = reference.ProjectId
  56. referenceMap[reference.Project].ProjectName = reference.ProjectName
  57. if _, cexit := countsMap[reference.ProjectId]; cexit {
  58. referenceMap[reference.Project].Count = countsMap[reference.ProjectId]
  59. }
  60. referenceMap[reference.Project].InspectionReference = make([]models.InspectionReference, 0)
  61. }
  62. referenceMap[reference.Project].InspectionReference = append(referenceMap[reference.Project].InspectionReference, *reference)
  63. }
  64. reference := make([]*models.InspectionReferenceMap, 0)
  65. for _, item := range referenceMap {
  66. reference = append(reference, item)
  67. }
  68. rl := len(reference)
  69. for index := 0; index < rl-1; index++ {
  70. for jndex := 0; jndex < rl-1-index; jndex++ {
  71. if reference[jndex].ProjectId > reference[jndex+1].ProjectId {
  72. var item models.InspectionReferenceMap
  73. item = *reference[jndex]
  74. reference[jndex] = reference[jndex+1]
  75. reference[jndex+1] = &item
  76. }
  77. }
  78. }
  79. c.ServeSuccessJSON(map[string]interface{}{
  80. "reference": reference,
  81. "patient_info": patient_info,
  82. })
  83. return
  84. }
  85. func (c *InspectionApiController) CreatePatientInspection() {
  86. patient, _ := c.GetInt64("patient", 0)
  87. remind_cycle, _ := c.GetInt64("remind_cycle", 0)
  88. if patient <= 0 {
  89. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  90. return
  91. }
  92. adminUserInfo := c.GetAdminUserInfo()
  93. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  94. if patientInfo.ID == 0 {
  95. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  96. return
  97. }
  98. var from models.InepectionForm
  99. err := json.Unmarshal(c.Ctx.Input.RequestBody, &from)
  100. if err != nil {
  101. utils.ErrorLog("%v", err)
  102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  103. return
  104. }
  105. timeLayout := "2006-01-02 15:04"
  106. loc, _ := time.LoadLocation("Local")
  107. theTime, err := time.ParseInLocation(timeLayout, from.InspectDate, loc)
  108. if err != nil {
  109. utils.ErrorLog(err.Error())
  110. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
  111. return
  112. }
  113. if len(from.FormItem) == 0 {
  114. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
  115. return
  116. }
  117. date := theTime.Unix()
  118. insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, from.ProjectId)
  119. if err != nil {
  120. utils.ErrorLog("%v", err)
  121. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  122. return
  123. }
  124. if len(insp) > 0 {
  125. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateExit)
  126. return
  127. }
  128. inspections := make([]models.Inspection, 0)
  129. for _, item := range from.FormItem {
  130. var inspection models.Inspection
  131. inspection.OrgId = adminUserInfo.CurrentOrgId
  132. inspection.PatientId = patient
  133. inspection.ProjectId = from.ProjectId
  134. inspection.ItemId = item.ItemId
  135. inspection.ItemName = item.ItemName
  136. inspection.ProjectName = item.ProjectName
  137. inspection.InspectType = item.RangeType
  138. inspection.InspectValue = item.Value
  139. inspection.InspectDate = date
  140. inspection.Status = 1
  141. inspection.CreatedTime = time.Now().Unix()
  142. inspection.UpdatedTime = time.Now().Unix()
  143. inspections = append(inspections, inspection)
  144. }
  145. err = service.CreatePatientInspection(inspections)
  146. if err != nil {
  147. utils.ErrorLog("%v", err)
  148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionAddFail)
  149. return
  150. }
  151. if remind_cycle > 0 {
  152. infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, 14)
  153. fmt.Println(infectiousRecord.InspectDate)
  154. var record_time int64
  155. switch remind_cycle {
  156. case 1: //1个月
  157. ts := time.Unix(infectiousRecord.InspectDate, 0)
  158. record_time = ts.AddDate(0, 1, 0).Unix()
  159. fmt.Println(record_time)
  160. break
  161. case 2: //2个月
  162. ts := time.Unix(infectiousRecord.InspectDate, 0)
  163. record_time = ts.AddDate(0, 2, 0).Unix()
  164. fmt.Println(record_time)
  165. break
  166. case 3: //3个月
  167. ts := time.Unix(infectiousRecord.InspectDate, 0)
  168. record_time = ts.AddDate(0, 3, 0).Unix()
  169. fmt.Println(record_time)
  170. break
  171. case 4: //6个月
  172. ts := time.Unix(infectiousRecord.InspectDate, 0)
  173. record_time = ts.AddDate(0, 6, 0).Unix()
  174. fmt.Println(record_time)
  175. break
  176. case 5: //12个月
  177. ts := time.Unix(infectiousRecord.InspectDate, 0)
  178. record_time = ts.AddDate(0, 12, 0).Unix()
  179. fmt.Println(record_time)
  180. break
  181. }
  182. errs := service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
  183. if errs != nil {
  184. utils.ErrorLog("更新日期出错:%v", errs)
  185. }
  186. }
  187. c.ServeSuccessJSON(map[string]interface{}{
  188. "inspections": inspections,
  189. "remind_cycle": remind_cycle,
  190. })
  191. return
  192. }
  193. func (c *InspectionApiController) EditPatientInspection() {
  194. patient, _ := c.GetInt64("patient", 0)
  195. remind_cycle, _ := c.GetInt64("remind_cycle", 0)
  196. // dates := c.GetString("dates")
  197. // projectid := c.GetString("projectid")
  198. if patient <= 0 {
  199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  200. return
  201. }
  202. adminUserInfo := c.GetAdminUserInfo()
  203. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  204. if patientInfo.ID == 0 {
  205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  206. return
  207. }
  208. var from models.InepectionForm
  209. err := json.Unmarshal(c.Ctx.Input.RequestBody, &from)
  210. if err != nil {
  211. utils.ErrorLog("%v", err)
  212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  213. return
  214. }
  215. timeLayout := "2006-01-02 15:04"
  216. loc, _ := time.LoadLocation("Local")
  217. theTime, err := time.ParseInLocation(timeLayout, from.InspectDate , loc)
  218. if err != nil {
  219. utils.ErrorLog(err.Error())
  220. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
  221. return
  222. }
  223. oldTime, olderr := time.ParseInLocation(timeLayout, from.OldInspectDate , loc)
  224. if olderr != nil {
  225. utils.ErrorLog(olderr.Error())
  226. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
  227. return
  228. }
  229. if len(from.FormItem) == 0 {
  230. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
  231. return
  232. }
  233. date := theTime.Unix()
  234. oldDate := oldTime.Unix()
  235. insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, oldDate, from.ProjectId)
  236. if err != nil {
  237. utils.ErrorLog("%v", err)
  238. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  239. return
  240. }
  241. if len(insp) == 0 {
  242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
  243. return
  244. }
  245. inspMap := make(map[int64]*models.Inspection)
  246. for _, item := range insp {
  247. inspMap[item.ID] = item
  248. }
  249. addinsp := make([]models.Inspection, 0)
  250. editinsp := make([]models.Inspection, 0)
  251. noMap := make([]int64, 0)
  252. fmt.Println(from.FormItem)
  253. for _, item := range from.FormItem {
  254. fmt.Println(item.ID)
  255. if item.ID == 0 {
  256. var inspection models.Inspection
  257. inspection.OrgId = adminUserInfo.CurrentOrgId
  258. inspection.PatientId = patient
  259. inspection.ProjectId = from.ProjectId
  260. inspection.ItemId = item.ItemId
  261. inspection.ItemName = item.ItemName
  262. inspection.ProjectName = item.ProjectName
  263. inspection.InspectType = item.RangeType
  264. inspection.InspectValue = item.Value
  265. inspection.InspectDate = date
  266. inspection.Status = 1
  267. inspection.CreatedTime = time.Now().Unix()
  268. inspection.UpdatedTime = time.Now().Unix()
  269. addinsp = append(addinsp, inspection)
  270. } else {
  271. inspection := *inspMap[item.ID]
  272. inspection.InspectValue = item.Value
  273. inspection.InspectDate = date
  274. inspection.UpdatedTime = time.Now().Unix()
  275. editinsp = append(editinsp, inspection)
  276. noMap = append(noMap, item.ID)
  277. }
  278. }
  279. err = service.EditPatientInspection(addinsp, editinsp, noMap, patient, adminUserInfo.CurrentOrgId, from.ProjectId, date)
  280. if err != nil {
  281. utils.ErrorLog("%v", err)
  282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionEditFail)
  283. return
  284. }
  285. inspections := make([]models.Inspection, 0)
  286. inspections = append(inspections, editinsp...)
  287. inspections = append(inspections, addinsp...)
  288. if remind_cycle > 0 {
  289. infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, 14)
  290. fmt.Println(infectiousRecord.InspectDate)
  291. var record_time int64
  292. switch remind_cycle {
  293. case 1: //1个月
  294. ts := time.Unix(infectiousRecord.InspectDate, 0)
  295. record_time = ts.AddDate(0, 1, 0).Unix()
  296. break
  297. case 2: //2个月
  298. ts := time.Unix(infectiousRecord.InspectDate, 0)
  299. record_time = ts.AddDate(0, 2, 0).Unix()
  300. break
  301. case 3: //3个月
  302. ts := time.Unix(infectiousRecord.InspectDate, 0)
  303. record_time = ts.AddDate(0, 3, 0).Unix()
  304. break
  305. case 4: //6个月
  306. ts := time.Unix(infectiousRecord.InspectDate, 0)
  307. record_time = ts.AddDate(0, 6, 0).Unix()
  308. break
  309. case 5: //12个月
  310. ts := time.Unix(infectiousRecord.InspectDate, 0)
  311. record_time = ts.AddDate(0, 12, 0).Unix()
  312. break
  313. }
  314. fmt.Println(record_time)
  315. errs := service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
  316. if errs != nil {
  317. utils.ErrorLog("更新日期出错:%v", errs)
  318. }
  319. }
  320. c.ServeSuccessJSON(map[string]interface{}{
  321. "inspections": inspections,
  322. "remind_cycle": remind_cycle,
  323. })
  324. return
  325. }
  326. func (c *InspectionApiController) DeletePatientInspection() {
  327. patient, _ := c.GetInt64("patient", 0)
  328. ProjectId, _ := c.GetInt64("project_id", 0)
  329. InspectDate := c.GetString("date")
  330. if patient <= 0 || ProjectId <= 0 || len(InspectDate) < 10 {
  331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  332. return
  333. }
  334. timeLayout := "2006-01-02 15:04"
  335. loc, _ := time.LoadLocation("Local")
  336. theTime, err := time.ParseInLocation(timeLayout, InspectDate, loc)
  337. if err != nil {
  338. utils.ErrorLog(err.Error())
  339. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
  340. return
  341. }
  342. adminUserInfo := c.GetAdminUserInfo()
  343. date := theTime.Unix()
  344. insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, ProjectId)
  345. if err != nil {
  346. utils.ErrorLog("%v", err)
  347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  348. return
  349. }
  350. if len(insp) == 0 {
  351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
  352. return
  353. }
  354. err = service.DeletePatientInspection(adminUserInfo.CurrentOrgId, patient, ProjectId, date)
  355. if err != nil {
  356. utils.ErrorLog("%v", err)
  357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDeleteFail)
  358. return
  359. }
  360. c.ServeSuccessJSON(map[string]interface{}{
  361. "msg": "ok",
  362. })
  363. return
  364. }
  365. func (c *InspectionApiController) GetPatientInspections() {
  366. patient, _ := c.GetInt64("patient", 0)
  367. projectId, _ := c.GetInt64("project_id", 0)
  368. if patient <= 0 || projectId <= 0 {
  369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  370. return
  371. }
  372. page, _ := c.GetInt64("page", 0)
  373. if page <= 0 {
  374. page = 1
  375. }
  376. adminUserInfo := c.GetAdminUserInfo()
  377. inspections, total, dateTime, err := service.GetPatientInspections(adminUserInfo.CurrentOrgId, patient, projectId, page)
  378. if err != nil {
  379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  380. return
  381. }
  382. date := ""
  383. if len(inspections) > 0 {
  384. date = time.Unix(dateTime, 0).Format("2006-01-02 15:04")
  385. }
  386. c.ServeSuccessJSON(map[string]interface{}{
  387. "inspections": inspections,
  388. "total": total,
  389. "date": date,
  390. })
  391. return
  392. }
  393. func (c *InspectionApiController) GetAllPatientInspection() {
  394. patient, _ := c.GetInt64("patient", 0)
  395. projectStr := c.GetString("project")
  396. start_time, _ := c.GetInt64("start_time")
  397. end_time, _ := c.GetInt64("end_time")
  398. upload_type, _ := c.GetInt64("type")
  399. ids := strings.Split(projectStr, "-")
  400. if patient <= 0 {
  401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  402. return
  403. }
  404. page, _ := c.GetInt64("page", 0)
  405. if page <= 0 {
  406. page = 1
  407. }
  408. adminUserInfo := c.GetAdminUserInfo()
  409. switch upload_type {
  410. case 1:
  411. var inspections []*models.Inspection
  412. for _, item := range ids {
  413. id, _ := strconv.ParseInt(item, 10, 64)
  414. inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
  415. //fmt.Println(err)
  416. //if err != nil {
  417. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  418. // return
  419. //}
  420. for _, inspection_item := range inspection {
  421. inspections = append(inspections, inspection_item)
  422. }
  423. }
  424. c.ServeSuccessJSON(map[string]interface{}{
  425. "inspections": inspections,
  426. "type": upload_type,
  427. })
  428. break
  429. case 2:
  430. id_one, _ := strconv.ParseInt(ids[0], 10, 64)
  431. id_two, _ := strconv.ParseInt(ids[1], 10, 64)
  432. id_three, _ := strconv.ParseInt(ids[2], 10, 64)
  433. inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
  434. inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
  435. inspection_three, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_three, start_time, end_time)
  436. c.ServeSuccessJSON(map[string]interface{}{
  437. "inspections_one": inspection_one,
  438. "inspections_two": inspection_two,
  439. "inspections_three": inspection_three,
  440. "type": upload_type,
  441. })
  442. break
  443. case 3:
  444. var inspections []*models.Inspection
  445. for _, item := range ids {
  446. id, _ := strconv.ParseInt(item, 10, 64)
  447. inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
  448. //fmt.Println(err)
  449. //if err != nil {
  450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  451. // return
  452. //}
  453. for _, inspection_item := range inspection {
  454. inspections = append(inspections, inspection_item)
  455. }
  456. }
  457. c.ServeSuccessJSON(map[string]interface{}{
  458. "inspections": inspections,
  459. "type": upload_type,
  460. })
  461. break
  462. case 4:
  463. id_one, _ := strconv.ParseInt(ids[0], 10, 64)
  464. id_two, _ := strconv.ParseInt(ids[1], 10, 64)
  465. id_three, _ := strconv.ParseInt(ids[2], 10, 64)
  466. id_four, _ := strconv.ParseInt(ids[3], 10, 64)
  467. id_five, _ := strconv.ParseInt(ids[4], 10, 64)
  468. inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
  469. inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
  470. inspection_three, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_three, start_time, end_time)
  471. inspection_four, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_four, start_time, end_time)
  472. inspection_five, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_five, start_time, end_time)
  473. c.ServeSuccessJSON(map[string]interface{}{
  474. "inspections_one": inspection_one,
  475. "inspections_two": inspection_two,
  476. "inspections_three": inspection_three,
  477. "inspections_four": inspection_four,
  478. "inspections_five": inspection_five,
  479. "type": upload_type,
  480. })
  481. break
  482. case 5:
  483. id_one, _ := strconv.ParseInt(ids[0], 10, 64)
  484. id_two, _ := strconv.ParseInt(ids[1], 10, 64)
  485. inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
  486. inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
  487. c.ServeSuccessJSON(map[string]interface{}{
  488. "inspections_one": inspection_one,
  489. "inspections_two": inspection_two,
  490. "type": upload_type,
  491. })
  492. break
  493. case 6:
  494. var inspections []*models.Inspection
  495. for _, item := range ids {
  496. id, _ := strconv.ParseInt(item, 10, 64)
  497. inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
  498. //fmt.Println(err)
  499. //if err != nil {
  500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  501. // return
  502. //}
  503. for _, inspection_item := range inspection {
  504. inspections = append(inspections, inspection_item)
  505. }
  506. }
  507. c.ServeSuccessJSON(map[string]interface{}{
  508. "inspections": inspections,
  509. "type": upload_type,
  510. })
  511. break
  512. case 7:
  513. var inspections []*models.Inspection
  514. for _, item := range ids {
  515. id, _ := strconv.ParseInt(item, 10, 64)
  516. inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
  517. //fmt.Println(err)
  518. //if err != nil {
  519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  520. // return
  521. //}
  522. for _, inspection_item := range inspection {
  523. inspections = append(inspections, inspection_item)
  524. }
  525. }
  526. c.ServeSuccessJSON(map[string]interface{}{
  527. "inspections": inspections,
  528. "type": upload_type,
  529. })
  530. break
  531. }
  532. return
  533. }
  534. func (c *InspectionApiController) GetInitInsepction() {
  535. references, _ := service.GetAllInspectionReference(0)
  536. c.ServeSuccessJSON(map[string]interface{}{
  537. "references": references,
  538. })
  539. return
  540. }