inspection_api_controller.go 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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:05"
  106. loc, _ := time.LoadLocation("Local")
  107. theTime, err := time.ParseInLocation(timeLayout, from.InspectDate+" 00:00:00", 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. if patient <= 0 {
  197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  198. return
  199. }
  200. adminUserInfo := c.GetAdminUserInfo()
  201. patientInfo, _ := service.FindPatientById(adminUserInfo.CurrentOrgId, patient)
  202. if patientInfo.ID == 0 {
  203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  204. return
  205. }
  206. var from models.InepectionForm
  207. err := json.Unmarshal(c.Ctx.Input.RequestBody, &from)
  208. if err != nil {
  209. utils.ErrorLog("%v", err)
  210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  211. return
  212. }
  213. timeLayout := "2006-01-02 15:04:05"
  214. loc, _ := time.LoadLocation("Local")
  215. theTime, err := time.ParseInLocation(timeLayout, from.InspectDate+" 00:00:00", loc)
  216. if err != nil {
  217. utils.ErrorLog(err.Error())
  218. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
  219. return
  220. }
  221. if len(from.FormItem) == 0 {
  222. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "未填写项目")
  223. return
  224. }
  225. date := theTime.Unix()
  226. insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, from.ProjectId)
  227. if err != nil {
  228. utils.ErrorLog("%v", err)
  229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  230. return
  231. }
  232. if len(insp) == 0 {
  233. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
  234. return
  235. }
  236. inspMap := make(map[int64]*models.Inspection)
  237. for _, item := range insp {
  238. inspMap[item.ID] = item
  239. }
  240. addinsp := make([]models.Inspection, 0)
  241. editinsp := make([]models.Inspection, 0)
  242. noMap := make([]int64, 0)
  243. fmt.Println(from.FormItem)
  244. for _, item := range from.FormItem {
  245. fmt.Println(item.ID)
  246. if item.ID == 0 {
  247. var inspection models.Inspection
  248. inspection.OrgId = adminUserInfo.CurrentOrgId
  249. inspection.PatientId = patient
  250. inspection.ProjectId = from.ProjectId
  251. inspection.ItemId = item.ItemId
  252. inspection.ItemName = item.ItemName
  253. inspection.ProjectName = item.ProjectName
  254. inspection.InspectType = item.RangeType
  255. inspection.InspectValue = item.Value
  256. inspection.InspectDate = date
  257. inspection.Status = 1
  258. inspection.CreatedTime = time.Now().Unix()
  259. inspection.UpdatedTime = time.Now().Unix()
  260. addinsp = append(addinsp, inspection)
  261. } else if _, exi := inspMap[item.ID]; exi {
  262. fmt.Println("2222222222")
  263. inspection := *inspMap[item.ID]
  264. inspection.InspectValue = item.Value
  265. inspection.UpdatedTime = time.Now().Unix()
  266. editinsp = append(editinsp, inspection)
  267. noMap = append(noMap, item.ID)
  268. }
  269. }
  270. err = service.EditPatientInspection(addinsp, editinsp, noMap, patient, adminUserInfo.CurrentOrgId, from.ProjectId, date)
  271. if err != nil {
  272. utils.ErrorLog("%v", err)
  273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionEditFail)
  274. return
  275. }
  276. inspections := make([]models.Inspection, 0)
  277. inspections = append(inspections, editinsp...)
  278. inspections = append(inspections, addinsp...)
  279. if remind_cycle > 0 {
  280. infectiousRecord, _ := service.FindLastRecordDate(adminUserInfo.CurrentOrgId, patient, 14)
  281. fmt.Println(infectiousRecord.InspectDate)
  282. var record_time int64
  283. switch remind_cycle {
  284. case 1: //1个月
  285. ts := time.Unix(infectiousRecord.InspectDate, 0)
  286. record_time = ts.AddDate(0, 1, 0).Unix()
  287. break
  288. case 2: //2个月
  289. ts := time.Unix(infectiousRecord.InspectDate, 0)
  290. record_time = ts.AddDate(0, 2, 0).Unix()
  291. break
  292. case 3: //3个月
  293. ts := time.Unix(infectiousRecord.InspectDate, 0)
  294. record_time = ts.AddDate(0, 3, 0).Unix()
  295. break
  296. case 4: //6个月
  297. ts := time.Unix(infectiousRecord.InspectDate, 0)
  298. record_time = ts.AddDate(0, 6, 0).Unix()
  299. break
  300. case 5: //12个月
  301. ts := time.Unix(infectiousRecord.InspectDate, 0)
  302. record_time = ts.AddDate(0, 12, 0).Unix()
  303. break
  304. }
  305. fmt.Println(record_time)
  306. errs := service.UpDateInfectiousRecordTime(adminUserInfo.CurrentOrgId, patient, record_time, remind_cycle)
  307. if errs != nil {
  308. utils.ErrorLog("更新日期出错:%v", errs)
  309. }
  310. }
  311. c.ServeSuccessJSON(map[string]interface{}{
  312. "inspections": inspections,
  313. "remind_cycle": remind_cycle,
  314. })
  315. return
  316. }
  317. func (c *InspectionApiController) DeletePatientInspection() {
  318. patient, _ := c.GetInt64("patient", 0)
  319. ProjectId, _ := c.GetInt64("project_id", 0)
  320. InspectDate := c.GetString("date")
  321. if patient <= 0 || ProjectId <= 0 || len(InspectDate) != 10 {
  322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  323. return
  324. }
  325. timeLayout := "2006-01-02 15:04:05"
  326. loc, _ := time.LoadLocation("Local")
  327. theTime, err := time.ParseInLocation(timeLayout, InspectDate+" 00:00:00", loc)
  328. if err != nil {
  329. utils.ErrorLog(err.Error())
  330. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "检验日期不正确")
  331. return
  332. }
  333. adminUserInfo := c.GetAdminUserInfo()
  334. date := theTime.Unix()
  335. insp, err := service.GetPatientInspectionByDate(adminUserInfo.CurrentOrgId, patient, date, ProjectId)
  336. if err != nil {
  337. utils.ErrorLog("%v", err)
  338. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  339. return
  340. }
  341. if len(insp) == 0 {
  342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDateNotExit)
  343. return
  344. }
  345. err = service.DeletePatientInspection(adminUserInfo.CurrentOrgId, patient, ProjectId, date)
  346. if err != nil {
  347. utils.ErrorLog("%v", err)
  348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInspectionDeleteFail)
  349. return
  350. }
  351. c.ServeSuccessJSON(map[string]interface{}{
  352. "msg": "ok",
  353. })
  354. return
  355. }
  356. func (c *InspectionApiController) GetPatientInspections() {
  357. patient, _ := c.GetInt64("patient", 0)
  358. projectId, _ := c.GetInt64("project_id", 0)
  359. if patient <= 0 || projectId <= 0 {
  360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  361. return
  362. }
  363. page, _ := c.GetInt64("page", 0)
  364. if page <= 0 {
  365. page = 1
  366. }
  367. adminUserInfo := c.GetAdminUserInfo()
  368. inspections, total, dateTime, err := service.GetPatientInspections(adminUserInfo.CurrentOrgId, patient, projectId, page)
  369. if err != nil {
  370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  371. return
  372. }
  373. date := ""
  374. if len(inspections) > 0 {
  375. date = time.Unix(dateTime, 0).Format("2006-01-02")
  376. }
  377. c.ServeSuccessJSON(map[string]interface{}{
  378. "inspections": inspections,
  379. "total": total,
  380. "date": date,
  381. })
  382. return
  383. }
  384. func (c *InspectionApiController) GetAllPatientInspection() {
  385. patient, _ := c.GetInt64("patient", 0)
  386. projectStr := c.GetString("project")
  387. start_time, _ := c.GetInt64("start_time")
  388. end_time, _ := c.GetInt64("end_time")
  389. upload_type, _ := c.GetInt64("type")
  390. ids := strings.Split(projectStr, "-")
  391. if patient <= 0 {
  392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  393. return
  394. }
  395. page, _ := c.GetInt64("page", 0)
  396. if page <= 0 {
  397. page = 1
  398. }
  399. adminUserInfo := c.GetAdminUserInfo()
  400. switch upload_type {
  401. case 1:
  402. var inspections []*models.Inspection
  403. for _, item := range ids {
  404. id, _ := strconv.ParseInt(item, 10, 64)
  405. inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
  406. //fmt.Println(err)
  407. //if err != nil {
  408. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  409. // return
  410. //}
  411. for _, inspection_item := range inspection {
  412. inspections = append(inspections, inspection_item)
  413. }
  414. }
  415. c.ServeSuccessJSON(map[string]interface{}{
  416. "inspections": inspections,
  417. "type": upload_type,
  418. })
  419. break
  420. case 2:
  421. id_one, _ := strconv.ParseInt(ids[0], 10, 64)
  422. id_two, _ := strconv.ParseInt(ids[1], 10, 64)
  423. id_three, _ := strconv.ParseInt(ids[2], 10, 64)
  424. inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
  425. inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
  426. inspection_three, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_three, start_time, end_time)
  427. c.ServeSuccessJSON(map[string]interface{}{
  428. "inspections_one": inspection_one,
  429. "inspections_two": inspection_two,
  430. "inspections_three": inspection_three,
  431. "type": upload_type,
  432. })
  433. break
  434. case 3:
  435. var inspections []*models.Inspection
  436. for _, item := range ids {
  437. id, _ := strconv.ParseInt(item, 10, 64)
  438. inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
  439. //fmt.Println(err)
  440. //if err != nil {
  441. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  442. // return
  443. //}
  444. for _, inspection_item := range inspection {
  445. inspections = append(inspections, inspection_item)
  446. }
  447. }
  448. c.ServeSuccessJSON(map[string]interface{}{
  449. "inspections": inspections,
  450. "type": upload_type,
  451. })
  452. break
  453. case 4:
  454. id_one, _ := strconv.ParseInt(ids[0], 10, 64)
  455. id_two, _ := strconv.ParseInt(ids[1], 10, 64)
  456. id_three, _ := strconv.ParseInt(ids[2], 10, 64)
  457. id_four, _ := strconv.ParseInt(ids[3], 10, 64)
  458. id_five, _ := strconv.ParseInt(ids[4], 10, 64)
  459. inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
  460. inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
  461. inspection_three, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_three, start_time, end_time)
  462. inspection_four, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_four, start_time, end_time)
  463. inspection_five, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_five, start_time, end_time)
  464. c.ServeSuccessJSON(map[string]interface{}{
  465. "inspections_one": inspection_one,
  466. "inspections_two": inspection_two,
  467. "inspections_three": inspection_three,
  468. "inspections_four": inspection_four,
  469. "inspections_five": inspection_five,
  470. "type": upload_type,
  471. })
  472. break
  473. case 5:
  474. id_one, _ := strconv.ParseInt(ids[0], 10, 64)
  475. id_two, _ := strconv.ParseInt(ids[1], 10, 64)
  476. inspection_one, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_one, start_time, end_time)
  477. inspection_two, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id_two, start_time, end_time)
  478. c.ServeSuccessJSON(map[string]interface{}{
  479. "inspections_one": inspection_one,
  480. "inspections_two": inspection_two,
  481. "type": upload_type,
  482. })
  483. break
  484. case 6:
  485. var inspections []*models.Inspection
  486. for _, item := range ids {
  487. id, _ := strconv.ParseInt(item, 10, 64)
  488. inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
  489. //fmt.Println(err)
  490. //if err != nil {
  491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  492. // return
  493. //}
  494. for _, inspection_item := range inspection {
  495. inspections = append(inspections, inspection_item)
  496. }
  497. }
  498. c.ServeSuccessJSON(map[string]interface{}{
  499. "inspections": inspections,
  500. "type": upload_type,
  501. })
  502. break
  503. case 7:
  504. var inspections []*models.Inspection
  505. for _, item := range ids {
  506. id, _ := strconv.ParseInt(item, 10, 64)
  507. inspection, _, _ := service.GetAllPatientInspection(adminUserInfo.CurrentOrgId, patient, page, id, start_time, end_time)
  508. //fmt.Println(err)
  509. //if err != nil {
  510. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  511. // return
  512. //}
  513. for _, inspection_item := range inspection {
  514. inspections = append(inspections, inspection_item)
  515. }
  516. }
  517. c.ServeSuccessJSON(map[string]interface{}{
  518. "inspections": inspections,
  519. "type": upload_type,
  520. })
  521. break
  522. }
  523. return
  524. }
  525. func (c *InspectionApiController) GetInitInsepction() {
  526. references, _ := service.GetAllInspectionReference(0)
  527. c.ServeSuccessJSON(map[string]interface{}{
  528. "references": references,
  529. })
  530. return
  531. }