pharmacy_controller.go 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "fmt"
  8. "github.com/astaxie/beego"
  9. "time"
  10. )
  11. type PharmacyController struct {
  12. BaseAuthAPIController
  13. }
  14. func PharmacyApiRegistRouters() {
  15. beego.Router("/api/pharmacy/ceshili", &PharmacyController{}, "get:Tlili")
  16. beego.Router("/api/pharmacy/todaynumber", &PharmacyController{}, "get:TodayNumber") //查询今天的待发药,已发药人数(
  17. beego.Router("/api/pharmacy/waitingdrug", &PharmacyController{}, "get:WaitingDrug") //获取当天待发药的所有患者(
  18. beego.Router("/api/pharmacy/issueddrugs", &PharmacyController{}, "get:IssuedDrug") //获取当天已发药的所有患者(
  19. beego.Router("/api/pharmacy/getpharmacycontent", &PharmacyController{}, "get:GetPharmacyContent") //获取当天该患者的所有信息(
  20. beego.Router("/api/pharmacy/dispensingmedicine", &PharmacyController{}, "get:DispensingMedicine") //患者发药按钮点击(
  21. beego.Router("/api/pharmacy/drugwithdrawal", &PharmacyController{}, "get:DrugWithdrawal") //退药按钮点击
  22. beego.Router("/api/pharmacy/dispensingdetails", &PharmacyController{}, "get:DispensingDetails") //获取发药明细的患者列表(
  23. beego.Router("/api/pharmacy/prescriptiondetails", &PharmacyController{}, "get:PrescriptionDetails") //发药明细-详情(
  24. beego.Router("/api/pharmacy/dispensemedicine", &PharmacyController{}, "get:DispenseMedicine") //获取当天已发药的药品(
  25. beego.Router("/api/pharmacy/waitingmedicine", &PharmacyController{}, "get:WaitingMedicine") //获取当天待发药的药品(
  26. beego.Router("/api/pharmacy/getpatientswithdrugs", &PharmacyController{}, "get:GetPatientsWithDrugs") //获取当天该药品的所有患者(
  27. beego.Router("/api/pharmacy/medicinedeparture", &PharmacyController{}, "get:MedicineDeparture") //药品发药按钮点击(
  28. beego.Router("/api/pharmacy/getcurrentname", &PharmacyController{}, "get:GetCurrentName") //获取当前登录账号的名字(
  29. beego.Router("/api/pharmacy/getpartitionlist", &PharmacyController{}, "get:GetPartitionList") //获取当前机构的分区列表
  30. beego.Router("/api/pharmacy/routeofadministration", &PharmacyController{}, "get:RouteOfAdministration") //获取当前机构的给药途径
  31. }
  32. func (this *PharmacyController) Tlili() {
  33. var err error
  34. defer func() {
  35. if rec := recover(); rec != nil {
  36. err = fmt.Errorf("程序异常:%v", rec)
  37. }
  38. if err != nil {
  39. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  40. }
  41. }()
  42. var list2 []*models.ReplacementDrugs
  43. list2, err = service.ReplacementDrugs(9675, false)
  44. if err != nil {
  45. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  46. return
  47. }
  48. this.ServeSuccessJSON(map[string]interface{}{
  49. "list": list2,
  50. })
  51. return
  52. }
  53. func (this *PharmacyController) GetCurrentName() {
  54. create := this.GetAdminUserInfo().AdminUser.Id
  55. this.ServeSuccessJSON(map[string]interface{}{
  56. "list": create,
  57. })
  58. return
  59. }
  60. //查询今天的待发药,已发药人数
  61. func (this *PharmacyController) TodayNumber() {
  62. var err error
  63. defer func() {
  64. if rec := recover(); rec != nil {
  65. err = fmt.Errorf("程序异常:%v", rec)
  66. }
  67. if err != nil {
  68. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  69. }
  70. }()
  71. orgid := this.GetAdminUserInfo().CurrentOrgId
  72. times := this.GetString("time", "")
  73. timeLayout := "2006-01-02"
  74. loc, _ := time.LoadLocation("Local")
  75. var stime, etime int64
  76. if times == "" {
  77. stime, etime = service.GetNowTime()
  78. } else {
  79. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  80. stime = stmp.Unix()
  81. etime = stime + 86399
  82. }
  83. //查询表里当天的数据
  84. var wtotal int
  85. wtotal, err = service.GetTodayPharmacy(stime, etime, orgid, 1)
  86. if err != nil {
  87. utils.ErrorLog(err.Error())
  88. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  89. return
  90. }
  91. var itotal int
  92. itotal, err = service.GetTodayPharmacy(stime, etime, orgid, 0)
  93. if err != nil {
  94. utils.ErrorLog(err.Error())
  95. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  96. return
  97. }
  98. this.ServeSuccessJSON(map[string]interface{}{
  99. "wtotal": wtotal,
  100. "itotal": itotal,
  101. })
  102. return
  103. }
  104. func (this *PharmacyController) IssuedDrug() {
  105. var err error
  106. defer func() {
  107. if rec := recover(); rec != nil {
  108. err = fmt.Errorf("程序异常:%v", rec)
  109. }
  110. if err != nil {
  111. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  112. }
  113. }()
  114. keyword := this.GetString("keyword", "")
  115. times := this.GetString("time", "")
  116. orgid := this.GetAdminUserInfo().CurrentOrgId
  117. shift, err := this.GetInt64("shift", 0) //班次
  118. if err != nil {
  119. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  120. return
  121. }
  122. partition, err := this.GetInt64("partition", 0) //分区
  123. if err != nil {
  124. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  125. return
  126. }
  127. timeLayout := "2006-01-02"
  128. loc, _ := time.LoadLocation("Local")
  129. var stime, etime int64
  130. if times == "" {
  131. stime, etime = service.GetNowTime()
  132. } else {
  133. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  134. stime = stmp.Unix()
  135. etime = stime + 86399
  136. }
  137. //查询表里当天的数据
  138. var flist []*models.TmpPatient
  139. flist, err = service.GetTodayDrug(stime, etime, orgid, 1, keyword)
  140. if err != nil {
  141. utils.ErrorLog(err.Error())
  142. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  143. return
  144. }
  145. listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
  146. if err != nil {
  147. utils.ErrorLog(err.Error())
  148. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  149. return
  150. }
  151. this.ServeSuccessJSON(map[string]interface{}{
  152. "list": listt,
  153. })
  154. return
  155. }
  156. func (this *PharmacyController) WaitingDrug() {
  157. var err error
  158. defer func() {
  159. if rec := recover(); rec != nil {
  160. err = fmt.Errorf("程序异常:%v", rec)
  161. }
  162. if err != nil {
  163. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  164. }
  165. }()
  166. keyword := this.GetString("keyword", "")
  167. times := this.GetString("time", "")
  168. shift, err := this.GetInt64("shift", 0) //班次
  169. if err != nil {
  170. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  171. return
  172. }
  173. partition, err := this.GetInt64("partition", 0) //分区
  174. if err != nil {
  175. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  176. return
  177. }
  178. orgid := this.GetAdminUserInfo().CurrentOrgId
  179. timeLayout := "2006-01-02"
  180. loc, _ := time.LoadLocation("Local")
  181. var stime, etime int64
  182. if times == "" {
  183. stime, etime = service.GetNowTime()
  184. } else {
  185. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  186. stime = stmp.Unix()
  187. etime = stime + 86399
  188. }
  189. //查询表里当天的数据
  190. var flist []*models.TmpPatient
  191. flist, err = service.GetTodayDrug(stime, etime, orgid, 0, keyword)
  192. if err != nil {
  193. utils.ErrorLog(err.Error())
  194. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  195. return
  196. }
  197. listt, err := service.PartitionAndLayout(stime, etime, orgid, shift, partition, flist)
  198. if err != nil {
  199. utils.ErrorLog(err.Error())
  200. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  201. return
  202. }
  203. this.ServeSuccessJSON(map[string]interface{}{
  204. "list": listt,
  205. })
  206. return
  207. }
  208. //
  209. func (this *PharmacyController) GetPharmacyContent() {
  210. var err error
  211. defer func() {
  212. if rec := recover(); rec != nil {
  213. err = fmt.Errorf("程序异常:%v", rec)
  214. }
  215. if err != nil {
  216. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  217. }
  218. }()
  219. patient_id, _ := this.GetInt64("patient_id", 0)
  220. is_medicine, _ := this.GetInt64("is_medicine", 0) //0:待发药,1:已发药
  221. times := this.GetString("time", "")
  222. orgid := this.GetAdminUserInfo().CurrentOrgId
  223. timeLayout := "2006-01-02"
  224. loc, _ := time.LoadLocation("Local")
  225. var stime, etime int64
  226. if times == "" {
  227. stime, etime = service.GetNowTime()
  228. } else {
  229. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  230. stime = stmp.Unix()
  231. etime = stime + 86399
  232. }
  233. var list []*models.PharmacyContent
  234. list, err = service.GetPatientMedication(orgid, patient_id, stime, etime, is_medicine)
  235. if err != nil {
  236. utils.ErrorLog(err.Error())
  237. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  238. return
  239. }
  240. return_value := make(map[string]interface{})
  241. return_value["list"] = list
  242. //if is_medicine == 1{发药时间先不展示
  243. // return_value["time"] = time
  244. //}
  245. this.ServeSuccessJSON(return_value)
  246. return
  247. }
  248. //发药按钮点击
  249. func (this *PharmacyController) DispensingMedicine() {
  250. var err error
  251. defer func() {
  252. if rec := recover(); rec != nil {
  253. err = fmt.Errorf("程序异常:%v", rec)
  254. }
  255. if err != nil {
  256. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  257. }
  258. }()
  259. patient_id, _ := this.GetInt64("patient_id", 0)
  260. times := this.GetString("time", "")
  261. orgid := this.GetAdminUserInfo().CurrentOrgId
  262. creater := this.GetAdminUserInfo().AdminUser.Id
  263. timeLayout := "2006-01-02"
  264. loc, _ := time.LoadLocation("Local")
  265. var stime, etime int64
  266. if times == "" {
  267. stime, etime = service.GetNowTime()
  268. } else {
  269. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  270. stime = stmp.Unix()
  271. etime = stime + 86399
  272. }
  273. err = service.DispensingMedicine(orgid, patient_id, stime, etime, creater)
  274. if err != nil {
  275. utils.ErrorLog(err.Error())
  276. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  277. return
  278. }
  279. this.ServeSuccessJSON(map[string]interface{}{
  280. "list": "操作成功",
  281. })
  282. return
  283. }
  284. //退药按钮点击
  285. func (this *PharmacyController) DrugWithdrawal() {
  286. var err error
  287. defer func() {
  288. if rec := recover(); rec != nil {
  289. err = fmt.Errorf("程序异常:%v", rec)
  290. }
  291. if err != nil {
  292. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  293. }
  294. }()
  295. patient_id, _ := this.GetInt64("patient_id", 0)
  296. times := this.GetString("time", "")
  297. orgid := this.GetAdminUserInfo().CurrentOrgId
  298. creater := this.GetAdminUserInfo().AdminUser.Id
  299. timeLayout := "2006-01-02"
  300. loc, _ := time.LoadLocation("Local")
  301. var stime, etime int64
  302. if times == "" {
  303. stime, etime = service.GetNowTime()
  304. } else {
  305. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  306. stime = stmp.Unix()
  307. etime = stime + 86399
  308. }
  309. err = service.DrugWithdrawal(orgid, patient_id, stime, etime, creater)
  310. if err != nil {
  311. utils.ErrorLog(err.Error())
  312. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  313. return
  314. }
  315. this.ServeSuccessJSON(map[string]interface{}{
  316. "list": "操作成功",
  317. })
  318. return
  319. }
  320. //发药明细列表
  321. func (this *PharmacyController) DispensingDetails() {
  322. var err error
  323. defer func() {
  324. if rec := recover(); rec != nil {
  325. err = fmt.Errorf("程序异常:%v", rec)
  326. }
  327. if err != nil {
  328. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  329. }
  330. }()
  331. keyword := this.GetString("keyword", "") //患者名称
  332. start_time := this.GetString("start_time", "") //开始时间
  333. end_time := this.GetString("end_time", "") //结束时间
  334. page, _ := this.GetInt64("page", 1) //页码
  335. limit, _ := this.GetInt64("limit", 10) //每一页查出来的条数
  336. orgid := this.GetAdminUserInfo().CurrentOrgId
  337. timeLayout := "2006-01-02"
  338. loc, _ := time.LoadLocation("Local")
  339. var stime, etime int64
  340. if start_time == "" {
  341. stime = 1
  342. } else {
  343. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  344. stime = stmp.Unix()
  345. }
  346. if end_time == "" {
  347. _, etime = service.GetNowTime()
  348. } else {
  349. etmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  350. etime = etmp.Unix()
  351. }
  352. var dislist []*models.DispensingList
  353. var total int64
  354. dislist, total, err = service.DispensingDetailsList(stime, etime, orgid, page, limit, keyword)
  355. if err != nil {
  356. utils.ErrorLog(err.Error())
  357. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  358. return
  359. }
  360. this.ServeSuccessJSON(map[string]interface{}{
  361. "list": dislist,
  362. "total": total,
  363. })
  364. return
  365. }
  366. //处方详情
  367. func (this *PharmacyController) PrescriptionDetails() {
  368. var err error
  369. defer func() {
  370. if rec := recover(); rec != nil {
  371. err = fmt.Errorf("程序异常:%v", rec)
  372. }
  373. if err != nil {
  374. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  375. }
  376. }()
  377. //患者姓名
  378. patient_id, _ := this.GetInt64("patient_id", 0)
  379. //发药时间
  380. record_date, _ := this.GetInt64("record_date", 0)
  381. orgid := this.GetAdminUserInfo().CurrentOrgId
  382. if record_date == 0 || patient_id == 0 {
  383. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数不足")
  384. return
  385. }
  386. var list []*models.PrescripDetails
  387. list, err = service.PrescriptionDetails(patient_id, record_date, orgid)
  388. if err != nil {
  389. utils.ErrorLog(err.Error())
  390. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  391. return
  392. }
  393. this.ServeSuccessJSON(map[string]interface{}{
  394. "list": list,
  395. })
  396. return
  397. }
  398. //已发药品的信息
  399. func (this *PharmacyController) DispenseMedicine() {
  400. var err error
  401. defer func() {
  402. if rec := recover(); rec != nil {
  403. err = fmt.Errorf("程序异常:%v", rec)
  404. }
  405. if err != nil {
  406. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  407. }
  408. }()
  409. keyword := this.GetString("keyword", "")
  410. times := this.GetString("time", "")
  411. orgid := this.GetAdminUserInfo().CurrentOrgId
  412. timeLayout := "2006-01-02"
  413. loc, _ := time.LoadLocation("Local")
  414. deliveryway := this.GetString("deliveryway", "")
  415. var stime, etime int64
  416. if times == "" {
  417. stime, etime = service.GetNowTime()
  418. } else {
  419. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  420. stime = stmp.Unix()
  421. etime = stime + 86399
  422. }
  423. //查询表里当天的数据
  424. var flist []*models.ListOfDrugs
  425. flist, err = service.GetTodayMedicine(stime, etime, orgid, 1, keyword)
  426. if err != nil {
  427. utils.ErrorLog(err.Error())
  428. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  429. return
  430. }
  431. llist, err := service.Administration(deliveryway, orgid, flist)
  432. if err != nil {
  433. utils.ErrorLog(err.Error())
  434. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  435. return
  436. }
  437. this.ServeSuccessJSON(map[string]interface{}{
  438. "list": llist,
  439. })
  440. return
  441. }
  442. //待发药的药品信息
  443. func (this *PharmacyController) WaitingMedicine() {
  444. var err error
  445. defer func() {
  446. if rec := recover(); rec != nil {
  447. err = fmt.Errorf("程序异常:%v", rec)
  448. }
  449. if err != nil {
  450. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  451. }
  452. }()
  453. keyword := this.GetString("keyword", "")
  454. times := this.GetString("time", "")
  455. orgid := this.GetAdminUserInfo().CurrentOrgId
  456. timeLayout := "2006-01-02"
  457. loc, _ := time.LoadLocation("Local")
  458. deliveryway := this.GetString("deliveryway", "")
  459. var stime, etime int64
  460. if times == "" {
  461. stime, etime = service.GetNowTime()
  462. } else {
  463. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  464. stime = stmp.Unix()
  465. etime = stime + 86399
  466. }
  467. //查询表里当天的数据
  468. var flist []*models.ListOfDrugs
  469. flist, err = service.GetTodayMedicine(stime, etime, orgid, 0, keyword)
  470. if err != nil {
  471. utils.ErrorLog(err.Error())
  472. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  473. return
  474. }
  475. llist, err := service.Administration(deliveryway, orgid, flist)
  476. if err != nil {
  477. utils.ErrorLog(err.Error())
  478. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  479. return
  480. }
  481. this.ServeSuccessJSON(map[string]interface{}{
  482. "list": llist,
  483. })
  484. return
  485. }
  486. //获取药品的所有患者信息
  487. func (this *PharmacyController) GetPatientsWithDrugs() {
  488. var err error
  489. defer func() {
  490. if rec := recover(); rec != nil {
  491. err = fmt.Errorf("程序异常:%v", rec)
  492. }
  493. if err != nil {
  494. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  495. }
  496. }()
  497. drug_id, _ := this.GetInt64("drug_id", 0)
  498. is_medicine, _ := this.GetInt64("is_medicine", 0) //0:待发药,1:已发药
  499. times := this.GetString("time", "")
  500. orgid := this.GetAdminUserInfo().CurrentOrgId
  501. deliveryway := this.GetString("deliveryway", "")
  502. if deliveryway == "" {
  503. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  504. return
  505. }
  506. shift, err := this.GetInt64("shift", 0) //班次
  507. if err != nil {
  508. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  509. return
  510. }
  511. partition, err := this.GetInt64("partition", 0) //分区
  512. if err != nil {
  513. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  514. return
  515. }
  516. timeLayout := "2006-01-02"
  517. loc, _ := time.LoadLocation("Local")
  518. var stime, etime int64
  519. if times == "" {
  520. stime, etime = service.GetNowTime()
  521. } else {
  522. stmp, _ := time.ParseInLocation(timeLayout+" 15:04:05", times+" 00:00:00", loc)
  523. stime = stmp.Unix()
  524. etime = stime + 86399
  525. }
  526. var list []*models.PatientInformation
  527. list, err = service.FindMedicationList(orgid, drug_id, stime, etime, is_medicine)
  528. if err != nil {
  529. utils.ErrorLog(err.Error())
  530. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  531. return
  532. }
  533. listll, err := service.PartitionAndLayoutDrug(deliveryway, stime, etime, orgid, shift, partition, list)
  534. if err != nil {
  535. utils.ErrorLog(err.Error())
  536. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  537. return
  538. }
  539. total, err := service.CalculateTheTotalAmount(listll, drug_id)
  540. if err != nil {
  541. utils.ErrorLog(err.Error())
  542. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  543. return
  544. }
  545. this.ServeSuccessJSON(map[string]interface{}{
  546. "list": listll,
  547. "total": total,
  548. })
  549. return
  550. }
  551. //药品管理发药按钮点击
  552. func (this *PharmacyController) MedicineDeparture() {
  553. var err error
  554. defer func() {
  555. if rec := recover(); rec != nil {
  556. err = fmt.Errorf("程序异常:%v", rec)
  557. }
  558. if err != nil {
  559. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  560. }
  561. }()
  562. creater, _ := this.GetInt64("creater", 0) //领药人
  563. ids := this.GetString("ids", "") //发药的数据
  564. orgid := this.GetAdminUserInfo().CurrentOrgId
  565. if ids == "" {
  566. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数不足")
  567. return
  568. }
  569. err = service.MedicineDeparture(ids, creater, orgid)
  570. if err != nil {
  571. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  572. return
  573. }
  574. this.ServeSuccessJSON(map[string]interface{}{
  575. "list": "修改成功",
  576. })
  577. return
  578. }
  579. func (this *PharmacyController) GetPartitionList() {
  580. var err error
  581. defer func() {
  582. if rec := recover(); rec != nil {
  583. err = fmt.Errorf("程序异常:%v", rec)
  584. }
  585. if err != nil {
  586. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  587. }
  588. }()
  589. orgid := this.GetAdminUserInfo().CurrentOrgId
  590. tmp := []*models.DeviceZone{{ID: 0, Name: "全部分区"}}
  591. list, err := service.GetAllValidDeviceZones02(orgid)
  592. if err != nil {
  593. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  594. return
  595. }
  596. this.ServeSuccessJSON(map[string]interface{}{
  597. "list": append(tmp, list...),
  598. })
  599. return
  600. }
  601. func (this *PharmacyController) RouteOfAdministration() {
  602. var err error
  603. defer func() {
  604. if rec := recover(); rec != nil {
  605. err = fmt.Errorf("程序异常:%v", rec)
  606. }
  607. if err != nil {
  608. service.SaveErrs(this.GetAdminUserInfo().CurrentOrgId, this.Ctx.Input, err)
  609. }
  610. }()
  611. orgid := this.GetAdminUserInfo().CurrentOrgId
  612. tmp := []*models.DrugwayDic{{ID: 0, Name: "全部"}}
  613. list, _, err := service.GetDrugWayDics(orgid)
  614. if err != nil {
  615. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, err.Error())
  616. return
  617. }
  618. this.ServeSuccessJSON(map[string]interface{}{
  619. "list": append(tmp, list...),
  620. })
  621. return
  622. }