his_hospital_api_controller.go 37KB

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