see999 3 years ago
parent
commit
c4c454a2a7
2 changed files with 28 additions and 6 deletions
  1. 13 5
      controllers/his_api_controller.go
  2. 15 1
      service/his_service.go

+ 13 - 5
controllers/his_api_controller.go View File

2802
  	ids_arr := strings.Split(ids_str,  ",")
2802
  	ids_arr := strings.Split(ids_str,  ",")
2803
 	if tempOrder.ID == 0 {
2803
 	if tempOrder.ID == 0 {
2804
 		if settle_accounts_type == 1 { //日结
2804
 		if settle_accounts_type == 1 { //日结
2805
+			fmt.Println(reg_type)
2805
 			if reg_type == 11{
2806
 			if reg_type == 11{
2807
+				fmt.Println(reg_type)
2806
 				prescriptions,_ = service.GetPrescriptionByIds(ids_arr,adminUser.CurrentOrgId)
2808
 				prescriptions,_ = service.GetPrescriptionByIds(ids_arr,adminUser.CurrentOrgId)
2807
 			   }else{
2809
 			   }else{
2808
 				prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
2810
 				prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
2841
 		strconv.FormatInt(his.PatientId, 10)
2843
 		strconv.FormatInt(his.PatientId, 10)
2842
 
2844
 
2843
 		var ids []int64
2845
 		var ids []int64
2844
-
2846
+		fmt.Println(prescriptions)
2845
 		for _, item := range prescriptions {
2847
 		for _, item := range prescriptions {
2846
 			ids = append(ids, item.ID)
2848
 			ids = append(ids, item.ID)
2847
 		}
2849
 		}
2848
-
2849
 		var total float64
2850
 		var total float64
2851
+		fmt.Println(prescriptions)
2850
 		for _, item := range prescriptions {
2852
 		for _, item := range prescriptions {
2853
+			fmt.Println(item)
2851
 			if item.Type == 1 { //药品
2854
 			if item.Type == 1 { //药品
2852
 				for _, subItem := range item.HisDoctorAdviceInfo {
2855
 				for _, subItem := range item.HisDoctorAdviceInfo {
2853
 					total = total + (subItem.Price * subItem.PrescribingNumber)
2856
 					total = total + (subItem.Price * subItem.PrescribingNumber)
4465
 	ids_str := c.GetString("ids")
4468
 	ids_str := c.GetString("ids")
4466
 	ids_arr := strings.Split(ids_str,  ",")
4469
 	ids_arr := strings.Split(ids_str,  ",")
4467
 
4470
 
4468
-
4471
+	fmt.Println(reg_type)
4469
 
4472
 
4470
 	if settle_accounts_type == 1 { //日结
4473
 	if settle_accounts_type == 1 { //日结
4471
 
4474
 
4476
 			prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
4479
 			prescriptions, _ = service.GetSettleHisPrescription(adminUser.CurrentOrgId, id, his_patient_id, recordDateTime, reg_type)
4477
 		}
4480
 		}
4478
 
4481
 
4479
-		
4482
+		fmt.Println(prescriptions)
4480
 	} else { //月结
4483
 	} else { //月结
4481
 		start_time_str := c.GetString("start_time")
4484
 		start_time_str := c.GetString("start_time")
4482
 		end_time_str := c.GetString("end_time")
4485
 		end_time_str := c.GetString("end_time")
4512
 		ids = append(ids, item.ID)
4515
 		ids = append(ids, item.ID)
4513
 	}
4516
 	}
4514
 
4517
 
4518
+	fmt.Println(ids)
4519
+
4515
 	var total float64
4520
 	var total float64
4516
 	for _, item := range prescriptions {
4521
 	for _, item := range prescriptions {
4522
+		fmt.Println(item)
4517
 		if item.Type == 1 { //药品
4523
 		if item.Type == 1 { //药品
4518
 			for _, subItem := range item.HisDoctorAdviceInfo {
4524
 			for _, subItem := range item.HisDoctorAdviceInfo {
4519
 				total = total + (subItem.Price * subItem.PrescribingNumber)
4525
 				total = total + (subItem.Price * subItem.PrescribingNumber)
4560
 
4566
 
4561
 	var customs []*Custom
4567
 	var customs []*Custom
4562
 	for _, item := range prescriptions {
4568
 	for _, item := range prescriptions {
4563
-
4569
+		fmt.Println(item.Type)
4564
 		if item.Type == 1 { //药品
4570
 		if item.Type == 1 { //药品
4565
 			for _, subItem := range item.HisDoctorAdviceInfo {
4571
 			for _, subItem := range item.HisDoctorAdviceInfo {
4566
 				cus := &Custom{
4572
 				cus := &Custom{
4613
 
4619
 
4614
 	}
4620
 	}
4615
 
4621
 
4622
+	fmt.Println(customs)
4623
+
4616
 	for _, item := range customs {
4624
 	for _, item := range customs {
4617
 		var advice_id int64 = 0
4625
 		var advice_id int64 = 0
4618
 		var project_id int64 = 0
4626
 		var project_id int64 = 0

+ 15 - 1
service/his_service.go View File

2048
 
2048
 
2049
 
2049
 
2050
 func GetPrescriptionByIds(ids []string, org_id int64) (prescription []*models.HisPrescription, err error) {
2050
 func GetPrescriptionByIds(ids []string, org_id int64) (prescription []*models.HisPrescription, err error) {
2051
-	err = readDb.Model(&models.HisPrescription{}).Where("id in (?) AND user_org_id = ? AND status = 1", ids, org_id).Find(&prescription).Error
2051
+	err = readDb.Model(&models.HisPrescription{}).
2052
+		Preload("HisAdditionalCharge", func(db *gorm.DB) *gorm.DB {
2053
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("XtHisAddtionConfig", "status=1")
2054
+		}).
2055
+		Preload("HisDoctorAdviceInfo", func(db *gorm.DB) *gorm.DB {
2056
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("Drug", "status=1")
2057
+		}).
2058
+		Preload("HisPrescriptionProject", func(db *gorm.DB) *gorm.DB {
2059
+			return db.Where("status = 1 AND user_org_id = ?", org_id).Preload("HisProject").Preload("GoodInfo", "status=1")
2060
+		}).Preload("TempHisOrder", func(db *gorm.DB) *gorm.DB {
2061
+		return db.Where("status = 1 AND user_org_id = ?", org_id)
2062
+	}).
2063
+		Where("id in (?) AND user_org_id = ? AND status = 1", ids,org_id).
2064
+		Find(&prescription).Error
2065
+	
2052
 	return
2066
 	return
2053
 }
2067
 }