his_charge_api_controller.go 18KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  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. time_type := c.GetString("time_type")
  207. keyword := c.GetString("keyword")
  208. item_type, _ := c.GetInt64("type")
  209. adminUser := c.GetAdminUserInfo()
  210. timeLayout := "2006-01-02"
  211. loc, _ := time.LoadLocation("Local")
  212. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  213. if err != nil {
  214. }
  215. startRecordDateTime := startTime.Unix()
  216. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  217. if err != nil {
  218. }
  219. endRecordDateTime := endTime.Unix()
  220. switch item_type {
  221. case 0:
  222. chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
  223. chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
  224. chargeDrug = append(chargeDrug, chargeProject...)
  225. b, _ := structToBytes(chargeDrug)
  226. //cd, _ := compressData(b)
  227. // 使用 Gzip 压缩数据
  228. var compressedData bytes.Buffer
  229. writer := gzip.NewWriter(&compressedData)
  230. _, err = writer.Write(b)
  231. if err != nil {
  232. c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
  233. c.Ctx.WriteString(err.Error())
  234. return
  235. }
  236. writer.Close()
  237. // 设置响应头,表明数据经过了 Gzip 压缩
  238. c.Ctx.Output.Header("Content-Encoding", "gzip")
  239. // 发送压缩后的数据
  240. c.Ctx.ResponseWriter.Write(compressedData.Bytes())
  241. break
  242. case 1:
  243. chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
  244. //chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  245. //chargeDrug = append(chargeDrug, chargeProject...)
  246. b, _ := structToBytes(chargeDrug)
  247. //cd, _ := compressData(b)
  248. // 使用 Gzip 压缩数据
  249. var compressedData bytes.Buffer
  250. writer := gzip.NewWriter(&compressedData)
  251. _, err = writer.Write(b)
  252. if err != nil {
  253. c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
  254. c.Ctx.WriteString(err.Error())
  255. return
  256. }
  257. writer.Close()
  258. // 设置响应头,表明数据经过了 Gzip 压缩
  259. c.Ctx.Output.Header("Content-Encoding", "gzip")
  260. // 发送压缩后的数据
  261. c.Ctx.ResponseWriter.Write(compressedData.Bytes())
  262. break
  263. case 2:
  264. //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  265. chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
  266. //chargeDrug = append(chargeDrug, chargeProject...)
  267. b, _ := structToBytes(chargeProject)
  268. //cd, _ := compressData(b)
  269. // 使用 Gzip 压缩数据
  270. var compressedData bytes.Buffer
  271. writer := gzip.NewWriter(&compressedData)
  272. _, err = writer.Write(b)
  273. if err != nil {
  274. c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
  275. c.Ctx.WriteString(err.Error())
  276. return
  277. }
  278. writer.Close()
  279. // 设置响应头,表明数据经过了 Gzip 压缩
  280. c.Ctx.Output.Header("Content-Encoding", "gzip")
  281. // 发送压缩后的数据
  282. c.Ctx.ResponseWriter.Write(compressedData.Bytes())
  283. break
  284. case 3:
  285. //chargeDrug, err := service.GetNewAllPatientDrugChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type)
  286. chargeProject, err := service.GetNewAllPatientProjectAndGoodChargeDetails(adminUser.CurrentOrgId, start_time+" 00:00:00", end_time+" 23:59:59", startRecordDateTime, endRecordDateTime, keyword, item_type, time_type)
  287. //chargeDrug = append(chargeDrug, chargeProject...)
  288. b, _ := structToBytes(chargeProject)
  289. //cd, _ := compressData(b)
  290. // 使用 Gzip 压缩数据
  291. var compressedData bytes.Buffer
  292. writer := gzip.NewWriter(&compressedData)
  293. _, err = writer.Write(b)
  294. if err != nil {
  295. c.Ctx.ResponseWriter.WriteHeader(http.StatusInternalServerError)
  296. c.Ctx.WriteString(err.Error())
  297. return
  298. }
  299. writer.Close()
  300. // 设置响应头,表明数据经过了 Gzip 压缩
  301. c.Ctx.Output.Header("Content-Encoding", "gzip")
  302. // 发送压缩后的数据
  303. c.Ctx.ResponseWriter.Write(compressedData.Bytes())
  304. break
  305. }
  306. }
  307. func structToBytes(p []*models.NewChargeDetail) ([]byte, error) {
  308. data, err := json.Marshal(p)
  309. if err != nil {
  310. return nil, err
  311. }
  312. return data, nil
  313. }
  314. func compressData(data []byte) ([]byte, error) {
  315. var compressedData bytes.Buffer
  316. writer := gzip.NewWriter(&compressedData)
  317. _, err := writer.Write(data)
  318. if err != nil {
  319. return nil, err
  320. }
  321. err = writer.Close()
  322. if err != nil {
  323. return nil, err
  324. }
  325. return compressedData.Bytes(), nil
  326. }
  327. func (c *HisChargeApiController) GetChargeStatisticsSettle() {
  328. start_time := c.GetString("start_time")
  329. end_time := c.GetString("end_time")
  330. keyword := c.GetString("keyword")
  331. item_type, _ := c.GetInt64("type")
  332. adminUser := c.GetAdminUserInfo()
  333. timeLayout := "2006-01-02"
  334. loc, _ := time.LoadLocation("Local")
  335. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  336. if err != nil {
  337. }
  338. startRecordDateTime := startTime.Unix()
  339. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  340. if err != nil {
  341. }
  342. endRecordDateTime := endTime.Unix()
  343. chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  344. if err == nil {
  345. c.ServeSuccessJSON(map[string]interface{}{
  346. "patients": chargePatient,
  347. })
  348. return
  349. } else {
  350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  351. return
  352. }
  353. }
  354. func (c *HisChargeApiController) GetHisInspectionList() {
  355. record_date := c.GetString("record_date")
  356. keyword := c.GetString("keyword")
  357. is_print, _ := c.GetInt64("is_print")
  358. page, _ := c.GetInt64("page")
  359. limit, _ := c.GetInt64("limit")
  360. tube_color, _ := c.GetInt64("tube_color")
  361. adminUser := c.GetAdminUserInfo()
  362. timeLayout := "2006-01-02"
  363. loc, _ := time.LoadLocation("Local")
  364. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  365. if err != nil {
  366. }
  367. record_time := startTime.Unix()
  368. var labels []*models.HisLabelPrintInfo
  369. var labels_two []*models.HisLabelPrintInfo
  370. var total int64
  371. var total_two int64
  372. //var err error
  373. if tube_color == 0 {
  374. labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  375. } else {
  376. labels, total, err = service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  377. labels_two, total_two, err = service.GetLabelPrintListTwo(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  378. total = total + total_two
  379. labels = append(labels, labels_two...)
  380. }
  381. if err == nil {
  382. c.ServeSuccessJSON(map[string]interface{}{
  383. "labels": labels,
  384. "total": total,
  385. })
  386. return
  387. } else {
  388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  389. return
  390. }
  391. }
  392. func (c *HisChargeApiController) GetHisInspectionListTwo() {
  393. record_date := c.GetString("record_date")
  394. keyword := c.GetString("keyword")
  395. is_print, _ := c.GetInt64("is_print")
  396. tube_color, _ := c.GetInt64("tube_color")
  397. adminUser := c.GetAdminUserInfo()
  398. timeLayout := "2006-01-02"
  399. loc, _ := time.LoadLocation("Local")
  400. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  401. if err != nil {
  402. }
  403. record_time := startTime.Unix()
  404. var labels []*models.HisLabelPrintInfo
  405. //var labels_two []*models.HisLabelPrintInfo
  406. //var total int64
  407. //var total_two int64
  408. labels, _, err = service.GetLabelPrintListThree(adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  409. //labels_two, total_two, err = service.GetLabelPrintListFour(adminUser.CurrentOrgId, record_time, is_print, keyword, tube_color)
  410. //total = total + total_two
  411. //labels = append(labels, labels_two...)
  412. if err == nil {
  413. c.ServeSuccessJSON(map[string]interface{}{
  414. "labels": labels,
  415. //"total": total,
  416. })
  417. return
  418. } else {
  419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  420. return
  421. }
  422. }
  423. func (c *HisChargeApiController) GetHisInspectionInfo() {
  424. id, _ := c.GetInt64("id")
  425. label, err := service.GetLabelPrintInfo(id)
  426. if err == nil {
  427. c.ServeSuccessJSON(map[string]interface{}{
  428. "label": label,
  429. })
  430. return
  431. } else {
  432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  433. return
  434. }
  435. }
  436. func (c *HisChargeApiController) GetHisYidiClearRecord() {
  437. records, err := service.FindHisYidiClearRecord(c.GetAdminUserInfo().CurrentOrgId)
  438. if err == nil {
  439. c.ServeSuccessJSON(map[string]interface{}{
  440. "list": records,
  441. })
  442. return
  443. } else {
  444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  445. return
  446. }
  447. }
  448. func (c *HisChargeApiController) GetAllPatient() {
  449. patients, err := service.GetAllPatientTwo(c.GetAdminUserInfo().CurrentOrgId)
  450. if err == nil {
  451. c.ServeSuccessJSON(map[string]interface{}{
  452. "list": patients,
  453. })
  454. return
  455. } else {
  456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  457. return
  458. }
  459. }
  460. func (c *HisChargeApiController) GetStatisticsDetail() {
  461. start_time := c.GetString("start_time")
  462. end_time := c.GetString("end_time")
  463. keyword := c.GetString("keyword")
  464. item_type, _ := c.GetInt64("type")
  465. p_type, _ := c.GetInt64("p_type")
  466. patinet_id, _ := c.GetInt64("patinet_id")
  467. adminUser := c.GetAdminUserInfo()
  468. timeLayout := "2006-01-02"
  469. loc, _ := time.LoadLocation("Local")
  470. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  471. if err != nil {
  472. }
  473. startRecordDateTime := startTime.Unix()
  474. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  475. if err != nil {
  476. }
  477. endRecordDateTime := endTime.Unix()
  478. chargePatient, err := service.GetPatientChargeDetails(patinet_id, adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type, p_type)
  479. if err == nil {
  480. c.ServeSuccessJSON(map[string]interface{}{
  481. "patients": chargePatient,
  482. })
  483. return
  484. } else {
  485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  486. return
  487. }
  488. }
  489. func (c *HisChargeApiController) GetStatisticsGather() {
  490. start_time := c.GetString("start_time")
  491. end_time := c.GetString("end_time")
  492. keyword := c.GetString("keyword")
  493. item_type, _ := c.GetInt64("type")
  494. adminUser := c.GetAdminUserInfo()
  495. timeLayout := "2006-01-02"
  496. loc, _ := time.LoadLocation("Local")
  497. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  498. if err != nil {
  499. }
  500. startRecordDateTime := startTime.Unix()
  501. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  502. if err != nil {
  503. }
  504. endRecordDateTime := endTime.Unix()
  505. chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  506. if err == nil {
  507. c.ServeSuccessJSON(map[string]interface{}{
  508. "patients": chargePatient,
  509. })
  510. return
  511. } else {
  512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  513. return
  514. }
  515. }