his_hospital_api_controller.go 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  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. "github.com/shopspring/decimal"
  10. "math/rand"
  11. "strconv"
  12. "strings"
  13. "time"
  14. )
  15. type HisHospitalApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func HisHospitalManagerApiRegistRouters() {
  19. beego.Router("/api/hishospitalpatient/list", &HisHospitalApiController{}, "get:GetHisHospitalPatientList")
  20. beego.Router("/api/hospitalcharge/list", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientList")
  21. beego.Router("/api/hospotalcharge/info", &HisHospitalApiController{}, "get:GetHisHospitalChargePatientInfo")
  22. beego.Router("/api/hospitalprescription/list", &HisHospitalApiController{}, "get:GetHisHospitalPrescriptionList")
  23. beego.Router("/api/hospital/inhopitalcheck/get", &HisHospitalApiController{}, "get:GetZHInHospitalCheck")
  24. beego.Router("/api/hospital/outhopitalcheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalCheck")
  25. beego.Router("/api/hospital/settle/get", &HisHospitalApiController{}, "get:GetSettleInfo")
  26. beego.Router("/api/hospital/inthopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHInHospitalUnCheck")
  27. beego.Router("/api/hospital/outhopitaluncheck/get", &HisHospitalApiController{}, "get:GetZHOutHospitalUnCheck")
  28. beego.Router("/api/hospital/refund", &HisHospitalApiController{}, "get:ZHRefund")
  29. beego.Router("/api/hospital/upload", &HisHospitalApiController{}, "get:GetUploadInfo")
  30. beego.Router("/api/hospital/refunddetail", &HisHospitalApiController{}, "get:RefundDetail")
  31. beego.Router("/api/hospitaldetail/list", &HisHospitalApiController{}, "get:GetHisHospitalDetailPatientList")
  32. beego.Router("/api/hospitaldetail/info", &HisHospitalApiController{}, "get:GetHisHospitalDetailInfo")
  33. beego.Router("/api/monthhospitaldetail/get", &HisHospitalApiController{}, "get:GetHisHospitalMonthDetailInfo")
  34. }
  35. func (c *HisHospitalApiController) RefundDetail() {
  36. patient_id, _ := c.GetInt64("patient_id")
  37. his_patient_id, _ := c.GetInt64("his_patient_id")
  38. record_time := c.GetString("record_time")
  39. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  40. timeLayout := "2006-01-02"
  41. loc, _ := time.LoadLocation("Local")
  42. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  43. if err != nil {
  44. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  45. return
  46. }
  47. recordDateTime := theTime.Unix()
  48. adminUser := c.GetAdminUserInfo()
  49. theTimeTwo, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 23:59:59", loc)
  50. if err != nil {
  51. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  52. return
  53. }
  54. recordDateTimeTwo := theTimeTwo.Unix()
  55. if settle_accounts_type == 1 { //日结
  56. err := service.UpDateOrderInfoStatus(patient_id, recordDateTime, adminUser.CurrentOrgId, recordDateTimeTwo)
  57. if err != nil {
  58. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  59. return
  60. }
  61. err1 := service.UpDatePrescriptionOrderStatusTwo(patient_id, recordDateTime, adminUser.CurrentOrgId)
  62. if err1 != nil {
  63. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  64. return
  65. }
  66. c.ServeSuccessJSON(map[string]interface{}{
  67. "msg": "撤销明细成功",
  68. })
  69. } else {
  70. record, _ := service.GetInHospitalRecord(his_patient_id)
  71. err := service.UpdataHospitalOrderStatusTwo(record.Number, adminUser.CurrentOrgId)
  72. if err == nil {
  73. c.ServeSuccessJSON(map[string]interface{}{
  74. "msg": "撤销明细成功",
  75. })
  76. } else {
  77. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  78. return
  79. }
  80. }
  81. }
  82. func (c *HisHospitalApiController) GetUploadInfo() {
  83. id, _ := c.GetInt64("id")
  84. record_time := c.GetString("record_time")
  85. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  86. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  87. timeLayout := "2006-01-02"
  88. loc, _ := time.LoadLocation("Local")
  89. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  90. if err != nil {
  91. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  92. return
  93. }
  94. recordDateTime := theTime.Unix()
  95. adminUser := c.GetAdminUserInfo()
  96. var prescriptions []*models.HisPrescription
  97. if settle_accounts_type == 1 { //日结
  98. prescriptions, _ = service.GetZHHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  99. } else { //月结
  100. start_time_str := c.GetString("start_time")
  101. end_time_str := c.GetString("end_time")
  102. timeLayout := "2006-01-02"
  103. loc, _ := time.LoadLocation("Local")
  104. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  105. if err != nil {
  106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  107. return
  108. }
  109. recordStartTime := theStartTime.Unix()
  110. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  111. if err != nil {
  112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  113. return
  114. }
  115. recordEndTime := theEndTime.Unix()
  116. prescriptions, _ = service.GetZHMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  117. }
  118. record, _ := service.GetInHospitalRecord(in_hospital_id)
  119. if record.ID == 0 {
  120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  121. return
  122. }
  123. var ids []int64
  124. for _, item := range prescriptions {
  125. ids = append(ids, item.ID)
  126. }
  127. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  128. var customs []*models.NewCustom
  129. for _, item := range prescriptions {
  130. tm := time.Unix(item.PreTime, 0)
  131. if item.Type == 1 { //药品
  132. for _, subItem := range item.HisDoctorAdviceInfo {
  133. if len(subItem.Drug.MedicalInsuranceNumber) > 0 && subItem.Drug.IsUser != 1 {
  134. //var randNum int
  135. //randNum = rand.Intn(10000) + 1000
  136. cus := &models.NewCustom{
  137. DetItemFeeSumamt: subItem.Price * subItem.PrescribingNumber,
  138. Cut: subItem.PrescribingNumber,
  139. FeedetlSn: subItem.FeedetlSn,
  140. Price: subItem.Price,
  141. MedListCodg: subItem.Drug.MedicalInsuranceNumber,
  142. HospApprFlag: subItem.Drug.HospApprFlag,
  143. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  144. }
  145. customs = append(customs, cus)
  146. }
  147. }
  148. }
  149. if item.Type == 2 { //项目
  150. for _, subItem := range item.HisPrescriptionProject {
  151. if subItem.Type == 2 {
  152. if len(subItem.HisProject.MedicalCode) > 0 {
  153. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  154. cus := &models.NewCustom{
  155. DetItemFeeSumamt: subItem.Price * cnt,
  156. Cut: cnt,
  157. FeedetlSn: subItem.FeedetlSn,
  158. Price: float64(subItem.Price),
  159. MedListCodg: subItem.HisProject.MedicalCode,
  160. HospApprFlag: -1,
  161. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  162. }
  163. customs = append(customs, cus)
  164. }
  165. } else if subItem.Type == 3 {
  166. if len(subItem.GoodInfo.MedicalInsuranceNumber) > 0 && subItem.GoodInfo.IsUser != 1 {
  167. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  168. cus := &models.NewCustom{
  169. DetItemFeeSumamt: subItem.Price * cnt,
  170. Cut: cnt,
  171. FeedetlSn: subItem.FeedetlSn,
  172. Price: float64(subItem.Price),
  173. MedListCodg: subItem.GoodInfo.MedicalInsuranceNumber,
  174. HospApprFlag: -1,
  175. FeeOcurTime: tm.Format("2006-01-02 15:04:05"),
  176. }
  177. customs = append(customs, cus)
  178. }
  179. }
  180. }
  181. }
  182. }
  183. fmt.Println(settle_accounts_type)
  184. if settle_accounts_type == 1 {
  185. fmt.Println(customs)
  186. for _, subItem := range customs {
  187. temp := strings.Split(subItem.FeedetlSn, "-")
  188. var advice_id int64 = 0
  189. var project_id int64 = 0
  190. var types int64 = 0
  191. id, _ := strconv.ParseInt(temp[2], 10, 64)
  192. types, _ = strconv.ParseInt(temp[1], 10, 64)
  193. if temp[1] == "1" {
  194. advice_id = id
  195. project_id = 0
  196. } else if temp[1] == "2" {
  197. advice_id = 0
  198. project_id = id
  199. }
  200. info := &models.HisOrderInfo{
  201. OrderNumber: record.Number,
  202. FeedetlSn: subItem.FeedetlSn,
  203. UploadDate: recordDateTime,
  204. AdviceId: advice_id,
  205. DetItemFeeSumamt: subItem.DetItemFeeSumamt,
  206. Cnt: subItem.Cut,
  207. Pric: float64(subItem.Price),
  208. PatientId: record.PatientId,
  209. PricUplmtAmt: 0,
  210. SelfpayProp: 0,
  211. FulamtOwnpayAmt: 0,
  212. OverlmtAmt: 0,
  213. PreselfpayAmt: 0,
  214. Status: 1,
  215. Mtime: time.Now().Unix(),
  216. Ctime: time.Now().Unix(),
  217. UserOrgId: adminUser.CurrentOrgId,
  218. HisPatientId: record.ID,
  219. OrderId: 0,
  220. ProjectId: project_id,
  221. Type: types,
  222. SettleType: settle_accounts_type,
  223. }
  224. if info.AdviceId > 0 && info.ProjectId == 0 {
  225. info.MedChrgitmType = "09"
  226. } else if info.AdviceId == 0 && info.ProjectId > 0 {
  227. p, _ := service.GetHisPrescriptionProjectByIDTwo(info.ProjectId)
  228. if p.Type == 2 {
  229. if p.HisProject.CostClassify == 3 {
  230. info.MedChrgitmType = "04"
  231. }
  232. if p.HisProject.CostClassify == 2 {
  233. info.MedChrgitmType = "05"
  234. }
  235. if p.HisProject.CostClassify == 8 {
  236. info.MedChrgitmType = "03"
  237. }
  238. } else {
  239. info.MedChrgitmType = "08"
  240. }
  241. }
  242. service.CreateOrderInfo(info)
  243. }
  244. err := service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  245. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  246. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
  247. if err == nil {
  248. c.ServeSuccessJSON(map[string]interface{}{
  249. "msg": "上传费用明细成功",
  250. })
  251. return
  252. } else {
  253. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  254. return
  255. }
  256. } else {
  257. for _, subItem := range customs {
  258. temp := strings.Split(subItem.FeedetlSn, "-")
  259. var advice_id int64 = 0
  260. var project_id int64 = 0
  261. var types int64 = 0
  262. id, _ := strconv.ParseInt(temp[2], 10, 64)
  263. types, _ = strconv.ParseInt(temp[1], 10, 64)
  264. if temp[1] == "1" {
  265. advice_id = id
  266. project_id = 0
  267. } else if temp[1] == "2" {
  268. advice_id = 0
  269. project_id = id
  270. }
  271. info := &models.HisOrderInfo{
  272. OrderNumber: record.Number,
  273. FeedetlSn: subItem.FeedetlSn,
  274. UploadDate: recordDateTime,
  275. AdviceId: advice_id,
  276. DetItemFeeSumamt: subItem.DetItemFeeSumamt,
  277. Cnt: subItem.Cut,
  278. Pric: float64(subItem.Price),
  279. PatientId: record.PatientId,
  280. PricUplmtAmt: 0,
  281. SelfpayProp: 0,
  282. FulamtOwnpayAmt: 0,
  283. OverlmtAmt: 0,
  284. PreselfpayAmt: 0,
  285. Status: 1,
  286. Mtime: time.Now().Unix(),
  287. Ctime: time.Now().Unix(),
  288. UserOrgId: adminUser.CurrentOrgId,
  289. HisPatientId: record.ID,
  290. OrderId: 0,
  291. ProjectId: project_id,
  292. Type: types,
  293. SettleType: settle_accounts_type,
  294. }
  295. service.CreateOrderInfo(info)
  296. }
  297. service.UpDatePrescriptionOrderStatus(adminUser.CurrentOrgId, ids)
  298. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, record.Number)
  299. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, record.PatientId, record.Number, recordDateTime)
  300. c.ServeSuccessJSON(map[string]interface{}{
  301. "msg": "上传费用明细成功",
  302. })
  303. }
  304. }
  305. func (c *HisHospitalApiController) GetHisHospitalPatientList() {
  306. record_date := c.GetString("record_date")
  307. types, _ := c.GetInt64("type", 0)
  308. sch_type, _ := c.GetInt64("sch_type", 0)
  309. timeLayout := "2006-01-02"
  310. loc, _ := time.LoadLocation("Local")
  311. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  312. if err != nil {
  313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  314. return
  315. }
  316. recordDateTime := theTime.Unix()
  317. adminInfo := c.GetAdminUserInfo()
  318. //var patients []*service.HospitalPatient
  319. var all_tempPatients []*service.HospitalPatient
  320. tempPatients, _ := service.GetHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
  321. tempPatients_two, _ := service.GetHisHospitalSchPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
  322. if types == 0 {
  323. all_tempPatients, _ = service.GetAllHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
  324. for _, item := range all_tempPatients {
  325. for index, subItem := range tempPatients_two {
  326. if item.ID == subItem.ID {
  327. tempPatients_two = append(tempPatients_two[:index], tempPatients_two[index+1:]...)
  328. }
  329. }
  330. }
  331. all_tempPatients = append(all_tempPatients, tempPatients_two...)
  332. }
  333. //当天有登记住院的和排班同时存在的话,删除掉排班的记录
  334. for _, item := range tempPatients {
  335. for index, subItem := range tempPatients_two {
  336. if item.ID == subItem.ID {
  337. tempPatients_two = append(tempPatients_two[:index], tempPatients_two[index+1:]...)
  338. }
  339. }
  340. }
  341. tempPatients = append(tempPatients, tempPatients_two...)
  342. var total_one int64
  343. var total_two int64
  344. for _, item := range tempPatients {
  345. if item.VMHisPrescriptionInfo.ID == 0 {
  346. total_one = total_one + 1
  347. }
  348. if item.VMHisPrescriptionInfo.ID > 0 {
  349. total_two = total_two + 1
  350. }
  351. }
  352. adminUserInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  353. doctors, _ := service.GetHisAdminUserDoctors(adminInfo.CurrentOrgId)
  354. department, _ := service.GetAllDepartMent(adminInfo.CurrentOrgId)
  355. if types == 0 {
  356. c.ServeSuccessJSON(map[string]interface{}{
  357. "list": all_tempPatients,
  358. "total_one": total_one,
  359. "total_two": total_two,
  360. "info": adminUserInfo,
  361. "doctors": doctors,
  362. "department": department,
  363. })
  364. } else if types == 1 { //未就诊
  365. var patientsOne []*service.HospitalPatient
  366. for _, item := range tempPatients {
  367. if item.VMHisPrescriptionInfo.ID == 0 {
  368. patientsOne = append(patientsOne, item)
  369. }
  370. }
  371. c.ServeSuccessJSON(map[string]interface{}{
  372. "list": patientsOne,
  373. "total_one": total_one,
  374. "total_two": total_two,
  375. "info": adminUserInfo,
  376. "doctors": doctors,
  377. "department": department,
  378. })
  379. } else if types == 2 { //已就诊
  380. var patientsTwo []*service.HospitalPatient
  381. for _, item := range tempPatients {
  382. if item.VMHisPrescriptionInfo.ID > 0 {
  383. patientsTwo = append(patientsTwo, item)
  384. }
  385. }
  386. c.ServeSuccessJSON(map[string]interface{}{
  387. "list": patientsTwo,
  388. "total_one": total_one,
  389. "total_two": total_two,
  390. "info": adminUserInfo,
  391. "doctors": doctors,
  392. "department": department,
  393. })
  394. }
  395. }
  396. func (c *HisHospitalApiController) GetHisHospitalChargePatientList() {
  397. record_date := c.GetString("record_date")
  398. timeLayout := "2006-01-02"
  399. loc, _ := time.LoadLocation("Local")
  400. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  401. if err != nil {
  402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  403. return
  404. }
  405. recordDateTime := theTime.Unix()
  406. adminInfo := c.GetAdminUserInfo()
  407. //tempPatients, _ := service.GetAllChargeHisPatientList(adminInfo.CurrentOrgId, "", recordDateTime)
  408. orders, _ := service.GetNewAllChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
  409. tempPatients, _ := service.GetNewAllUnChargeHisHospitalPatientList(adminInfo.CurrentOrgId, recordDateTime)
  410. var patients []*models.HisHospitalCheckRecord
  411. for _, item := range tempPatients {
  412. fmt.Println(item.ID)
  413. if item.ID > 0 && item.InHospitalStatus == 1 && item.HisHospitalOrder.OrderStatus != 2 {
  414. patients = append(patients, item)
  415. }
  416. }
  417. c.ServeSuccessJSON(map[string]interface{}{
  418. "list": patients,
  419. "list_two": patients,
  420. "charge_list": orders,
  421. })
  422. }
  423. func (c *HisHospitalApiController) GetHisHospitalChargePatientInfo() {
  424. patient_id, _ := c.GetInt64("patient_id")
  425. his_patient_id, _ := c.GetInt64("his_patient_id")
  426. record_date := c.GetString("record_date")
  427. start_time := c.GetString("start_time")
  428. end_time := c.GetString("end_time")
  429. order_status, _ := c.GetInt64("type", 0)
  430. p_type, _ := c.GetInt64("p_type", 0)
  431. timeLayout := "2006-01-02"
  432. loc, _ := time.LoadLocation("Local")
  433. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  434. if err != nil {
  435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  436. return
  437. }
  438. recordDateTime := theTime.Unix()
  439. startTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  440. if err != nil {
  441. }
  442. startRecordDateTime := startTime.Unix()
  443. endTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  444. if err != nil {
  445. }
  446. endRecordDateTime := endTime.Unix()
  447. admin := c.GetAdminUserInfo()
  448. his_patient_info, _ := service.GetNewHisHospitalPatientInfo(his_patient_id)
  449. xt_patient_info, _ := service.GetXTPatientInfo(admin.CurrentOrgId, patient_id)
  450. var prescriptions []*models.HisHospitalPrescription
  451. if order_status == 1 || order_status == 0 {
  452. prescriptions, _ = service.GetNewUnChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
  453. } else if order_status == 2 {
  454. prescriptions, _ = service.GetNewChargeHisHospitalPrescriptionFive(admin.CurrentOrgId, patient_id, his_patient_id, recordDateTime)
  455. }
  456. var monthPrescriptions []*models.HisPrescription
  457. var settle_prescriptions []*models.HisHospitalPrescription
  458. if order_status == 1 || order_status == 0 {
  459. monthPrescriptions, _ = service.GetUnChargeMonthHisPrescriptionThree(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
  460. } else if order_status == 2 {
  461. monthPrescriptions, _ = service.GetChargeMonthHisPrescriptionFour(admin.CurrentOrgId, patient_id, startRecordDateTime, endRecordDateTime, p_type)
  462. }
  463. if order_status == 1 || order_status == 0 {
  464. settle_prescriptions, _ = service.GetSettleHisHospitalPrescription(admin.CurrentOrgId, patient_id, his_patient_info.Number)
  465. } else if order_status == 2 {
  466. settle_prescriptions, _ = service.GetSettleHisHospitalPrescriptionTwo(admin.CurrentOrgId, patient_id, his_patient_info.Number)
  467. }
  468. var settle_total float64
  469. for _, item := range settle_prescriptions {
  470. if len(item.HisPrescriptionProject) > 0 {
  471. for _, subItem := range item.HisPrescriptionProject {
  472. count, _ := strconv.ParseFloat(subItem.Count, 64)
  473. total, _ := decimal.NewFromFloat(count * subItem.Price).Round(2).Float64()
  474. settle_total = settle_total + total
  475. }
  476. }
  477. if len(item.HisDoctorAdviceInfo) > 0 {
  478. for _, subItem := range item.HisDoctorAdviceInfo {
  479. total, _ := decimal.NewFromFloat(subItem.PrescribingNumber * subItem.Price).Round(2).Float64()
  480. settle_total = settle_total + total
  481. }
  482. }
  483. }
  484. settle_total, _ = decimal.NewFromFloat(settle_total).Round(2).Float64()
  485. case_history, _ := service.GetHisPatientCaseHistoryInfo(admin.CurrentOrgId, patient_id, recordDateTime)
  486. patientPrescriptionInfo, _ := service.FindPatientPrescriptionInfoTwo(admin.CurrentOrgId, patient_id, recordDateTime, p_type)
  487. order, _ := service.GetNewHisOrder(admin.CurrentOrgId, his_patient_info.Number, patient_id)
  488. doctors, _ := service.GetHisAdminUserDoctors(admin.CurrentOrgId)
  489. //获取所有科室信息
  490. department, _ := service.GetAllDepartMent(admin.CurrentOrgId)
  491. c.ServeSuccessJSON(map[string]interface{}{
  492. "his_info": his_patient_info,
  493. "xt_info": xt_patient_info,
  494. "prescription": prescriptions,
  495. "case_history": case_history,
  496. "info": patientPrescriptionInfo,
  497. "month_prescriptions": monthPrescriptions,
  498. "order": order,
  499. "doctors": doctors,
  500. "department": department,
  501. "settle_prescriptions": settle_prescriptions,
  502. "settle_total": settle_total,
  503. })
  504. return
  505. }
  506. func (c *HisHospitalApiController) GetHisHospitalrescriptionList() {
  507. record_date := c.GetString("record_date")
  508. keywords := c.GetString("keywords")
  509. page, _ := c.GetInt64("page")
  510. limit, _ := c.GetInt64("limit")
  511. timeLayout := "2006-01-02"
  512. loc, _ := time.LoadLocation("Local")
  513. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  514. if err != nil {
  515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  516. return
  517. }
  518. recordDateTime := theTime.Unix()
  519. adminInfo := c.GetAdminUserInfo()
  520. prescriptionOrder, err, total := service.GetHisPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
  521. //adminInfo := c.GetAdminUserInfo()
  522. //prescriptionOrder, err := service.GetHisPrescriptionOrderList(adminInfo.CurrentOrgId)
  523. //fmt.Println(prescriptionOrder)
  524. if err == nil {
  525. c.ServeSuccessJSON(map[string]interface{}{
  526. "order": prescriptionOrder,
  527. "total": total,
  528. })
  529. } else {
  530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  531. return
  532. }
  533. }
  534. func (c *HisHospitalApiController) GetHisHospitalPrescriptionList() {
  535. record_date := c.GetString("record_date")
  536. keywords := c.GetString("keywords")
  537. page, _ := c.GetInt64("page")
  538. limit, _ := c.GetInt64("limit")
  539. timeLayout := "2006-01-02"
  540. loc, _ := time.LoadLocation("Local")
  541. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  542. if err != nil {
  543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  544. return
  545. }
  546. recordDateTime := theTime.Unix()
  547. adminInfo := c.GetAdminUserInfo()
  548. prescriptionOrder, err, total := service.GetHisHospitalPatientPrescriptionList(adminInfo.CurrentOrgId, keywords, recordDateTime, page, limit)
  549. if err == nil {
  550. c.ServeSuccessJSON(map[string]interface{}{
  551. "order": prescriptionOrder,
  552. "total": total,
  553. })
  554. } else {
  555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  556. return
  557. }
  558. }
  559. func (c *HisHospitalApiController) GetZHInHospitalCheck() {
  560. id, _ := c.GetInt64("id")
  561. record_time := c.GetString("record_time")
  562. name := c.GetString("name")
  563. phone := c.GetString("phone")
  564. id_card_type, _ := c.GetInt64("id_card_type")
  565. certificates, _ := c.GetInt64("certificates")
  566. id_card_no := c.GetString("id_card_no")
  567. doctor, _ := c.GetInt64("doctor")
  568. admin_user_id, _ := c.GetInt64("admin_user_id")
  569. department, _ := c.GetInt64("department")
  570. adm_bed, _ := c.GetInt64("adm_bed")
  571. diagnosis_ids := c.GetString("diagnosis")
  572. sick_type, _ := c.GetInt64("sick_type")
  573. start_time := c.GetString("start_time")
  574. balance_accounts_type, _ := c.GetInt64("balance_accounts_type")
  575. med_type, _ := c.GetInt64("med_type")
  576. timeLayout := "2006-01-02"
  577. loc, _ := time.LoadLocation("Local")
  578. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  579. if err != nil {
  580. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  581. return
  582. }
  583. recordDateTime := theTime.Unix()
  584. adminInfo := c.GetAdminUserInfo()
  585. record, _ := service.GetLastHospitalRecord(id, adminInfo.CurrentOrgId)
  586. if record.ID != 0 {
  587. if record.InHospitalStatus == 1 && record.OutHospitalStatus != 1 {
  588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalExistDataException)
  589. return
  590. }
  591. }
  592. timestamp := time.Now().Unix()
  593. tempTime := time.Unix(timestamp, 0)
  594. timeFormat := tempTime.Format("20060102150405")
  595. chrgBchno := rand.Intn(100000) + 10000
  596. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(id, 10)
  597. timeStr := time.Now().Format("2006-01-02 15:04:05")
  598. fmt.Println(timeStr)
  599. timeArr := strings.Split(timeStr, " ")
  600. fmt.Println(timeArr)
  601. timeArrTwo := strings.Split(timeArr[0], "-")
  602. timeArrThree := strings.Split(timeArr[1], ":")
  603. var str = timeArrTwo[0] + timeArrTwo[1] + timeArrTwo[2] + timeArrThree[0] + timeArrThree[1] + timeArrThree[2] + strconv.FormatInt(id, 10)
  604. inHospital := &models.HisHospitalCheckRecord{
  605. PatientId: id,
  606. Name: name,
  607. MedicalTreatmentType: med_type,
  608. RecordDate: recordDateTime,
  609. IdCardNo: id_card_no,
  610. AdminUserId: admin_user_id,
  611. Departments: department,
  612. UserOrgId: adminInfo.CurrentOrgId,
  613. Status: 1,
  614. Ctime: time.Now().Unix(),
  615. Mtime: time.Now().Unix(),
  616. Number: str,
  617. Doctor: doctor,
  618. Certno: id_card_no,
  619. MedType: med_type,
  620. IptOtpNo: ipt_otp_no,
  621. AdmBed: adm_bed,
  622. IdCardType: id_card_type,
  623. Diagnosis: diagnosis_ids,
  624. SickType: sick_type,
  625. MdtrtCertType: "02",
  626. InHosptialTime: start_time,
  627. OutHosptialTime: "",
  628. InHospitalStatus: 1,
  629. Certificates: certificates,
  630. Phone: phone,
  631. BalanceAccountsType: balance_accounts_type,
  632. }
  633. service.CreateHospitalRecord(inHospital)
  634. c.ServeSuccessJSON(map[string]interface{}{
  635. "msg": "办理入院成功",
  636. "info": inHospital,
  637. })
  638. }
  639. func (this *HisHospitalApiController) GetZHOutHospitalCheck() {
  640. id, _ := this.GetInt64("id")
  641. record_time := this.GetString("record_time")
  642. out_time := this.GetString("out_time")
  643. record, _ := service.GetInHospitalRecord(id)
  644. if record.ID == 0 {
  645. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  646. return
  647. }
  648. timeLayout := "2006-01-02"
  649. loc, _ := time.LoadLocation("Local")
  650. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  651. recordDateTime := theTime.Unix()
  652. //timestamp := time.Now().Unix()
  653. //tempTime := time.Unix(timestamp, 0)
  654. //timeFormatOne := tempTime.Format("2006-01-02 15:04:05")
  655. record.OutHospitalStatus = 1
  656. record.OutHosptialTime = out_time
  657. record.OutWay = 1
  658. service.CreateHospitalRecord(&record)
  659. orders, _ := service.GetHisOrderInfoByNumberFour(record.Number)
  660. var total float64
  661. for _, item := range orders {
  662. total = total + item.DetItemFeeSumamt
  663. }
  664. order := &models.HisOrder{
  665. UserOrgId: this.GetAdminUserInfo().CurrentOrgId,
  666. HisPatientId: record.ID,
  667. PatientId: record.PatientId,
  668. SettleAccountsDate: recordDateTime,
  669. Ctime: time.Now().Unix(),
  670. Mtime: time.Now().Unix(),
  671. Status: 1,
  672. Number: record.Number,
  673. Infcode: 0,
  674. WarnMsg: "",
  675. Cainfo: "",
  676. ErrMsg: "",
  677. RespondTime: "",
  678. InfRefmsgid: "",
  679. OrderStatus: 1,
  680. MdtrtId: record.Number,
  681. IsMedicineInsurance: 1,
  682. PType: 1,
  683. MedfeeSumamt: total,
  684. PsnPartAmt: total,
  685. }
  686. err := service.CreateOrder(order)
  687. if err != nil {
  688. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  689. return
  690. }
  691. this.ServeSuccessJSON(map[string]interface{}{
  692. "msg": "出院成功",
  693. })
  694. }
  695. func (c *HisHospitalApiController) GetSettleInfo() {
  696. order_id, _ := c.GetInt64("order_id")
  697. in_hospital_id, _ := c.GetInt64("in_hospital_id")
  698. pay_way, _ := c.GetInt64("pay_way")
  699. pay_price, _ := c.GetFloat("pay_price")
  700. pay_card_no := c.GetString("pay_card_no")
  701. discount_price, _ := c.GetFloat("discount_price")
  702. preferential_price, _ := c.GetFloat("preferential_price")
  703. reality_price, _ := c.GetFloat("reality_price")
  704. found_price, _ := c.GetFloat("found_price")
  705. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  706. private_price, _ := c.GetFloat("private_price")
  707. fapiao_code := c.GetString("fapiao_code")
  708. fapiao_number := c.GetString("fapiao_number")
  709. id, _ := c.GetInt64("patient_id")
  710. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  711. tmp_decimal := c.GetString("tmp_decimal")
  712. var decimal float64 //本次使用的押金
  713. var errmsg error
  714. tx := service.XTWriteDB().Begin() //开了事务
  715. //只检测扣费函数SpendDeposit有没有返回错误,如果有则回滚所有以TX结尾的方法(去掉TX即为原先的方法)
  716. defer func() {
  717. if errmsg != nil {
  718. utils.ErrorLog("事务失败,原因为: %v", errmsg.Error())
  719. tx.Rollback()
  720. } else {
  721. tx.Commit()
  722. }
  723. }()
  724. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  725. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  726. return
  727. }
  728. if len(tmp_decimal) > 0 {
  729. if tmp_decimal[0] == 45 {
  730. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  731. return
  732. }
  733. }
  734. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  735. if errs != nil {
  736. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金金额错误")
  737. return
  738. }
  739. decimal = tt
  740. record, _ := service.GetInHospitalRecordTX(in_hospital_id, tx)
  741. order, _ := service.GetHisOrderByIDTX(order_id, tx)
  742. chrg_bchno := order.Number
  743. if record.ID == 0 {
  744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  745. return
  746. }
  747. if record.InHospitalStatus == 1 && record.OutHospitalStatus == 0 {
  748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHospitalNoExistDataException)
  749. return
  750. }
  751. order.OrderStatus = 2
  752. order.DiscountPrice = discount_price
  753. order.MedicalInsurancePrice = medical_insurance_price
  754. order.FaPiaoNumber = fapiao_number
  755. order.FaPiaoCode = fapiao_code
  756. order.PayWay = pay_way
  757. order.PayPrice = pay_price
  758. order.PayCardNo = pay_card_no
  759. order.PreferentialPrice = preferential_price
  760. order.RealityPrice = reality_price
  761. order.FoundPrice = found_price
  762. order.PrivatePrice = private_price
  763. order.MdtrtId = record.Number
  764. order.MedfeeSumamt = order.MedfeeSumamt
  765. order.PsnCashPay = order.MedfeeSumamt
  766. order.PsnName = record.Name
  767. order.Certno = record.IdCardNo
  768. order.IsMedicineInsurance = 0
  769. order.Decimal = decimal
  770. year2 := time.Now().Format("2006")
  771. month2 := time.Now().Format("01")
  772. day2 := time.Now().Format("02")
  773. hour := time.Now().Format("15")
  774. min := time.Now().Format("04")
  775. second := time.Now().Format("05")
  776. order.SetlTime = year2 + "-" + month2 + "-" + day2 + " " + hour + ":" + min + ":" + second
  777. //order.SetlTime =
  778. err := service.UpdataOrderStatusTwoTX(chrg_bchno, c.GetAdminUserInfo().CurrentOrgId, tx)
  779. err = service.UpDateOrderTX(order, tx)
  780. //判断是否使用了押金
  781. if dec_way == "true" {
  782. tmpstring := strconv.FormatInt(order.ID, 10)
  783. //扣押金
  784. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  785. if errmsg != nil {
  786. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  787. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateOrderException)
  788. return
  789. }
  790. }
  791. if err == nil {
  792. c.ServeSuccessJSON(map[string]interface{}{
  793. "msg": "结算成功",
  794. })
  795. } else {
  796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  797. return
  798. }
  799. }
  800. func (c *HisHospitalApiController) ZHRefund() {
  801. order_id, _ := c.GetInt64("order_id")
  802. order, _ := service.GetHisOrderByID(order_id)
  803. adminUser := c.GetAdminUserInfo()
  804. orgid := c.GetAdminUserInfo().CurrentOrgId
  805. err := service.UpdataHospitalOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, "", "")
  806. if err != nil {
  807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  808. return
  809. }
  810. tmp := strconv.FormatInt(order.ID, 10)
  811. //当押金不为零时产生退费记录
  812. if order.Decimal != 0 {
  813. err = service.MoneyIncrease(orgid, order.PatientId, tmp, order.Decimal)
  814. if err != nil {
  815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  816. return
  817. }
  818. }
  819. c.ServeSuccessJSON(map[string]interface{}{
  820. "msg": "退费成功",
  821. })
  822. }
  823. func (this *HisHospitalApiController) GetZHOutHospitalUnCheck() {
  824. id, _ := this.GetInt64("id")
  825. record, _ := service.GetInHospitalRecord(id)
  826. if record.ID == 0 {
  827. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  828. return
  829. }
  830. record.OutHospitalStatus = 0
  831. service.CreateHospitalRecord(&record)
  832. this.ServeSuccessJSON(map[string]interface{}{
  833. "msg": "撤销出院成功",
  834. })
  835. }
  836. func (this *HisHospitalApiController) GetZHInHospitalUnCheck() {
  837. id, _ := this.GetInt64("id")
  838. record, _ := service.GetInHospitalRecord(id)
  839. if record.ID == 0 {
  840. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeInHospitalNoExistDataException)
  841. return
  842. }
  843. record.Status = 0
  844. service.CreateHospitalRecord(&record)
  845. this.ServeSuccessJSON(map[string]interface{}{
  846. "msg": "撤销入院成功",
  847. })
  848. }
  849. func (c *HisHospitalApiController) GetHisHospitalDetailPatientList() {
  850. record_date := c.GetString("record_date")
  851. sch_type, _ := c.GetInt64("sch_type")
  852. timeLayout := "2006-01-02"
  853. loc, _ := time.LoadLocation("Local")
  854. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  855. if err != nil {
  856. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  857. return
  858. }
  859. recordDateTime := theTime.Unix()
  860. adminInfo := c.GetAdminUserInfo()
  861. UnUploadPrescriptionPatients, _ := service.GetHisHospitalUnUploadPrescriptionDetailPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
  862. UploadPrescriptionPatients, _ := service.GetHisHospitalUploadPrescriptionDetailPatientList(adminInfo.CurrentOrgId, recordDateTime, sch_type)
  863. //var patients []*models.HisHospitalCheckRecord
  864. /* for _, item := range tempPatients {
  865. fmt.Println(item.ID)
  866. if item.ID > 0 && item.InHospitalStatus == 1 && item.HisHospitalOrder.OrderStatus != 2 {
  867. patients = append(patients, item)
  868. }
  869. }*/
  870. c.ServeSuccessJSON(map[string]interface{}{
  871. "list": UnUploadPrescriptionPatients,
  872. "list_two": UploadPrescriptionPatients,
  873. "upload_num": len(UploadPrescriptionPatients),
  874. "un_upload_num": len(UnUploadPrescriptionPatients),
  875. })
  876. }
  877. func (c *HisHospitalApiController) GetHisHospitalDetailInfo() {
  878. record_date := c.GetString("record_date")
  879. id, _ := c.GetInt64("id")
  880. is_upload, _ := c.GetInt64("is_upload")
  881. patient_id, _ := c.GetInt64("patient_id")
  882. start_time_str := c.GetString("start_time")
  883. end_time_str := c.GetString("end_time")
  884. record, _ := service.GetInHospitalRecord(id)
  885. timeLayout := "2006-01-02"
  886. loc, _ := time.LoadLocation("Local")
  887. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  888. if err != nil {
  889. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  890. return
  891. }
  892. recordDateTime := theTime.Unix()
  893. adminInfo := c.GetAdminUserInfo()
  894. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  895. if err != nil {
  896. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  897. return
  898. }
  899. recordStartTime := theStartTime.Unix()
  900. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  901. if err != nil {
  902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  903. return
  904. }
  905. recordEndTime := theEndTime.Unix()
  906. var prescriptions []*models.HisPrescription
  907. if is_upload == 1 { //未上传
  908. prescriptions, _ = service.GetUnUploadHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordDateTime)
  909. } else if is_upload == 2 { //已上传
  910. prescriptions, _ = service.GetUploadHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordDateTime)
  911. }
  912. var monthPrescriptions []*models.HisPrescription
  913. if is_upload == 1 {
  914. monthPrescriptions, _ = service.GetMonthUnUploadHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  915. } else if is_upload == 2 {
  916. monthPrescriptions, _ = service.GetMonthUploadHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  917. }
  918. c.ServeSuccessJSON(map[string]interface{}{
  919. "prescription": prescriptions,
  920. "month_prescriptions": monthPrescriptions,
  921. "his_info": record,
  922. })
  923. }
  924. func (c *HisHospitalApiController) GetHisHospitalMonthDetailInfo() {
  925. id, _ := c.GetInt64("id")
  926. is_upload, _ := c.GetInt64("is_upload")
  927. patient_id, _ := c.GetInt64("patient_id")
  928. start_time_str := c.GetString("start_time")
  929. end_time_str := c.GetString("end_time")
  930. record, _ := service.GetInHospitalRecord(id)
  931. timeLayout := "2006-01-02"
  932. loc, _ := time.LoadLocation("Local")
  933. adminInfo := c.GetAdminUserInfo()
  934. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  935. if err != nil {
  936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  937. return
  938. }
  939. recordStartTime := theStartTime.Unix()
  940. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  941. if err != nil {
  942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  943. return
  944. }
  945. recordEndTime := theEndTime.Unix()
  946. //var prescriptions []*models.HisPrescription
  947. var monthPrescriptions []*models.HisPrescription
  948. if is_upload == 1 {
  949. monthPrescriptions, _ = service.GetMonthUnUploadHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  950. } else if is_upload == 2 {
  951. monthPrescriptions, _ = service.GetMonthUploadHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  952. } else {
  953. monthPrescriptions, _ = service.GetAllMonthHisHospitalPrescription(adminInfo.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  954. }
  955. c.ServeSuccessJSON(map[string]interface{}{
  956. "month_prescriptions": monthPrescriptions,
  957. "his_info": record,
  958. })
  959. }