陈少旭 1 nedēļu atpakaļ
vecāks
revīzija
285fdd7848

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1436 - 24
controllers/fapiao_controller.go


+ 6 - 0
controllers/his_api_controller.go Parādīt failu

@@ -1186,6 +1186,9 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
1186 1186
 						case 15:
1187 1187
 							item.MedChrgitmType = "14"
1188 1188
 							break
1189
+						case 101:
1190
+							item.MedChrgitmType = "04"
1191
+							break
1189 1192
 
1190 1193
 						}
1191 1194
 
@@ -1222,6 +1225,9 @@ func (c *HisApiController) GetPrivateExpensesOrder() {
1222 1225
 						case 9:
1223 1226
 							item.MedChrgitmType = "14"
1224 1227
 							break
1228
+						case 101:
1229
+							item.MedChrgitmType = "04"
1230
+							break
1225 1231
 						default:
1226 1232
 							item.MedChrgitmType = "14"
1227 1233
 							break

+ 44 - 3
controllers/his_export_data_controller.go Parādīt failu

@@ -6,7 +6,7 @@ import (
6 6
 	"XT_New/service"
7 7
 	"github.com/astaxie/beego"
8 8
 	"github.com/shopspring/decimal"
9
-	"strings"
9
+	"time"
10 10
 )
11 11
 
12 12
 type HisExportDataController struct {
@@ -19,6 +19,38 @@ func HisExportDataApiRegistRouters() {
19 19
 
20 20
 	beego.Router("/api/batchsettle/get", &HisExportDataController{}, "Get:GetExportSettleData")
21 21
 
22
+	beego.Router("/api/export/10726/detail", &HisExportDataController{}, "Get:Get10726DetailExportData")
23
+	beego.Router("/api/export/10726/summary", &HisExportDataController{}, "Get:Get10726SummaryExportData")
24
+	beego.Router("/api/export/10697/summary", &HisExportDataController{}, "Get:Get10697SummaryExportData")
25
+
26
+}
27
+
28
+func (c *HisExportDataController) Get10726DetailExportData() {
29
+	start_time := c.GetString("start_time")
30
+	end_time := c.GetString("end_time")
31
+	result, _ := service.GetHisOrderBy10726Detail(start_time, end_time)
32
+	c.ServeSuccessJSON(map[string]interface{}{
33
+		"result": result,
34
+	})
35
+}
36
+
37
+func (c *HisExportDataController) Get10726SummaryExportData() {
38
+	start_time := c.GetString("start_time")
39
+	end_time := c.GetString("end_time")
40
+	result, _ := service.GetHisOrderBy10726Summary(start_time, end_time)
41
+	c.ServeSuccessJSON(map[string]interface{}{
42
+		"result": result,
43
+	})
44
+}
45
+
46
+func (c *HisExportDataController) Get10697SummaryExportData() {
47
+	start_time := c.GetString("start_time")
48
+	end_time := c.GetString("end_time")
49
+	ins := c.GetString("ins")
50
+	result, _ := service.GetHisOrderBy10697Summary(start_time, end_time, ins)
51
+	c.ServeSuccessJSON(map[string]interface{}{
52
+		"result": result,
53
+	})
22 54
 }
23 55
 
24 56
 func (c *HisExportDataController) GetExportSettleData() {
@@ -195,6 +227,15 @@ func (c *HisExportDataController) GetExportSettleData() {
195 227
 			otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
196 228
 		}
197 229
 	}
230
+
231
+	t := time.Unix(orders[0].SettleAccountsDate, 0)
232
+	t2 := time.Unix(orders[len(orders)-1].SettleAccountsDate, 0)
233
+
234
+	// 使用Format方法将时间转换为字符串
235
+	// 这里以 "2006-01-02 15:04:05" 为例,它是Go的预定义常量格式
236
+	f_time := t.Format("2006-01-02")
237
+
238
+	l_time := t2.Format("2006-01-02")
198 239
 	c.ServeSuccessJSON(map[string]interface{}{
199 240
 		"order_infos":                                 orderInfos,
200 241
 		"number":                                      order.MdtrtId,
@@ -238,8 +279,8 @@ func (c *HisExportDataController) GetExportSettleData() {
238 279
 		"org_name": miConfig.OrgName,
239 280
 		"org_code": miConfig.Code,
240 281
 		"num":      len(orders),
241
-		"f_time":   strings.Split(orders[0].SetlTime, " ")[0],
242
-		"l_time":   strings.Split(orders[len(orders)-1].SetlTime, " ")[0],
282
+		"f_time":   f_time,
283
+		"l_time":   l_time,
243 284
 	})
244 285
 
245 286
 }

+ 147 - 0
models/bwfapiao/baiwang.go Parādīt failu

@@ -78,3 +78,150 @@ type QrcodeCertifyResultError struct {
78 78
 	SubCode    string `json:"subCode"`    // 子错误码
79 79
 	SubMessage string `json:"subMessage"` // 子错误信息
80 80
 }
81
+
82
+// 公共响应参数
83
+type CommonResponse struct {
84
+	Success       bool          `json:"success"`       // 接口调用成功或失败的标志
85
+	Method        string        `json:"method"`        // 接口的唯一标识
86
+	RequestID     string        `json:"requestId"`     // 请求唯一标识
87
+	Response      interface{}   `json:"response"`      // 业务接口调用成功后的具体响应信息
88
+	ErrorResponse ErrorResponse `json:"errorResponse"` // 错误响应信息
89
+}
90
+
91
+// 定义响应结构体
92
+type RedAddResponse struct {
93
+	Success       bool                `json:"success"`                 // 接口调用成功或失败的标志
94
+	Method        string              `json:"method"`                  // 接口的唯一标识
95
+	RequestId     string              `json:"requestId"`               // 请求唯一标识
96
+	Response      []RedAddInvoiceData `json:"response,omitempty"`      // 业务响应信息
97
+	ErrorResponse ErrorResponse       `json:"errorResponse,omitempty"` // 错误响应信息
98
+}
99
+
100
+type RedAddInvoiceData struct {
101
+	RedConfirmUUID     string `json:"redConfirmUuid"`
102
+	RedInvoiceNo       string `json:"redInvoiceNo"`
103
+	ConfirmState       string `json:"confirmState"`
104
+	RedConfirmNo       string `json:"redConfirmNo"`
105
+	ConfirmBillingMark string `json:"confirmBillingMark"`
106
+	RedConfirmSerialNo string `json:"redConfirmSerialNo"`
107
+}
108
+
109
+// 定义响应结构体
110
+type RedOperaResponse struct {
111
+	Success       bool                  `json:"success"`                 // 接口调用成功或失败的标志
112
+	Method        string                `json:"method"`                  // 接口的唯一标识
113
+	RequestId     string                `json:"requestId"`               // 请求唯一标识
114
+	Response      []RedOperaInvoiceData `json:"response,omitempty"`      // 业务响应信息
115
+	ErrorResponse ErrorResponse         `json:"errorResponse,omitempty"` // 错误响应信息
116
+}
117
+
118
+type RedOperaInvoiceData struct {
119
+	RedConfirmUUID     string `json:"redConfirmUuid"`
120
+	RedInvoiceNo       string `json:"redInvoiceNo"`
121
+	ConfirmState       string `json:"confirmState"`
122
+	RedConfirmNo       string `json:"redConfirmNo"`
123
+	ConfirmBillingMark string `json:"confirmBillingMark"`
124
+	RedConfirmSerialNo string `json:"redConfirmSerialNo"`
125
+}
126
+
127
+type InvoiceIssueResponse struct {
128
+	Method        string                   `json:"method"`
129
+	Success       bool                     `json:"success"`
130
+	RequestID     string                   `json:"requestId"`
131
+	Response      InvoiceIssueResponseData `json:"response"`
132
+	ErrorResponse ErrorResponse            `json:"errorResponse,omitempty"` // 错误响应信息
133
+
134
+}
135
+
136
+type InvoiceIssueResponseData struct {
137
+	Fail    []InvoiceIssueFailData    `json:"fail"`
138
+	Success []InvoiceIssueSuccessData `json:"success"`
139
+}
140
+
141
+type InvoiceIssueFailData struct {
142
+	InvoiceTotalPrice    float64                      `json:"invoiceTotalPrice"`
143
+	InvoiceTotalTax      float64                      `json:"invoiceTotalTax"`
144
+	InvoiceTotalPriceTax float64                      `json:"invoiceTotalPriceTax"`
145
+	SerialNo             string                       `json:"serialNo"`
146
+	InvoiceDetailsList   []InvoiceDetailsFailItemData `json:"invoiceDetailsList"`
147
+}
148
+
149
+type InvoiceDetailsFailItemData struct {
150
+	PriceTaxMark         string  `json:"priceTaxMark"`
151
+	GoodsTaxRate         float64 `json:"goodsTaxRate"`
152
+	InvoiceLineNature    string  `json:"invoiceLineNature"`
153
+	GoodsTotalPrice      float64 `json:"goodsTotalPrice"`
154
+	GoodsSpecification   string  `json:"goodsSpecification"`
155
+	GoodsPrice           float64 `json:"goodsPrice"`
156
+	FreeTaxMark          string  `json:"freeTaxMark"`
157
+	GoodsQuantity        string  `json:"goodsQuantity"`
158
+	GoodsUnit            string  `json:"goodsUnit"`
159
+	GoodsTotalTax        float64 `json:"goodsTotalTax"`
160
+	GoodsCode            string  `json:"goodsCode"`
161
+	PreferentialMark     string  `json:"preferentialMark"`
162
+	GoodsName            string  `json:"goodsName"`
163
+	GoodsLineNo          string  `json:"goodsLineNo"`
164
+	VatSpecialManagement string  `json:"vatSpecialManagement"`
165
+}
166
+
167
+type InvoiceIssueSuccessData struct {
168
+	PaperInvoiceCode     string                          `json:"paperInvoiceCode"`
169
+	EInvoiceUrl          string                          `json:"eInvoiceUrl"`
170
+	InvoiceTotalTax      float64                         `json:"invoiceTotalTax"`
171
+	InvoiceDate          string                          `json:"invoiceDate"`
172
+	InvoiceCode          string                          `json:"invoiceCode"`
173
+	InvoiceTotalPriceTax float64                         `json:"invoiceTotalPriceTax"`
174
+	SerialNo             string                          `json:"serialNo"`
175
+	MulPurchaserList     []MulPurchaserItemData          `json:"mulPurchaserList"`
176
+	TaxControlCode       string                          `json:"taxControlCode"`
177
+	InvoiceCheckCode     string                          `json:"invoiceCheckCode"`
178
+	InvoiceQrCode        string                          `json:"invoiceQrCode"`
179
+	InvoiceTotalPrice    float64                         `json:"invoiceTotalPrice"`
180
+	InvoiceDetailsList   []InvoiceDetailsSuccessItemData `json:"invoiceDetailsList"`
181
+	InvoiceTypeCode      string                          `json:"invoiceTypeCode"`
182
+	PaperInvoiceNo       string                          `json:"paperInvoiceNo"`
183
+	InvoiceNo            string                          `json:"invoiceNo"`
184
+	MulPurchaserMark     string                          `json:"mulPurchaserMark"`
185
+}
186
+
187
+type MulPurchaserItemData struct {
188
+	Purchaser       string `json:"purchaser"`
189
+	CertificateNo   string `json:"certificateNo"`
190
+	CertificateType string `json:"certificateType"`
191
+}
192
+
193
+type InvoiceDetailsSuccessItemData struct {
194
+	PriceTaxMark       string  `json:"priceTaxMark"`
195
+	GoodsTaxRate       float64 `json:"goodsTaxRate"`
196
+	GoodsSpecification string  `json:"goodsSpecification"`
197
+	GoodsPrice         float64 `json:"goodsPrice"`
198
+	GoodsQuantity      float64 `json:"goodsQuantity"`
199
+	GoodsUnit          string  `json:"goodsUnit"`
200
+	GoodsTotalTax      float64 `json:"goodsTotalTax"`
201
+	GoodsCode          string  `json:"goodsCode"`
202
+	GoodsName          string  `json:"goodsName"`
203
+	GoodsLineNo        int     `json:"goodsLineNo"`
204
+	GoodsTotalPrice    float64 `json:"goodsTotalPrice"`
205
+}
206
+
207
+// 定义响应结构体
208
+type BanShiResponse struct {
209
+	Success       bool              `json:"success"`                 // 接口调用成功或失败的标志
210
+	Method        string            `json:"method"`                  // 接口的唯一标识
211
+	RequestId     string            `json:"requestId"`               // 请求唯一标识
212
+	Response      BanShiInvoiceData `json:"response,omitempty"`      // 业务响应信息
213
+	ErrorResponse ErrorResponse     `json:"errorResponse,omitempty"` // 错误响应信息
214
+}
215
+
216
+type BanShiInvoiceData struct {
217
+	EInvoiceUrl  string `json:"eInvoiceUrl"`
218
+	FileType     string `json:"fileType"`
219
+	ConfirmState string `json:"confirmState"`
220
+	UrlMap       Urls   `json:"urlMap"`
221
+}
222
+
223
+type Urls struct {
224
+	PdfUrl string `json:"pdfUrl"`
225
+	OfdUrl string `json:"ofdUrl"`
226
+	XmlUrl string `json:"xmlUrl"`
227
+}

+ 6 - 0
models/fapiao.go Parādīt failu

@@ -92,6 +92,12 @@ type HisFaPiaoOrder struct {
92 92
 	Patients                Patients                   `gorm:"ForeignKey:PatientId;AssociationForeignKey:ID" json:"patient"`
93 93
 	SettleAccountsDateOrder []*SettleAccountsDateOrder `gorm:"-" json:"orders" form:"orders"`
94 94
 	Message                 string                     `gorm:"column:message" json:"message" form:"message"`
95
+	RedInvoiceUUID          string                     `gorm:"column:red_invoice_uuid" json:"red_invoice_uuid" form:"red_invoice_uuid"`
96
+
97
+	BlueRequestInfo  string `gorm:"column:blue_request_info" json:"blue_request_info" form:"blue_request_info"`
98
+	BlueResponseInfo string `gorm:"column:blue_response_info" json:"blue_response_info" form:"blue_response_info"`
99
+	RedRequestInfo   string `gorm:"column:red_request_info" json:"red_request_info" form:"red_request_info"`
100
+	RedResponseInfo  string `gorm:"column:red_response_info" json:"red_response_info" form:"red_response_info"`
95 101
 }
96 102
 
97 103
 func (HisFaPiaoOrder) TableName() string {

+ 48 - 0
models/his_models.go Parādīt failu

@@ -2941,3 +2941,51 @@ type XtGoodTeamList struct {
2941 2941
 func (XtGoodTeamList) TableName() string {
2942 2942
 	return "xt_good_team_list"
2943 2943
 }
2944
+
2945
+type HisOrder10726 struct {
2946
+	ID                  uint    `gorm:"primaryKey"`
2947
+	UserOrgID           int     `gorm:"column:user_org_id"`
2948
+	OrderStatus         int     `gorm:"column:order_status"`
2949
+	SetlTime            string  `gorm:"column:setl_time"`
2950
+	IsMedicineInsurance int     `gorm:"column:is_medicine_insurance"`
2951
+	Status              int     `gorm:"column:status"`
2952
+	Certno              string  `gorm:"column:certno"`
2953
+	PsnName             string  `gorm:"column:psn_name"`
2954
+	Gend                string  `gorm:"column:gend"`
2955
+	PsnType             string  `gorm:"column:psn_type"`
2956
+	MedType             string  `gorm:"column:med_type"`
2957
+	MedfeeSumamt        float64 `gorm:"column:medfee_sumamt"`
2958
+	HifpPay             float64 `gorm:"column:hifp_pay"`
2959
+	ActPayDedc          float64 `gorm:"column:act_pay_dedc"`
2960
+	HifobPay            float64 `gorm:"column:hifob_pay"`
2961
+	HifmiPay            float64 `gorm:"column:hifmi_pay"`
2962
+	HifesPay            float64 `gorm:"column:hifes_pay"`
2963
+	CvlservPay          float64 `gorm:"column:cvlserv_pay"`
2964
+	MafPay              float64 `gorm:"column:maf_pay"`
2965
+	OthPay              float64 `gorm:"column:oth_pay"`
2966
+	HospPartAmt         float64 `gorm:"column:hosp_part_amt"`
2967
+	AcctPay             float64 `gorm:"column:acct_pay"`
2968
+	AcctMulaidPay       float64 `gorm:"column:acct_mulaid_pay"`
2969
+	FundPaySumamt       float64 `gorm:"column:fund_pay_sumamt"`
2970
+	PsnCashPay          float64 `gorm:"column:psn_cash_pay"`
2971
+}
2972
+
2973
+type HisOrder10726Summary struct {
2974
+	Insutype            string  `gorm:"column:insutype"`
2975
+	UserOrgID           int     `gorm:"column:user_org_id"`
2976
+	OrderStatus         int     `gorm:"column:order_status"`
2977
+	SetlTime            string  `gorm:"column:setl_time"`
2978
+	IsMedicineInsurance int     `gorm:"column:is_medicine_insurance"`
2979
+	Status              int     `gorm:"column:status"`
2980
+	PatientID           int     `gorm:"column:patient_id"`
2981
+	ID                  int     `gorm:"column:id"`
2982
+	MedfeeSumamt        float64 `gorm:"column:medfee_sumamt"`
2983
+	HifpPay             float64 `gorm:"column:hifp_pay"`
2984
+	HifmiPay            float64 `gorm:"column:hifmi_pay"`
2985
+	CvlservPay          float64 `gorm:"column:cvlserv_pay"`
2986
+	MafPay              float64 `gorm:"column:maf_pay"`
2987
+	OthPay              float64 `gorm:"column:oth_pay"`
2988
+	AcctPay             float64 `gorm:"column:acct_pay"`
2989
+	AcctMulaidPay       float64 `gorm:"column:acct_mulaid_pay"`
2990
+	PsnCashPay          float64 `gorm:"column:psn_cash_pay"`
2991
+}

+ 196 - 0
service/export_data_service.go Parādīt failu

@@ -134,3 +134,199 @@ func GetBatchHisOrderInfoByNumber(order_number string) (order []models.BatchHisO
134 134
 	err = readDb.Model(&models.BatchHisOrderInfo{}).Where("order_number = ? and status = 1", order_number).Find(&order).Error
135 135
 	return
136 136
 }
137
+
138
+type Results struct {
139
+	SerialNo           string  `gorm:"column:序号"`
140
+	MedicalArea        string  `gorm:"column:医疗区划"`
141
+	CertNo             string  `gorm:"column:证件号码"`
142
+	PsnName            string  `gorm:"column:姓名"`
143
+	Gender             string  `gorm:"column:性别"`
144
+	Occupation         string  `gorm:"column:职业"`
145
+	MedicalType        string  `gorm:"column:医疗类别"`
146
+	AdmissionTime      string  `gorm:"column:入院时间"`
147
+	DischargeTime      string  `gorm:"column:出院时间"`
148
+	SettlementTime     string  `gorm:"column:结算时间"`
149
+	DischargeDiagnosis string  `gorm:"column:出院诊断"`
150
+	InpatientDays      int     `gorm:"column:住院天数"`
151
+	MedicalFeeTotal    float64 `gorm:"column:医疗费总额"`
152
+	HifpPay            float64 `gorm:"column:统筹支付金额"`
153
+	ActPayDedc         float64 `gorm:"column:起付线"`
154
+	HifobPay           float64 `gorm:"column:职工大额基金支付"`
155
+	HifmiPay           float64 `gorm:"column:居民大病基金支出"`
156
+	HifesPay           float64 `gorm:"column:企业补充"`
157
+	CvlservPay         float64 `gorm:"column:公务员补助"`
158
+	MafPay             float64 `gorm:"column:医疗救助"`
159
+	OthPay             float64 `gorm:"column:其他支付"`
160
+	HospPartAmt        float64 `gorm:"column:医院负担"`
161
+	AcctPay            float64 `gorm:"column:个账支付"`
162
+	AcctMulaidPay      float64 `gorm:"column:共济支付"`
163
+	FundPaySumamt      float64 `gorm:"column:基金支付金额"`
164
+	PsnCashPay         float64 `gorm:"column:现金支付"`
165
+}
166
+
167
+type SummaryResults struct {
168
+	InsuranceType      string  `gorm:"column:险种类型"`   // 险种类型
169
+	MedicalArea        string  `gorm:"column:统筹区"`    // 统筹区
170
+	SettlementCategory string  `gorm:"column:清算类别"`   // 清算类别
171
+	PeopleCount        int     `gorm:"column:人数"`     // 人数
172
+	VisitCount         int     `gorm:"column:人次"`     // 人次
173
+	TotalMedicalFee    float64 `gorm:"column:医保费用合计"` // 医保费用合计
174
+	PoolFundPay        float64 `gorm:"column:统筹支付金额"` // 统筹支付金额
175
+	BigDiseaseFundPay  float64 `gorm:"column:大病基金支付"` // 大病基金支付
176
+	PublicServantPay   float64 `gorm:"column:公务员补助"`  // 公务员补助
177
+	MedicalAssistance  float64 `gorm:"column:医疗救助"`   // 医疗救助
178
+	OtherPay           float64 `gorm:"column:其他支付"`   // 其他支付
179
+	AcctPay            float64 `gorm:"column:个账支付"`   // 个账支付
180
+	MutualAidPay       float64 `gorm:"column:共济支付"`   // 共济支付
181
+	CashPay            float64 `gorm:"column:现金支付"`   // 现金支付
182
+}
183
+
184
+func GetHisOrderBy10726Detail(start_time string, end_time string) ([]Results, error) {
185
+	//err = readDb.Model(&models.HisOrder10726{}).Select("").Where("setl_time >= ? and setl_time <= ? AND status = 1 and order_status = 2  and user_org_id = 10721", start_time+" 00:00:00", end_time+" 23:59:00").Find(&order).Error
186
+	var result []Results
187
+	readDb.Table("his_order").Select(`
188
+		'' AS 序号,
189
+		'乐安县' AS 医疗区划,
190
+		certno AS 证件号码,
191
+		psn_name AS 姓名,
192
+		CASE 
193
+			WHEN gend = '1' THEN '男' 
194
+			WHEN gend = '2' THEN '女' 
195
+		END AS 性别,
196
+		CASE 
197
+			WHEN psn_type IN ('14', '15') THEN '居民(成年)'
198
+		END AS 职业,
199
+		CASE 
200
+			WHEN med_type = '990101' THEN '单病种门诊'
201
+			WHEN med_type = '14' THEN '门诊慢特病'
202
+		END AS 医疗类别,
203
+		setl_time AS 入院时间,
204
+		setl_time AS 出院时间,
205
+		setl_time AS 结算时间,
206
+		CASE 
207
+			WHEN med_type = '990101' THEN '尿毒症(免费透析)'
208
+			WHEN med_type = '14' THEN '尿毒症期'
209
+		END AS 出院诊断,
210
+		1 AS 住院天数,
211
+		medfee_sumamt AS 医疗费总额,
212
+		hifp_pay AS 统筹支付金额,
213
+		act_pay_dedc AS 起付线,
214
+		hifob_pay AS 职工大额基金支付,
215
+		hifmi_pay AS 居民大病基金支出,
216
+		hifes_pay AS 企业补充,
217
+		cvlserv_pay AS 公务员补助,
218
+		maf_pay AS 医疗救助,
219
+		oth_pay AS 其他支付,
220
+		hosp_part_amt AS 医院负担,
221
+		acct_pay AS 个账支付,
222
+		acct_mulaid_pay AS 共济支付,
223
+		fund_pay_sumamt AS 基金支付金额,
224
+		psn_cash_pay AS 现金支付
225
+	`).Where("user_org_id = ?", 10726).
226
+		Where("order_status = ?", 2).
227
+		Where("setl_time >= ?", start_time).
228
+		Where("setl_time <= ?", end_time).
229
+		Where("is_medicine_insurance = ?", 1).
230
+		Where("status = ?", 1).
231
+		Scan(&result)
232
+	return result, err
233
+}
234
+
235
+func GetHisOrderBy10726Summary(start_time string, end_time string) ([]SummaryResults, error) {
236
+	var result []SummaryResults
237
+	err = readDb.Table("his_order").
238
+		Select(`
239
+			CASE
240
+				WHEN insutype = "390" THEN "城乡居民"
241
+				WHEN insutype = "310" THEN "职工"
242
+			END AS "险种类型",
243
+			"乐安县" AS 统筹区,
244
+			"门诊" AS 清算类别,
245
+			COUNT(DISTINCT patient_id) AS 人数,
246
+			COUNT(id) AS 人次,
247
+			SUM(medfee_sumamt) AS 医保费用合计,
248
+			SUM(hifp_pay) AS 统筹支付金额,
249
+			SUM(hifmi_pay) AS 大病基金支付,
250
+			SUM(cvlserv_pay) AS 公务员补助,
251
+			SUM(maf_pay) AS 医疗救助,
252
+			SUM(oth_pay) AS 其他支付,
253
+			SUM(acct_pay) AS 个账支付,
254
+			SUM(acct_mulaid_pay) AS 共济支付,
255
+			SUM(psn_cash_pay) AS 现金支付
256
+		`).
257
+		Where("user_org_id = ? AND order_status = ? AND setl_time >= ? AND setl_time <= ? AND is_medicine_insurance = ? AND status = ?",
258
+			10726, 2, start_time, end_time, 1, 1).
259
+		Group("insutype").
260
+		Scan(&result).Error
261
+	return result, err
262
+
263
+}
264
+
265
+type MedicalCharges struct {
266
+	SerialNo                 string  `gorm:"column:编号"`     // 编号
267
+	MedicalInsuranceNo       string  `gorm:"column:医疗保险号"`  // 医疗保险号
268
+	PsnName                  string  `gorm:"column:姓名"`     // 姓名
269
+	BedsFee                  float64 `gorm:"column:床位费"`    // 床位费
270
+	ConsultationFee          float64 `gorm:"column:诊察费"`    // 诊察费
271
+	ExaminationFee           float64 `gorm:"column:检查费"`    // 检查费
272
+	LaboratoryFee            float64 `gorm:"column:化验费"`    // 化验费
273
+	TreatmentFee             float64 `gorm:"column:治疗费"`    // 治疗费
274
+	NursingFee               float64 `gorm:"column:护理费"`    // 护理费
275
+	HealthMaterialsFee       float64 `gorm:"column:卫生材料费"`  // 卫生材料费
276
+	WesternMedicineFee       float64 `gorm:"column:西药费"`    // 西药费
277
+	ChineseMedicineFee       float64 `gorm:"column:中药饮片费"`  // 中药饮片费
278
+	ChinesePatentMedicineFee float64 `gorm:"column:中成药费"`   // 中成药费
279
+	GeneralTreatmentFee      float64 `gorm:"column:一般诊疗费"`  // 一般诊疗费
280
+	RegistrationFee          float64 `gorm:"column:挂号费"`    // 挂号费
281
+	OtherFee                 float64 `gorm:"column:其他费"`    // 其他费
282
+	TotalMedicalFee          float64 `gorm:"column:医疗费总额"`  // 医疗费总额
283
+	SelfPay                  float64 `gorm:"column:个人自付金额"` // 个人自付金额
284
+	AcctPay                  float64 `gorm:"column:基本账户支付"` // 基本账户支付
285
+	MutualAidAcctPay         float64 `gorm:"column:共济账户支付"` // 共济账户支付
286
+	PublicServantPay         float64 `gorm:"column:公务员补助"`  // 公务员补助
287
+	PoolFundPay              float64 `gorm:"column:统筹支付金额"` // 统筹支付金额
288
+	MedicalAssistance        float64 `gorm:"column:医疗救助"`   // 医疗救助
289
+	BigDiseasePay            float64 `gorm:"column:大病支付"`   // 大病支付
290
+	EnterpriseSupplement     float64 `gorm:"column:企业补充支付"` // 企业补充支付
291
+	MajorDiseaseSupplement   float64 `gorm:"column:重大疾病补充"` // 重大疾病补充 (Empty in SQL, will be left blank in Go)
292
+	OtherPayment             float64 `gorm:"column:其它支付"`   // 其它支付
293
+}
294
+
295
+func GetHisOrderBy10697Summary(start_time string, end_time string, ins string) (results []MedicalCharges, err error) {
296
+	err = readDb.Table("his_order").
297
+		Select(`
298
+        "" AS 编号,
299
+        his_order.certno AS 医疗保险号,
300
+        his_order.psn_name AS 姓名,
301
+        SUM(CASE WHEN i.med_chrgitm_type = '01' THEN i.det_item_fee_sumamt ELSE 0 END) AS 床位费,
302
+        SUM(CASE WHEN i.med_chrgitm_type = '02' THEN i.det_item_fee_sumamt ELSE 0 END) AS 诊察费,
303
+        SUM(CASE WHEN i.med_chrgitm_type = '03' THEN i.det_item_fee_sumamt ELSE 0 END) AS 检查费,
304
+        SUM(CASE WHEN i.med_chrgitm_type = '04' THEN i.det_item_fee_sumamt ELSE 0 END) AS 化验费,
305
+        SUM(CASE WHEN i.med_chrgitm_type = '05' THEN i.det_item_fee_sumamt ELSE 0 END) AS 治疗费,
306
+        SUM(CASE WHEN i.med_chrgitm_type = '07' THEN i.det_item_fee_sumamt ELSE 0 END) AS 护理费,
307
+        SUM(CASE WHEN i.med_chrgitm_type = '08' THEN i.det_item_fee_sumamt ELSE 0 END) AS 卫生材料费,
308
+        SUM(CASE WHEN i.med_chrgitm_type = '09' THEN i.det_item_fee_sumamt ELSE 0 END) AS 西药费,
309
+        SUM(CASE WHEN i.med_chrgitm_type = '10' THEN i.det_item_fee_sumamt ELSE 0 END) AS 中药饮片费,
310
+        SUM(CASE WHEN i.med_chrgitm_type = '11' THEN i.det_item_fee_sumamt ELSE 0 END) AS 中成药费,
311
+        SUM(CASE WHEN i.med_chrgitm_type = '12' THEN i.det_item_fee_sumamt ELSE 0 END) AS 一般诊疗费,
312
+        SUM(CASE WHEN i.med_chrgitm_type = '13' THEN i.det_item_fee_sumamt ELSE 0 END) AS 挂号费,
313
+        SUM(CASE WHEN i.med_chrgitm_type = '14' THEN i.det_item_fee_sumamt ELSE 0 END) AS 其他费,
314
+        SUM(his_order.medfee_sumamt) AS 医疗费总额,
315
+        SUM(his_order.psn_cash_pay) AS 个人自付金额,
316
+        SUM(his_order.acct_pay) AS 基本账户支付,
317
+        SUM(his_order.acct_mulaid_pay) AS 共济账户支付,
318
+        SUM(his_order.cvlserv_pay) AS 公务员补助,
319
+        SUM(his_order.hifp_pay) AS 统筹支付金额,
320
+        SUM(his_order.maf_pay) AS 医疗救助,
321
+        SUM(his_order.hifmi_pay) AS 大病支付,
322
+        SUM(his_order.hifes_pay) AS 企业补充支付,
323
+        "" AS 重大疾病补充,
324
+        SUM(his_order.oth_pay) AS 其它支付
325
+    `).
326
+		Joins("JOIN his_order_info i ON his_order.number = i.order_number").
327
+		Where("his_order.user_org_id = ? AND his_order.order_status = ? AND his_order.setl_time >= ? AND his_order.setl_time <= ? AND his_order.is_medicine_insurance = ? AND his_order.insutype = ? AND his_order.STATUS = ?",
328
+			10697, 2, start_time+" 00:00:00", end_time+" 23:59:59", 1, ins, 1).
329
+		Group("his_order.patient_id").
330
+		Scan(&results).Error
331
+	return
332
+}

+ 8 - 2
service/fapiao_service.go Parādīt failu

@@ -11,10 +11,14 @@ func FindFaPiaoConfigInfo(org_id int64) (config models.FapiaoConfig, err error)
11 11
 	return
12 12
 }
13 13
 
14
-func GetFaPiaoSettleList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, sort_type int64, start_time string, end_time string, is_open_fapiao int64, patient_id int64) (order []*models.HisOrderByFaPiao, err error, total int64) {
14
+func GetFaPiaoSettleList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, sort_type int64, start_time string, end_time string, is_open_fapiao int64, patient_id int64, keywords string) (order []*models.HisOrderByFaPiao, err error, total int64) {
15 15
 	offset := (page - 1) * limit
16
+	keywords = "%" + keywords + "%"
16 17
 	db := readDb.Model(&models.HisOrderByFaPiao{})
17 18
 
19
+	if len(keywords) > 0 {
20
+		db = db.Joins("join xt_patients  on xt_patients.id = his_order.patient_id and xt_patients.name like ?", keywords)
21
+	}
18 22
 	// Join the patients table based on user_org_id
19 23
 	db = db.Joins("join xt_patients as patient on patient.id = his_order.patient_id and patient.user_org_id = ?", user_org_id)
20 24
 
@@ -75,11 +79,13 @@ func GetFaPiaoSettleList(user_org_id int64, page int64, limit int64, start_time_
75 79
 	return
76 80
 }
77 81
 
78
-func GetFaPiaoList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64) (order []*models.HisFaPiaoOrder, err error, total int64) {
82
+func GetFaPiaoList(user_org_id int64, page int64, limit int64, start_time_timestamp int64, end_time_timestamp int64, keywords string) (order []*models.HisFaPiaoOrder, err error, total int64) {
79 83
 	offset := (page - 1) * limit
84
+	//keywords = "%" + keywords + "%"
80 85
 	db := readDb.Model(&models.HisFaPiaoOrder{})
81 86
 	db = db.Preload("Patients", "status = 1 AND user_org_id = ?", user_org_id)
82 87
 	db = db.Where("ctime >= ? and ctime <= ? and user_org_id = ? and status = 1 and pdf_url <> ''", start_time_timestamp, end_time_timestamp, user_org_id)
88
+
83 89
 	// Count the total number of records
84 90
 	db = db.Count(&total)
85 91
 	// Apply pagination