his_charge_api_controller.go 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "bytes"
  8. "compress/gzip"
  9. "encoding/json"
  10. "github.com/astaxie/beego"
  11. "net/http"
  12. "time"
  13. )
  14. type HisChargeApiController struct {
  15. BaseAuthAPIController
  16. }
  17. func HisChargeApiRegistRouters() {
  18. beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
  19. beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
  20. //beego.InsertFilter("/api/his/chargestatistics/detail", beego.BeforeRouter, GzipFilter)
  21. beego.Router("/api/his/patient", &HisChargeApiController{}, "get:GetAllPatient")
  22. //beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
  23. beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
  24. beego.Router("/api/his/inspectionlisttwo/get", &HisChargeApiController{}, "get:GetHisInspectionListTwo")
  25. beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
  26. //发票
  27. beego.Router("/api/fapiao/create", &HisChargeApiController{}, "post:CreateFaPiaoRecord")
  28. beego.Router("/api/fapiao/modify", &HisChargeApiController{}, "post:ModifyFaPiaoRecord")
  29. beego.Router("/api/fapiao/list", &HisChargeApiController{}, "get:GetFaPiaoRecordList")
  30. beego.Router("/api/fapiao/delete", &HisChargeApiController{}, "post:DeleteFaPiaoRecord")
  31. beego.Router("/api/fapiao", &HisChargeApiController{}, "get:GetFaPiaoRecord")
  32. beego.Router("/api/fapiao/is_use", &HisChargeApiController{}, "post:UpdateFaPiaoRecordIsUse")
  33. beego.Router("/api/his/getyidiclear", &HisChargeApiController{}, "get:GetHisYidiClearRecord")
  34. beego.Router("/api/his/getexportdata", &HisChargeApiController{}, "get:GetExportData")
  35. }
  36. func (c *HisChargeApiController) GetExportData() {
  37. start_time := c.GetString("start_time")
  38. end_time := c.GetString("end_time")
  39. adminUser := c.GetAdminUserInfo()
  40. timeLayout := "2006-01-02"
  41. loc, _ := time.LoadLocation("Local")
  42. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  43. if err != nil {
  44. }
  45. startRecordDateTime := startTime.Unix()
  46. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  47. if err != nil {
  48. }
  49. endRecordDateTime := endTime.Unix()
  50. chargePatient, err := service.GetAllChargeDetailsTwo(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime)
  51. if err == nil {
  52. c.ServeSuccessJSON(map[string]interface{}{
  53. "patients": chargePatient,
  54. })
  55. return
  56. } else {
  57. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  58. return
  59. }
  60. }
  61. func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {
  62. id, _ := c.GetInt64("id", 0)
  63. is_use, _ := c.GetInt64("is_use")
  64. if id <= 0 {
  65. utils.ErrorLog("id == 0")
  66. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  67. return
  68. }
  69. record, _ := service.FindFapiaoById(id)
  70. adminUserInfo := c.GetAdminUserInfo()
  71. service.UpdateFapiaoIsUse(adminUserInfo.CurrentOrgId)
  72. records := models.HisFapiaoRecord{
  73. ID: id,
  74. FapiaoCode: record.FapiaoCode,
  75. FapiaoNumber: record.FapiaoNumber,
  76. Ctime: time.Now().Unix(),
  77. Mtime: time.Now().Unix(),
  78. UserOrgId: adminUserInfo.CurrentOrgId,
  79. Status: 1,
  80. IsUse: is_use,
  81. }
  82. err := service.ModifyFapiao(&records)
  83. if err == nil {
  84. c.ServeSuccessJSON(map[string]interface{}{
  85. "fapiao_record": records,
  86. })
  87. } else {
  88. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  89. }
  90. }
  91. func (c *HisChargeApiController) CreateFaPiaoRecord() {
  92. fapiao_code := c.GetString("fapiao_code")
  93. fapiao_number := c.GetString("fapiao_number")
  94. if len(fapiao_code) <= 0 {
  95. utils.ErrorLog("len(fapiao_code) == 0")
  96. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  97. return
  98. }
  99. if len(fapiao_number) <= 0 {
  100. utils.ErrorLog("len(fapiao_number) == 0")
  101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  102. return
  103. }
  104. adminUserInfo := c.GetAdminUserInfo()
  105. record := models.HisFapiaoRecord{
  106. FapiaoCode: fapiao_code,
  107. FapiaoNumber: fapiao_number,
  108. Ctime: time.Now().Unix(),
  109. Mtime: time.Now().Unix(),
  110. UserOrgId: adminUserInfo.CurrentOrgId,
  111. Status: 1,
  112. IsUse: 0,
  113. }
  114. err, records := service.AddSigleFapiaoRecord(&record)
  115. if err == nil {
  116. c.ServeSuccessJSON(map[string]interface{}{
  117. "fapiao_record": records,
  118. })
  119. } else {
  120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  121. }
  122. }
  123. func (c *HisChargeApiController) ModifyFaPiaoRecord() {
  124. id, _ := c.GetInt64("id", 0)
  125. fapiao_code := c.GetString("fapiao_code")
  126. fapiao_number := c.GetString("fapiao_number")
  127. if id <= 0 {
  128. utils.ErrorLog("id == 0")
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  130. return
  131. }
  132. if len(fapiao_code) <= 0 {
  133. utils.ErrorLog("len(fapiao_code) == 0")
  134. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  135. return
  136. }
  137. if len(fapiao_number) <= 0 {
  138. utils.ErrorLog("len(fapiao_number) == 0")
  139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  140. return
  141. }
  142. record, _ := service.FindFapiaoById(id)
  143. adminUserInfo := c.GetAdminUserInfo()
  144. records := models.HisFapiaoRecord{
  145. ID: id,
  146. FapiaoCode: fapiao_code,
  147. FapiaoNumber: fapiao_number,
  148. Ctime: time.Now().Unix(),
  149. Mtime: time.Now().Unix(),
  150. UserOrgId: adminUserInfo.CurrentOrgId,
  151. Status: 1,
  152. IsUse: record.IsUse,
  153. }
  154. err := service.ModifyFapiao(&records)
  155. if err == nil {
  156. c.ServeSuccessJSON(map[string]interface{}{
  157. "fapiao_record": records,
  158. })
  159. } else {
  160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  161. }
  162. }
  163. func (c *HisChargeApiController) GetFaPiaoRecordList() {
  164. page, _ := c.GetInt64("page", 1)
  165. limit, _ := c.GetInt64("limit", 7)
  166. adminUserInfo := c.GetAdminUserInfo()
  167. fapiaoRecord, total, err := service.FindAllFapiaoList(adminUserInfo.CurrentOrgId, page, limit)
  168. if err == nil {
  169. c.ServeSuccessJSON(map[string]interface{}{
  170. "fapiao_record": fapiaoRecord,
  171. "total": total,
  172. })
  173. } else {
  174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  175. }
  176. }
  177. func (c *HisChargeApiController) DeleteFaPiaoRecord() {
  178. id, _ := c.GetInt64("id", 0)
  179. err := service.DeleteFapiaoById(id)
  180. if err == nil {
  181. c.ServeSuccessJSON(map[string]interface{}{
  182. "msg": "删除成功",
  183. })
  184. } else {
  185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  186. }
  187. }
  188. func (c *HisChargeApiController) GetFaPiaoRecord() {
  189. id, _ := c.GetInt64("id", 0)
  190. fapiaoRecord, err := service.FindFapiaoById(id)
  191. if err == nil {
  192. c.ServeSuccessJSON(map[string]interface{}{
  193. "fapiao_record": fapiaoRecord,
  194. })
  195. } else {
  196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  197. }
  198. }
  199. func (c *HisChargeApiController) GetChargeStatisticsDetail() {
  200. //c.ServeSuccessJSON(map[string]interface{}{
  201. // "msg": "接口优化升级,如有数据需要,请联系客服!",
  202. //})
  203. //return
  204. start_time := c.GetString("start_time")
  205. end_time := c.GetString("end_time")
  206. keyword := c.GetString("keyword")
  207. item_type, _ := c.GetInt64("type")
  208. adminUser := c.GetAdminUserInfo()
  209. timeLayout := "2006-01-02"
  210. loc, _ := time.LoadLocation("Local")
  211. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  212. if err != nil {
  213. }
  214. startRecordDateTime := startTime.Unix()
  215. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  216. if err != nil {
  217. }
  218. endRecordDateTime := endTime.Unix()
  219. switch item_type {
  220. case 0:
  221. chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  222. chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  223. chargeDrug = append(chargeDrug, chargeProject...)
  224. b, _ := structToBytes(chargeDrug)
  225. //cd, _ := compressData(b)
  226. // 使用 Gzip 压缩数据
  227. var compressedData bytes.Buffer
  228. writer := gzip.NewWriter(&compressedData)
  229. _, err = writer.Write(b)
  230. if err != nil {
  231. c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
  232. c.Ctx.WriteString(err.Error())
  233. return
  234. }
  235. writer.Close()
  236. // 设置响应头,表明数据经过了 Gzip 压缩
  237. c.Ctx.Output.Header("Content-Encoding", "gzip")
  238. // 发送压缩后的数据
  239. c.Ctx.ResponseWriter.Write(compressedData.Bytes())
  240. break
  241. case 1:
  242. chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  243. //chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  244. //chargeDrug = append(chargeDrug, chargeProject...)
  245. b, _ := structToBytes(chargeDrug)
  246. //cd, _ := compressData(b)
  247. // 使用 Gzip 压缩数据
  248. var compressedData bytes.Buffer
  249. writer := gzip.NewWriter(&compressedData)
  250. _, err = writer.Write(b)
  251. if err != nil {
  252. c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
  253. c.Ctx.WriteString(err.Error())
  254. return
  255. }
  256. writer.Close()
  257. // 设置响应头,表明数据经过了 Gzip 压缩
  258. c.Ctx.Output.Header("Content-Encoding", "gzip")
  259. // 发送压缩后的数据
  260. c.Ctx.ResponseWriter.Write(compressedData.Bytes())
  261. break
  262. case 2:
  263. //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  264. chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  265. //chargeDrug = append(chargeDrug, chargeProject...)
  266. b, _ := structToBytes(chargeProject)
  267. //cd, _ := compressData(b)
  268. // 使用 Gzip 压缩数据
  269. var compressedData bytes.Buffer
  270. writer := gzip.NewWriter(&compressedData)
  271. _, err = writer.Write(b)
  272. if err != nil {
  273. c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
  274. c.Ctx.WriteString(err.Error())
  275. return
  276. }
  277. writer.Close()
  278. // 设置响应头,表明数据经过了 Gzip 压缩
  279. c.Ctx.Output.Header("Content-Encoding", "gzip")
  280. // 发送压缩后的数据
  281. c.Ctx.ResponseWriter.Write(compressedData.Bytes())
  282. break
  283. case 3:
  284. //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  285. chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  286. //chargeDrug = append(chargeDrug, chargeProject...)
  287. b, _ := structToBytes(chargeProject)
  288. //cd, _ := compressData(b)
  289. // 使用 Gzip 压缩数据
  290. var compressedData bytes.Buffer
  291. writer := gzip.NewWriter(&compressedData)
  292. _, err = writer.Write(b)
  293. if err != nil {
  294. c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
  295. c.Ctx.WriteString(err.Error())
  296. return
  297. }
  298. writer.Close()
  299. // 设置响应头,表明数据经过了 Gzip 压缩
  300. c.Ctx.Output.Header("Content-Encoding", "gzip")
  301. // 发送压缩后的数据
  302. c.Ctx.ResponseWriter.Write(compressedData.Bytes())
  303. break
  304. }
  305. }
  306. func structToBytes(p []*models.NewChargeDetail) ([]byte, error) {
  307. data, err := json.Marshal(p)
  308. if err != nil {
  309. return nil, err
  310. }
  311. return data, nil
  312. }
  313. func compressData(data []byte) ([]byte, error) {
  314. var compressedData bytes.Buffer
  315. writer := gzip.NewWriter(&compressedData)
  316. _, err := writer.Write(data)
  317. if err != nil {
  318. return nil, err
  319. }
  320. err = writer.Close()
  321. if err != nil {
  322. return nil, err
  323. }
  324. return compressedData.Bytes(), nil
  325. }
  326. func (c *HisChargeApiController) GetChargeStatisticsSettle() {
  327. start_time := c.GetString("start_time")
  328. end_time := c.GetString("end_time")
  329. keyword := c.GetString("keyword")
  330. item_type, _ := c.GetInt64("type")
  331. adminUser := c.GetAdminUserInfo()
  332. timeLayout := "2006-01-02"
  333. loc, _ := time.LoadLocation("Local")
  334. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  335. if err != nil {
  336. }
  337. startRecordDateTime := startTime.Unix()
  338. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  339. if err != nil {
  340. }
  341. endRecordDateTime := endTime.Unix()
  342. chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  343. if err == nil {
  344. c.ServeSuccessJSON(map[string]interface{}{
  345. "patients": chargePatient,
  346. })
  347. return
  348. } else {
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  350. return
  351. }
  352. }
  353. func (c *HisChargeApiController) GetHisInspectionList() {
  354. record_date := c.GetString("record_date")
  355. keyword := c.GetString("keyword")
  356. is_print, _ := c.GetInt64("is_print")
  357. page, _ := c.GetInt64("page")
  358. limit, _ := c.GetInt64("limit")
  359. tube_color, _ := c.GetInt64("tube_color")
  360. adminUser := c.GetAdminUserInfo()
  361. timeLayout := "2006-01-02"
  362. loc, _ := time.LoadLocation("Local")
  363. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  364. if err != nil {
  365. }
  366. record_time := startTime.Unix()
  367. var labels []*models.HisLabelPrintInfo
  368. var labels_two []*models.HisLabelPrintInfo
  369. var total int64
  370. var total_two int64
  371. //var err error
  372. if tube_color == 0 {
  373. labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  374. } else {
  375. labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  376. labels_two, total_two, err = service.GetLabelPrintListTwo(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  377. total = total + total_two
  378. labels = append(labels, labels_two...)
  379. }
  380. if err == nil {
  381. c.ServeSuccessJSON(map[string]interface{}{
  382. "labels": labels,
  383. "total": total,
  384. })
  385. return
  386. } else {
  387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  388. return
  389. }
  390. }
  391. func (c *HisChargeApiController) GetHisInspectionListTwo() {
  392. record_date := c.GetString("record_date")
  393. keyword := c.GetString("keyword")
  394. is_print, _ := c.GetInt64("is_print")
  395. tube_color, _ := c.GetInt64("tube_color")
  396. adminUser := c.GetAdminUserInfo()
  397. timeLayout := "2006-01-02"
  398. loc, _ := time.LoadLocation("Local")
  399. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  400. if err != nil {
  401. }
  402. record_time := startTime.Unix()
  403. var labels []*models.HisLabelPrintInfo
  404. //var labels_two []*models.HisLabelPrintInfo
  405. //var total int64
  406. //var total_two int64
  407. labels, _, err = service.GetLabelPrintListThree(adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  408. //labels_two, total_two, err = service.GetLabelPrintListFour(adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  409. //total = total + total_two
  410. //labels = append(labels, labels_two...)
  411. if err == nil {
  412. c.ServeSuccessJSON(map[string]interface{}{
  413. "labels": labels,
  414. //"total": total,
  415. })
  416. return
  417. } else {
  418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  419. return
  420. }
  421. }
  422. func (c *HisChargeApiController) GetHisInspectionInfo() {
  423. id, _ := c.GetInt64("id")
  424. label, err := service.GetLabelPrintInfo(id)
  425. if err == nil {
  426. c.ServeSuccessJSON(map[string]interface{}{
  427. "label": label,
  428. })
  429. return
  430. } else {
  431. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  432. return
  433. }
  434. }
  435. func (c *HisChargeApiController) GetHisYidiClearRecord() {
  436. records, err := service.FindHisYidiClearRecord(c.GetAdminUserInfo().CurrentOrgId)
  437. if err == nil {
  438. c.ServeSuccessJSON(map[string]interface{}{
  439. "list": records,
  440. })
  441. return
  442. } else {
  443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  444. return
  445. }
  446. }
  447. func (c *HisChargeApiController) GetAllPatient() {
  448. patients, err := service.GetAllPatientTwo(c.GetAdminUserInfo().CurrentOrgId)
  449. if err == nil {
  450. c.ServeSuccessJSON(map[string]interface{}{
  451. "list": patients,
  452. })
  453. return
  454. } else {
  455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  456. return
  457. }
  458. }
  459. func (c *HisChargeApiController) GetStatisticsDetail() {
  460. start_time := c.GetString("start_time")
  461. end_time := c.GetString("end_time")
  462. keyword := c.GetString("keyword")
  463. item_type, _ := c.GetInt64("type")
  464. p_type, _ := c.GetInt64("p_type")
  465. patinet_id, _ := c.GetInt64("patinet_id")
  466. adminUser := c.GetAdminUserInfo()
  467. timeLayout := "2006-01-02"
  468. loc, _ := time.LoadLocation("Local")
  469. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  470. if err != nil {
  471. }
  472. startRecordDateTime := startTime.Unix()
  473. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  474. if err != nil {
  475. }
  476. endRecordDateTime := endTime.Unix()
  477. chargePatient, err := service.GetPatientChargeDetails(patinet_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type, p_type)
  478. if err == nil {
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "patients": chargePatient,
  481. })
  482. return
  483. } else {
  484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  485. return
  486. }
  487. }
  488. func (c *HisChargeApiController) GetStatisticsGather() {
  489. start_time := c.GetString("start_time")
  490. end_time := c.GetString("end_time")
  491. keyword := c.GetString("keyword")
  492. item_type, _ := c.GetInt64("type")
  493. adminUser := c.GetAdminUserInfo()
  494. timeLayout := "2006-01-02"
  495. loc, _ := time.LoadLocation("Local")
  496. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  497. if err != nil {
  498. }
  499. startRecordDateTime := startTime.Unix()
  500. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  501. if err != nil {
  502. }
  503. endRecordDateTime := endTime.Unix()
  504. chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  505. if err == nil {
  506. c.ServeSuccessJSON(map[string]interface{}{
  507. "patients": chargePatient,
  508. })
  509. return
  510. } else {
  511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  512. return
  513. }
  514. }