瀏覽代碼

Merge branch '20230223_xt_api_new_branch' of http://git.shengws.com/csx/XT_New into 20230223_xt_api_new_branch

28169 2 月之前
父節點
當前提交
e462439549
共有 2 個文件被更改,包括 69 次插入11 次删除
  1. 64 1
      service/export_data_service.go
  2. 5 10
      service/patientmanage_service.go

+ 64 - 1
service/export_data_service.go 查看文件

@@ -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
+}

+ 5 - 10
service/patientmanage_service.go 查看文件

@@ -1970,20 +1970,15 @@ type InspectionCount struct {
1970 1970
 }
1971 1971
 
1972 1972
 func GetNormalInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1973
-	var count []*InspectionCount
1973
+	var count []*models.Inspection
1974 1974
 	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x Join xt_patients pp on pp.id = x.patient_id and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ?  and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE (xti.status = 1) AND (xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date<= ? and xti.`inspect_value` <= ? and xti.inspect_value >= ? ) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, min_value).Scan(&count).Error
1975
-	for _, items := range count {
1976
-		total = total + items.Count
1977
-	}
1978
-	return total, err2
1975
+
1976
+	return int64(len(count)), err2
1979 1977
 }
1980 1978
 func GetUnusualInspectionTotalByID(startime int64, endtime int64, orgid int64, item_name string, max_value float64, min_value float64) (total int64, err error) {
1981
-	var count []*InspectionCount
1979
+	var count []*models.Inspection
1982 1980
 	err2 := XTReadDB().Table("xt_inspection as xti ").Select("count(*) as count").Joins("join (SELECT max(inspect_date) as ind, patient_id as pid  FROM xt_inspection as x JOIN xt_patients pp on pp.id = x.patient_id and pp.status = 1 and pp.lapseto = 1  WHERE (x.status = 1) AND (x.org_id = ? and x.item_name = ?  and x.inspect_date >= ? and x.inspect_date <= ?) group by patient_id) as ta on ta.ind = xti.`inspect_date` and xti.patient_id = ta.pid  WHERE   (xti.status = 1 AND xti.org_id = ? and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value > ?) OR (xti.status = 1 AND xti.org_id = ?  and xti.item_name = ?  and xti.inspect_date >= ? and xti.inspect_date <= ? and xti.inspect_value < ?) Group by xti.patient_id", orgid, item_name, startime, endtime, orgid, item_name, startime, endtime, max_value, orgid, item_name, startime, endtime, min_value).Scan(&count).Error
1983
-	for _, items := range count {
1984
-		total = total + items.Count
1985
-	}
1986
-	return total, err2
1981
+	return int64(len(count)), err2
1987 1982
 }
1988 1983
 func GetPatientNotInspectionTotal(startime int64, endtime int64, orgid int64, item_name string) (total int64, err error) {
1989 1984
 	err = XTReadDB().Model(models.XtPatients{}).Joins("LEFT JOIN xt_inspection pd ON xt_patients.id = pd.patient_id and pd.org_id = ? and pd.item_name = ? and pd.inspect_date >= ? and pd.inspect_date<=? ", orgid, item_name, startime, endtime).Where("xt_patients.user_org_id = ? and xt_patients.status = 1 and pd.patient_id IS NULL and xt_patients.lapseto = 1", orgid).Count(&total).Error