inspection_api_controller.go 19KB

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