his_charge_api_controller.go 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "github.com/astaxie/beego"
  8. "time"
  9. )
  10. type HisChargeApiController struct {
  11. BaseAuthAPIController
  12. }
  13. func HisChargeApiRegistRouters() {
  14. beego.Router("/api/his/chargestatistics/detail", &HisChargeApiController{}, "get:GetChargeStatisticsDetail")
  15. beego.Router("/api/his/chargestatistics/settle", &HisChargeApiController{}, "get:GetChargeStatisticsSettle")
  16. beego.Router("/api/his/inspectionlist/get", &HisChargeApiController{}, "get:GetHisInspectionList")
  17. beego.Router("/api/his/inspectioninfo/get", &HisChargeApiController{}, "get:GetHisInspectionInfo")
  18. //发票
  19. beego.Router("/api/fapiao/create", &HisChargeApiController{}, "post:CreateFaPiaoRecord")
  20. beego.Router("/api/fapiao/modify", &HisChargeApiController{}, "post:ModifyFaPiaoRecord")
  21. beego.Router("/api/fapiao/list", &HisChargeApiController{}, "get:GetFaPiaoRecordList")
  22. beego.Router("/api/fapiao/delete", &HisChargeApiController{}, "post:DeleteFaPiaoRecord")
  23. beego.Router("/api/fapiao", &HisChargeApiController{}, "get:GetFaPiaoRecord")
  24. beego.Router("/api/fapiao/is_use", &HisChargeApiController{}, "post:UpdateFaPiaoRecordIsUse")
  25. beego.Router("/api/his/getyidiclear", &HisChargeApiController{}, "get:GetHisYidiClearRecord")
  26. }
  27. func (c *HisChargeApiController) UpdateFaPiaoRecordIsUse() {
  28. id, _ := c.GetInt64("id", 0)
  29. is_use, _ := c.GetInt64("is_use")
  30. if id <= 0 {
  31. utils.ErrorLog("id == 0")
  32. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  33. return
  34. }
  35. record, _ := service.FindFapiaoById(id)
  36. adminUserInfo := c.GetAdminUserInfo()
  37. service.UpdateFapiaoIsUse(adminUserInfo.CurrentOrgId)
  38. records := models.HisFapiaoRecord{
  39. ID: id,
  40. FapiaoCode: record.FapiaoCode,
  41. FapiaoNumber: record.FapiaoNumber,
  42. Ctime: time.Now().Unix(),
  43. Mtime: time.Now().Unix(),
  44. UserOrgId: adminUserInfo.CurrentOrgId,
  45. Status: 1,
  46. IsUse: is_use,
  47. }
  48. err := service.ModifyFapiao(&records)
  49. if err == nil {
  50. c.ServeSuccessJSON(map[string]interface{}{
  51. "fapiao_record": records,
  52. })
  53. } else {
  54. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  55. }
  56. }
  57. func (c *HisChargeApiController) CreateFaPiaoRecord() {
  58. fapiao_code := c.GetString("fapiao_code")
  59. fapiao_number := c.GetString("fapiao_number")
  60. if len(fapiao_code) <= 0 {
  61. utils.ErrorLog("len(fapiao_code) == 0")
  62. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  63. return
  64. }
  65. if len(fapiao_number) <= 0 {
  66. utils.ErrorLog("len(fapiao_number) == 0")
  67. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  68. return
  69. }
  70. adminUserInfo := c.GetAdminUserInfo()
  71. record := models.HisFapiaoRecord{
  72. FapiaoCode: fapiao_code,
  73. FapiaoNumber: fapiao_number,
  74. Ctime: time.Now().Unix(),
  75. Mtime: time.Now().Unix(),
  76. UserOrgId: adminUserInfo.CurrentOrgId,
  77. Status: 1,
  78. IsUse: 0,
  79. }
  80. err, records := service.AddSigleFapiaoRecord(&record)
  81. if err == nil {
  82. c.ServeSuccessJSON(map[string]interface{}{
  83. "fapiao_record": records,
  84. })
  85. } else {
  86. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  87. }
  88. }
  89. func (c *HisChargeApiController) ModifyFaPiaoRecord() {
  90. id, _ := c.GetInt64("id", 0)
  91. fapiao_code := c.GetString("fapiao_code")
  92. fapiao_number := c.GetString("fapiao_number")
  93. if id <= 0 {
  94. utils.ErrorLog("id == 0")
  95. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  96. return
  97. }
  98. if len(fapiao_code) <= 0 {
  99. utils.ErrorLog("len(fapiao_code) == 0")
  100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  101. return
  102. }
  103. if len(fapiao_number) <= 0 {
  104. utils.ErrorLog("len(fapiao_number) == 0")
  105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  106. return
  107. }
  108. record, _ := service.FindFapiaoById(id)
  109. adminUserInfo := c.GetAdminUserInfo()
  110. records := models.HisFapiaoRecord{
  111. ID: id,
  112. FapiaoCode: fapiao_code,
  113. FapiaoNumber: fapiao_number,
  114. Ctime: time.Now().Unix(),
  115. Mtime: time.Now().Unix(),
  116. UserOrgId: adminUserInfo.CurrentOrgId,
  117. Status: 1,
  118. IsUse: record.IsUse,
  119. }
  120. err := service.ModifyFapiao(&records)
  121. if err == nil {
  122. c.ServeSuccessJSON(map[string]interface{}{
  123. "fapiao_record": records,
  124. })
  125. } else {
  126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  127. }
  128. }
  129. func (c *HisChargeApiController) GetFaPiaoRecordList() {
  130. page, _ := c.GetInt64("page", 1)
  131. limit, _ := c.GetInt64("limit", 7)
  132. adminUserInfo := c.GetAdminUserInfo()
  133. fapiaoRecord, total, err := service.FindAllFapiaoList(adminUserInfo.CurrentOrgId, page, limit)
  134. if err == nil {
  135. c.ServeSuccessJSON(map[string]interface{}{
  136. "fapiao_record": fapiaoRecord,
  137. "total": total,
  138. })
  139. } else {
  140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  141. }
  142. }
  143. func (c *HisChargeApiController) DeleteFaPiaoRecord() {
  144. id, _ := c.GetInt64("id", 0)
  145. err := service.DeleteFapiaoById(id)
  146. if err == nil {
  147. c.ServeSuccessJSON(map[string]interface{}{
  148. "msg": "删除成功",
  149. })
  150. } else {
  151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  152. }
  153. }
  154. func (c *HisChargeApiController) GetFaPiaoRecord() {
  155. id, _ := c.GetInt64("id", 0)
  156. fapiaoRecord, err := service.FindFapiaoById(id)
  157. if err == nil {
  158. c.ServeSuccessJSON(map[string]interface{}{
  159. "fapiao_record": fapiaoRecord,
  160. })
  161. } else {
  162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  163. }
  164. }
  165. func (c *HisChargeApiController) GetChargeStatisticsDetail() {
  166. start_time := c.GetString("start_time")
  167. end_time := c.GetString("end_time")
  168. keyword := c.GetString("keyword")
  169. item_type, _ := c.GetInt64("type")
  170. adminUser := c.GetAdminUserInfo()
  171. timeLayout := "2006-01-02"
  172. loc, _ := time.LoadLocation("Local")
  173. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  174. if err != nil {
  175. }
  176. startRecordDateTime := startTime.Unix()
  177. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  178. if err != nil {
  179. }
  180. endRecordDateTime := endTime.Unix()
  181. chargePatient, err := service.GetAllPatientChargeDetails(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  182. if err == nil {
  183. c.ServeSuccessJSON(map[string]interface{}{
  184. "patients": chargePatient,
  185. })
  186. return
  187. } else {
  188. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  189. return
  190. }
  191. }
  192. func (c *HisChargeApiController) GetChargeStatisticsSettle() {
  193. start_time := c.GetString("start_time")
  194. end_time := c.GetString("end_time")
  195. keyword := c.GetString("keyword")
  196. item_type, _ := c.GetInt64("type")
  197. adminUser := c.GetAdminUserInfo()
  198. timeLayout := "2006-01-02"
  199. loc, _ := time.LoadLocation("Local")
  200. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  201. if err != nil {
  202. }
  203. startRecordDateTime := startTime.Unix()
  204. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  205. if err != nil {
  206. }
  207. endRecordDateTime := endTime.Unix()
  208. chargePatient, err := service.GetAllPatientChargeSettle(adminUser.CurrentOrgId, startRecordDateTime, endRecordDateTime, keyword, item_type)
  209. if err == nil {
  210. c.ServeSuccessJSON(map[string]interface{}{
  211. "patients": chargePatient,
  212. })
  213. return
  214. } else {
  215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  216. return
  217. }
  218. }
  219. func (c *HisChargeApiController) GetHisInspectionList() {
  220. record_date := c.GetString("record_date")
  221. keyword := c.GetString("keyword")
  222. is_print, _ := c.GetInt64("is_print")
  223. page, _ := c.GetInt64("page")
  224. limit, _ := c.GetInt64("limit")
  225. adminUser := c.GetAdminUserInfo()
  226. timeLayout := "2006-01-02"
  227. loc, _ := time.LoadLocation("Local")
  228. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  229. if err != nil {
  230. }
  231. record_time := startTime.Unix()
  232. labels, total, err := service.GetLabelPrintList(page, limit, adminUser.CurrentOrgId, record_time, is_print, keyword)
  233. if err == nil {
  234. c.ServeSuccessJSON(map[string]interface{}{
  235. "labels": labels,
  236. "total": total,
  237. })
  238. return
  239. } else {
  240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  241. return
  242. }
  243. }
  244. func (c *HisChargeApiController) GetHisInspectionInfo() {
  245. id, _ := c.GetInt64("id")
  246. label, err := service.GetLabelPrintInfo(id)
  247. if err == nil {
  248. c.ServeSuccessJSON(map[string]interface{}{
  249. "label": label,
  250. })
  251. return
  252. } else {
  253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  254. return
  255. }
  256. }
  257. func (c *HisChargeApiController) GetHisYidiClearRecord() {
  258. records, err := service.FindHisYidiClearRecord(c.GetAdminUserInfo().CurrentOrgId)
  259. if err == nil {
  260. c.ServeSuccessJSON(map[string]interface{}{
  261. "list": records,
  262. })
  263. return
  264. } else {
  265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  266. return
  267. }
  268. }