package controllers import ( "XT_New/enums" "XT_New/models" "XT_New/service" "github.com/astaxie/beego" "github.com/shopspring/decimal" "strings" ) type HisExportDataController struct { BaseAuthAPIController } func HisExportDataApiRegistRouters() { beego.Router("/api/export", &HisExportDataController{}, "Get:GetExportData") beego.Router("/api/batchsettle/get", &HisExportDataController{}, "Get:GetExportSettleData") } func (c *HisExportDataController) GetExportSettleData() { patient_id, _ := c.GetInt64("patient_id", 0) start_time := c.GetString("start_time") end_time := c.GetString("end_time") admin_user_id, _ := c.GetInt64("admin_user_id") var order models.HisOrder orders, _ := service.GetHisOrderByTime(patient_id, start_time, end_time) order = orders[len(orders)-1] order.MedfeeSumamt = 0 order.FundPaySumamt = 0 order.PsnCashPay = 0 order.ActPayDedc = 0 order.PreselfpayAmt = 0 order.HifpPay = 0 order.HifmiPay = 0 order.HifesPay = 0 order.MafPay = 0 order.CvlservPay = 0 order.OthPay = 0 order.AcctPay = 0 decimal.DivisionPrecision = 2 var orderInfos []models.BatchHisOrderInfo for _, item := range orders { order.MedfeeSumamt, _ = decimal.NewFromFloat(order.MedfeeSumamt).Add(decimal.NewFromFloat(item.MedfeeSumamt)).Float64() order.FundPaySumamt, _ = decimal.NewFromFloat(order.FundPaySumamt).Add(decimal.NewFromFloat(item.FundPaySumamt)).Float64() order.PsnCashPay, _ = decimal.NewFromFloat(order.PsnCashPay).Add(decimal.NewFromFloat(item.PsnCashPay)).Float64() order.ActPayDedc, _ = decimal.NewFromFloat(order.ActPayDedc).Add(decimal.NewFromFloat(item.ActPayDedc)).Float64() order.PreselfpayAmt, _ = decimal.NewFromFloat(order.PreselfpayAmt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() order.HifpPay, _ = decimal.NewFromFloat(order.HifpPay).Add(decimal.NewFromFloat(item.HifpPay)).Float64() order.HifmiPay, _ = decimal.NewFromFloat(order.HifmiPay).Add(decimal.NewFromFloat(item.HifmiPay)).Float64() order.HifesPay, _ = decimal.NewFromFloat(order.HifesPay).Add(decimal.NewFromFloat(item.HifesPay)).Float64() order.MafPay, _ = decimal.NewFromFloat(order.MafPay).Add(decimal.NewFromFloat(item.MafPay)).Float64() order.CvlservPay, _ = decimal.NewFromFloat(order.CvlservPay).Add(decimal.NewFromFloat(item.CvlservPay)).Float64() order.OthPay, _ = decimal.NewFromFloat(order.OthPay).Add(decimal.NewFromFloat(item.OthPay)).Float64() order.AcctPay, _ = decimal.NewFromFloat(order.AcctPay).Add(decimal.NewFromFloat(item.AcctPay)).Float64() orderInfo, _ := service.GetBatchHisOrderInfoByNumber(item.Number) orderInfos = append(orderInfos, orderInfo...) } //role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, c.GetAdminUserInfo().AdminUser.Id) if order.ID == 0 { c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong) return } miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId) org_id := c.GetAdminUserInfo().CurrentOrgId //adminInfo, _ := service.GetAdminUserInfoByID(org_id, order.Creator) patient, _ := service.GetFaPiaoPatientByID(org_id, order.PatientId) printor_admin, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id) charge_admin, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, order.Creator) var bedCostTotal float64 = 0 //床位总费 var bedCostSelfTotal float64 = 0 //床位自费 var bedCostPartSelfTotal float64 = 0 //床位部分项目自费 var operationCostTotal float64 = 0 //手术费 var operationCostSelfTotal float64 = 0 //手术费 var operationCostPartSelfTotal float64 = 0 //手术费 var otherCostTotal float64 = 0 //其他费用 var otherCostSelfTotal float64 = 0 //其他费用 var otherCostPartSelfTotal float64 = 0 //其他费用 var materialCostTotal float64 = 0 //材料费 var materialCostSelfTotal float64 = 0 //材料费 var materialCostPartSelfTotal float64 = 0 //材料费 var westernMedicineCostTotal float64 = 0 //西药费 var westernMedicineCostSelfTotal float64 = 0 //西药费 var westernMedicineCostPartSelfTotal float64 = 0 //西药费 var chineseTraditionalMedicineCostTotal float64 = 0 //中成药 var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药 var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药 var checkCostTotal float64 = 0 //检查费 var checkCostSelfTotal float64 = 0 //检查费 var checkCostPartSelfTotal float64 = 0 //检查费 var laboratoryCostTotal float64 = 0 //化验费 var laboratoryCostSelfTotal float64 = 0 //化验费 var laboratoryCostPartSelfTotal float64 = 0 //化验费 var treatCostTotal float64 = 0 //治疗费用 var treatCostSelfTotal float64 = 0 //治疗费用 var treatCostPartSelfTotal float64 = 0 //治疗费用 var hiliCostTotal float64 = 0 //护理费 var hiliCostSelfTotal float64 = 0 //护理费 var hiliCostPartSelfTotal float64 = 0 //护理费 decimal.DivisionPrecision = 2 for _, item := range orderInfos { if item.MedChrgitmType == "01" { //床位费 bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } if item.MedChrgitmType == "07" { //床位费 hiliCostTotal, _ = decimal.NewFromFloat(hiliCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() hiliCostSelfTotal, _ = decimal.NewFromFloat(hiliCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() hiliCostPartSelfTotal, _ = decimal.NewFromFloat(hiliCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() //hiliCostSelfTotal = hiliCostTotal } if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 { if item.MedChrgitmType == "03" { //检查费 laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } } else { if item.MedChrgitmType == "03" { //检查费 checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } } if item.MedChrgitmType == "04" { //化验费 laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费 treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } if item.MedChrgitmType == "06" { //手术费 operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } if item.MedChrgitmType == "08" { //材料费 materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } if item.MedChrgitmType == "09" { //西药费 westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } if item.MedChrgitmType == "11" { //中成费 chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费 otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64() otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64() otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64() } } c.ServeSuccessJSON(map[string]interface{}{ "order_infos": orderInfos, "number": order.MdtrtId, "date": order.SettleAccountsDate, "charge_admin": charge_admin, "printor_admin": printor_admin, "info": order, "bedCostTotal": bedCostTotal, "bedCostSelfTotal": bedCostSelfTotal, "bedCostPartSelfTotal": bedCostPartSelfTotal, "operationCostTotal": operationCostTotal, "operationCostSelfTotal": operationCostSelfTotal, "operationCostPartSelfTotal": operationCostPartSelfTotal, "otherCostTotal": otherCostTotal, "otherCostSelfTotal": otherCostSelfTotal, "otherCostPartSelfTotal": otherCostPartSelfTotal, "materialCostTotal": materialCostTotal, "materialCostSelfTotal": materialCostSelfTotal, "materialCostPartSelfTotal": materialCostPartSelfTotal, "westernMedicineCostTotal": westernMedicineCostTotal, "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal, "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal, "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal, "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal, "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal, "checkCostTotal": checkCostTotal, "checkCostSelfTotal": checkCostSelfTotal, "checkCostPartSelfTotal": checkCostPartSelfTotal, "laboratoryCostTotal": laboratoryCostTotal, "laboratoryCostSelfTotal": laboratoryCostSelfTotal, "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal, "treatCostTotal": treatCostTotal, "treatCostSelfTotal": treatCostSelfTotal, "treatCostPartSelfTotal": treatCostPartSelfTotal, "hiliCostTotal": hiliCostTotal, "hiliCostSelfTotal": hiliCostSelfTotal, "hiliCostPartSelfTotal": hiliCostPartSelfTotal, "patient": patient, "org_name": miConfig.OrgName, "org_code": miConfig.Code, "num": len(orders), "f_time": strings.Split(orders[0].SetlTime, " ")[0], "l_time": strings.Split(orders[len(orders)-1].SetlTime, " ")[0], }) } func (this *HisExportDataController) GetExportData() { start_time := this.GetString("start_time") start_time = start_time + " 00:00:00" end_time := this.GetString("end_time") end_time = end_time + " 23:59:59" type_str := this.GetString("type") if type_str == "1" { ps, _ := service.GetHisOrderDetailFor310(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId) this.ServeSuccessJSON(map[string]interface{}{ "order": ps, }) } else { ps, _ := service.GetHisOrderDetailFor390(start_time, end_time, this.GetAdminUserInfo().CurrentOrgId) this.ServeSuccessJSON(map[string]interface{}{ "order": ps, }) } }