|
@@ -320,7 +320,7 @@ func GetHisOrderBy10697Summary(start_time string, end_time string, ins string) (
|
320
|
320
|
SUM(his_order.maf_pay) AS 医疗救助,
|
321
|
321
|
SUM(his_order.hifmi_pay) AS 大病支付,
|
322
|
322
|
SUM(his_order.hifes_pay) AS 企业补充支付,
|
323
|
|
- "" AS 重大疾病补充,
|
|
323
|
+ 0 AS 重大疾病补充,
|
324
|
324
|
SUM(his_order.oth_pay) AS 其它支付
|
325
|
325
|
`).
|
326
|
326
|
Joins("JOIN his_order_info i ON his_order.number = i.order_number").
|
|
@@ -330,3 +330,66 @@ func GetHisOrderBy10697Summary(start_time string, end_time string, ins string) (
|
330
|
330
|
Scan(&results).Error
|
331
|
331
|
return
|
332
|
332
|
}
|
|
333
|
+
|
|
334
|
+func GetHisOrderBy10697SummaryTwo(startTime, endTime, ins string, st_stamp, end_stamp int64) ([]MedicalCharges, error) {
|
|
335
|
+ var results []MedicalCharges
|
|
336
|
+ // 改为字符串数组
|
|
337
|
+ medChargeTypes := []string{"01", "02", "03", "04", "05", "07", "08", "09", "10", "11", "12", "13", "14"}
|
|
338
|
+
|
|
339
|
+ // 定义子查询
|
|
340
|
+ subQuery := readDb.Table("his_order_info").
|
|
341
|
+ Select(`
|
|
342
|
+ order_number,
|
|
343
|
+ med_chrgitm_type,
|
|
344
|
+ SUM(det_item_fee_sumamt) AS det_item_fee_sumamt`).
|
|
345
|
+ Where("user_org_id = ? AND STATUS = ? AND (upload_date) >= ? AND (upload_date) <= ? AND med_chrgitm_type IN (?)",
|
|
346
|
+ 10721, 1,
|
|
347
|
+ st_stamp,
|
|
348
|
+ end_stamp,
|
|
349
|
+ medChargeTypes).
|
|
350
|
+ Group("order_number, med_chrgitm_type").
|
|
351
|
+ SubQuery() // 作为临时表
|
|
352
|
+
|
|
353
|
+ // 执行主查询
|
|
354
|
+ err := readDb.Table("his_order").
|
|
355
|
+ Select(`
|
|
356
|
+ "" AS 编号,
|
|
357
|
+ his_order.certno AS 医疗保险号,
|
|
358
|
+ his_order.psn_name AS 姓名,
|
|
359
|
+ SUM(CASE WHEN i.med_chrgitm_type = '01' THEN i.det_item_fee_sumamt ELSE 0 END) AS 床位费,
|
|
360
|
+ SUM(CASE WHEN i.med_chrgitm_type = '02' THEN i.det_item_fee_sumamt ELSE 0 END) AS 诊察费,
|
|
361
|
+ SUM(CASE WHEN i.med_chrgitm_type = '03' THEN i.det_item_fee_sumamt ELSE 0 END) AS 检查费,
|
|
362
|
+ SUM(CASE WHEN i.med_chrgitm_type = '04' THEN i.det_item_fee_sumamt ELSE 0 END) AS 化验费,
|
|
363
|
+ SUM(CASE WHEN i.med_chrgitm_type = '05' THEN i.det_item_fee_sumamt ELSE 0 END) AS 治疗费,
|
|
364
|
+ SUM(CASE WHEN i.med_chrgitm_type = '07' THEN i.det_item_fee_sumamt ELSE 0 END) AS 护理费,
|
|
365
|
+ SUM(CASE WHEN i.med_chrgitm_type = '08' THEN i.det_item_fee_sumamt ELSE 0 END) AS 卫生材料费,
|
|
366
|
+ SUM(CASE WHEN i.med_chrgitm_type = '09' THEN i.det_item_fee_sumamt ELSE 0 END) AS 西药费,
|
|
367
|
+ SUM(CASE WHEN i.med_chrgitm_type = '10' THEN i.det_item_fee_sumamt ELSE 0 END) AS 中药饮片费,
|
|
368
|
+ SUM(CASE WHEN i.med_chrgitm_type = '11' THEN i.det_item_fee_sumamt ELSE 0 END) AS 中成药费,
|
|
369
|
+ SUM(CASE WHEN i.med_chrgitm_type = '12' THEN i.det_item_fee_sumamt ELSE 0 END) AS 一般诊疗费,
|
|
370
|
+ SUM(CASE WHEN i.med_chrgitm_type = '13' THEN i.det_item_fee_sumamt ELSE 0 END) AS 挂号费,
|
|
371
|
+ SUM(CASE WHEN i.med_chrgitm_type = '14' THEN i.det_item_fee_sumamt ELSE 0 END) AS 其他费,
|
|
372
|
+ SUM(distinct his_order.medfee_sumamt) AS 医疗费总额,
|
|
373
|
+ SUM(distinct his_order.psn_cash_pay) AS 个人自付金额,
|
|
374
|
+ SUM(distinct his_order.acct_pay) AS 基本账户支付,
|
|
375
|
+ SUM(distinct his_order.acct_mulaid_pay) AS 共济账户支付,
|
|
376
|
+ SUM(distinct his_order.cvlserv_pay) AS 公务员补助,
|
|
377
|
+ SUM(distinct his_order.hifp_pay) AS 统筹支付金额,
|
|
378
|
+ SUM(distinct his_order.maf_pay) AS 医疗救助,
|
|
379
|
+ SUM(distinct his_order.hifmi_pay) AS 大病支付,
|
|
380
|
+ SUM(distinct his_order.hifes_pay) AS 企业补充支付,
|
|
381
|
+ 0 AS 重大疾病补充,
|
|
382
|
+ SUM(distinct his_order.oth_pay) AS 其它支付
|
|
383
|
+ `).
|
|
384
|
+ Joins("JOIN (?) i ON his_order.number = i.order_number", subQuery). // 使用子查询
|
|
385
|
+ 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 = ?",
|
|
386
|
+ 10721, 2, startTime+" 00:00:00", endTime+" 23:59:59", 1, ins, 1).
|
|
387
|
+ Group("his_order.patient_id").
|
|
388
|
+ Scan(&results).Error
|
|
389
|
+
|
|
390
|
+ if err != nil {
|
|
391
|
+ return nil, err
|
|
392
|
+ }
|
|
393
|
+
|
|
394
|
+ return results, nil
|
|
395
|
+}
|